@@ -18,6 +18,7 @@ import {OpenDocOptions} from 'app/common/DocListAPI';
18
18
import { SHARE_KEY_PREFIX } from 'app/common/gristUrls' ;
19
19
import { isLongerThan , pruneArray } from 'app/common/gutil' ;
20
20
import { UserAPI , UserAPIImpl } from 'app/common/UserAPI' ;
21
+ import { AccessTokenResult } from 'app/plugin/GristAPI' ;
21
22
import { GristObjCode } from 'app/plugin/GristData' ;
22
23
import { Deps as DocClientsDeps } from 'app/server/lib/DocClients' ;
23
24
import { DocManager } from 'app/server/lib/DocManager' ;
@@ -27,6 +28,7 @@ import {globalUploadSet} from 'app/server/lib/uploads';
27
28
import { assert } from 'chai' ;
28
29
import { cloneDeep , isMatch , pick } from 'lodash' ;
29
30
import * as sinon from 'sinon' ;
31
+ import * as jwt from 'jsonwebtoken' ;
30
32
import { TestServer } from 'test/gen-server/apiUtils' ;
31
33
import { createDocTools } from 'test/server/docTools' ;
32
34
import { GristClient , openClient } from 'test/server/gristClient' ;
@@ -4125,6 +4127,23 @@ describe('GranularAccess', function() {
4125
4127
await assert . isFulfilled ( owner . getDocAPI ( docId ) . getRows ( 'Table1' ) ) ;
4126
4128
} ) ;
4127
4129
} ) ;
4130
+
4131
+ describe ( "accessToken" , function ( ) {
4132
+ it ( 'respects aclAsUser' , async function ( ) {
4133
+ await freshDoc ( ) ;
4134
+ async function getPayload ( ) {
4135
+ const tokenResult : AccessTokenResult = ( await cliOwner . send ( 'getAccessToken' , 0 , { } ) ) . data ;
4136
+ const token = tokenResult . token ;
4137
+ const payload : any = jwt . decode ( token ) ;
4138
+ return payload ;
4139
+ }
4140
+
4141
+ const ownerPayload = await getPayload ( ) ;
4142
+ await reopenClients ( { linkParameters :
{ aclAsUser :
'[email protected] ' } } ) ;
4143
+ const aclPayload = await getPayload ( ) ;
4144
+ assert ( aclPayload ! . userId != ownerPayload ! . userId ) ;
4145
+ } )
4146
+ } )
4128
4147
} ) ;
4129
4148
4130
4149
async function closeClient ( cli : GristClient ) {
0 commit comments