Просмотр исходного кода

feat: update tests to reflect changes in scope authentication and enhance access token handling

reiji-h 1 год назад
Родитель
Сommit
c7ebbe130e

+ 3 - 3
apps/app/src/server/middlewares/access-token-parser/access-token-parser.integ.ts

@@ -189,7 +189,7 @@ describe('access-token-parser middleware for access token with scopes', () => {
     expect(nextMock).toHaveBeenCalled();
   });
 
-  it('should authenticate with no scopes', async() => {
+  it('should authenticate with specific scope', async() => {
     // arrange
     const reqMock = mock<AccessTokenParserReq>({
       user: undefined,
@@ -255,7 +255,7 @@ describe('access-token-parser middleware for access token with scopes', () => {
     reqMock.query.access_token = token;
     await accessTokenParser([SCOPE.WRITE.USER.INFO])(reqMock, resMock, nextMock);
 
-    // assert
+    // // assert
     expect(reqMock.user).toBeUndefined();
     expect(serializeUserSecurely).not.toHaveBeenCalled();
     expect(nextMock).toHaveBeenCalled();
@@ -322,7 +322,7 @@ describe('access-token-parser middleware for access token with scopes', () => {
 
     // act - try to access with read:user:info scope
     reqMock.query.access_token = token;
-    await accessTokenParser([SCOPE.READ.USER.INFO])(reqMock, resMock, nextMock);
+    await accessTokenParser([SCOPE.READ.USER.INFO, SCOPE.READ.USER.API.ACCESS_TOKEN])(reqMock, resMock, nextMock);
 
     // assert
     expect(reqMock.user).toBeDefined();