@@ -12,7 +12,7 @@ describe('OAuth Token API Routes', () => {
1212 const mockRefreshTokenIfNeeded = vi . fn ( )
1313 const mockGetOAuthToken = vi . fn ( )
1414 const mockAuthorizeCredentialUse = vi . fn ( )
15- const mockCheckHybridAuth = vi . fn ( )
15+ const mockCheckSessionOrInternalAuth = vi . fn ( )
1616
1717 const mockLogger = createMockLogger ( )
1818
@@ -42,7 +42,7 @@ describe('OAuth Token API Routes', () => {
4242 } ) )
4343
4444 vi . doMock ( '@/lib/auth/hybrid' , ( ) => ( {
45- checkHybridAuth : mockCheckHybridAuth ,
45+ checkSessionOrInternalAuth : mockCheckSessionOrInternalAuth ,
4646 } ) )
4747 } )
4848
@@ -235,7 +235,7 @@ describe('OAuth Token API Routes', () => {
235235
236236 describe ( 'credentialAccountUserId + providerId path' , ( ) => {
237237 it ( 'should reject unauthenticated requests' , async ( ) => {
238- mockCheckHybridAuth . mockResolvedValueOnce ( {
238+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
239239 success : false ,
240240 error : 'Authentication required' ,
241241 } )
@@ -256,7 +256,7 @@ describe('OAuth Token API Routes', () => {
256256 } )
257257
258258 it ( 'should reject API key authentication' , async ( ) => {
259- mockCheckHybridAuth . mockResolvedValueOnce ( {
259+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
260260 success : true ,
261261 authType : 'api_key' ,
262262 userId : 'test-user-id' ,
@@ -278,7 +278,7 @@ describe('OAuth Token API Routes', () => {
278278 } )
279279
280280 it ( 'should reject internal JWT authentication' , async ( ) => {
281- mockCheckHybridAuth . mockResolvedValueOnce ( {
281+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
282282 success : true ,
283283 authType : 'internal_jwt' ,
284284 userId : 'test-user-id' ,
@@ -300,7 +300,7 @@ describe('OAuth Token API Routes', () => {
300300 } )
301301
302302 it ( 'should reject requests for other users credentials' , async ( ) => {
303- mockCheckHybridAuth . mockResolvedValueOnce ( {
303+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
304304 success : true ,
305305 authType : 'session' ,
306306 userId : 'attacker-user-id' ,
@@ -322,7 +322,7 @@ describe('OAuth Token API Routes', () => {
322322 } )
323323
324324 it ( 'should allow session-authenticated users to access their own credentials' , async ( ) => {
325- mockCheckHybridAuth . mockResolvedValueOnce ( {
325+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
326326 success : true ,
327327 authType : 'session' ,
328328 userId : 'test-user-id' ,
@@ -345,7 +345,7 @@ describe('OAuth Token API Routes', () => {
345345 } )
346346
347347 it ( 'should return 404 when credential not found for user' , async ( ) => {
348- mockCheckHybridAuth . mockResolvedValueOnce ( {
348+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
349349 success : true ,
350350 authType : 'session' ,
351351 userId : 'test-user-id' ,
@@ -373,7 +373,7 @@ describe('OAuth Token API Routes', () => {
373373 */
374374 describe ( 'GET handler' , ( ) => {
375375 it ( 'should return access token successfully' , async ( ) => {
376- mockCheckHybridAuth . mockResolvedValueOnce ( {
376+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
377377 success : true ,
378378 authType : 'session' ,
379379 userId : 'test-user-id' ,
@@ -402,7 +402,7 @@ describe('OAuth Token API Routes', () => {
402402 expect ( response . status ) . toBe ( 200 )
403403 expect ( data ) . toHaveProperty ( 'accessToken' , 'fresh-token' )
404404
405- expect ( mockCheckHybridAuth ) . toHaveBeenCalled ( )
405+ expect ( mockCheckSessionOrInternalAuth ) . toHaveBeenCalled ( )
406406 expect ( mockGetCredential ) . toHaveBeenCalledWith ( mockRequestId , 'credential-id' , 'test-user-id' )
407407 expect ( mockRefreshTokenIfNeeded ) . toHaveBeenCalled ( )
408408 } )
@@ -421,7 +421,7 @@ describe('OAuth Token API Routes', () => {
421421 } )
422422
423423 it ( 'should handle authentication failure' , async ( ) => {
424- mockCheckHybridAuth . mockResolvedValueOnce ( {
424+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
425425 success : false ,
426426 error : 'Authentication required' ,
427427 } )
@@ -440,7 +440,7 @@ describe('OAuth Token API Routes', () => {
440440 } )
441441
442442 it ( 'should handle credential not found' , async ( ) => {
443- mockCheckHybridAuth . mockResolvedValueOnce ( {
443+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
444444 success : true ,
445445 authType : 'session' ,
446446 userId : 'test-user-id' ,
@@ -461,7 +461,7 @@ describe('OAuth Token API Routes', () => {
461461 } )
462462
463463 it ( 'should handle missing access token' , async ( ) => {
464- mockCheckHybridAuth . mockResolvedValueOnce ( {
464+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
465465 success : true ,
466466 authType : 'session' ,
467467 userId : 'test-user-id' ,
@@ -487,7 +487,7 @@ describe('OAuth Token API Routes', () => {
487487 } )
488488
489489 it ( 'should handle token refresh failure' , async ( ) => {
490- mockCheckHybridAuth . mockResolvedValueOnce ( {
490+ mockCheckSessionOrInternalAuth . mockResolvedValueOnce ( {
491491 success : true ,
492492 authType : 'session' ,
493493 userId : 'test-user-id' ,
0 commit comments