11import { FastifyRequest } from 'fastify' ;
22import jwt from 'jsonwebtoken' ;
3- import { getVerifiedUser } from '../../../../src/app/user-info/cloud-auth' ;
3+ import { verifyUserWithPublicKeys } from '../../../../src/app/user-info/cloud-auth' ;
44
55type MockFastifyRequest = FastifyRequest & {
66 cookies : Record < string , string > ;
@@ -37,7 +37,7 @@ function createMockRequest(options: {
3737 } as unknown as MockFastifyRequest ;
3838}
3939
40- describe ( 'getVerifiedUser ' , ( ) => {
40+ describe ( 'Verify user with public keys ' , ( ) => {
4141 const publicKey = 'test-public-key' ;
4242
4343 beforeEach ( ( ) => {
@@ -47,7 +47,7 @@ describe('getVerifiedUser', () => {
4747 it ( 'should return undefined when no token is present (no header, no cookie)' , ( ) => {
4848 const mockRequest = createMockRequest ( { headers : { } , cookies : { } } ) ;
4949
50- const result = getVerifiedUser ( mockRequest , publicKey ) ;
50+ const result = verifyUserWithPublicKeys ( mockRequest , [ publicKey ] ) ;
5151
5252 expect ( result ) . toBeUndefined ( ) ;
5353 expect ( jwt . verify ) . not . toHaveBeenCalled ( ) ;
@@ -61,7 +61,7 @@ describe('getVerifiedUser', () => {
6161 cookies : { } ,
6262 } ) ;
6363
64- const result = getVerifiedUser ( mockRequest , publicKey ) ;
64+ const result = verifyUserWithPublicKeys ( mockRequest , [ publicKey ] ) ;
6565
6666 expect ( jwt . verify ) . toHaveBeenCalledWith ( 'header-token' , publicKey , {
6767 algorithms : [ 'RS256' ] ,
@@ -77,7 +77,7 @@ describe('getVerifiedUser', () => {
7777 cookies : { 'cloud-token' : 'cookie-token' } ,
7878 } ) ;
7979
80- const result = getVerifiedUser ( mockRequest , publicKey ) ;
80+ const result = verifyUserWithPublicKeys ( mockRequest , [ publicKey ] ) ;
8181
8282 expect ( jwt . verify ) . toHaveBeenCalledWith ( 'cookie-token' , publicKey , {
8383 algorithms : [ 'RS256' ] ,
@@ -93,7 +93,7 @@ describe('getVerifiedUser', () => {
9393 cookies : { } ,
9494 } ) ;
9595
96- const result = getVerifiedUser ( mockRequest , publicKey ) ;
96+ const result = verifyUserWithPublicKeys ( mockRequest , [ publicKey ] ) ;
9797
9898 expect ( jwt . verify ) . toHaveBeenCalledWith ( 'cookie-header-token' , publicKey , {
9999 algorithms : [ 'RS256' ] ,
@@ -110,7 +110,7 @@ describe('getVerifiedUser', () => {
110110 cookies : { } ,
111111 } ) ;
112112
113- const result = getVerifiedUser ( mockRequest , publicKey ) ;
113+ const result = verifyUserWithPublicKeys ( mockRequest , [ publicKey ] ) ;
114114
115115 expect ( result ) . toBeUndefined ( ) ;
116116 expect ( jwt . verify ) . toHaveBeenCalledWith ( 'bad-token' , publicKey , {
0 commit comments