@@ -10,7 +10,12 @@ import {
1010 mockJwtPayload ,
1111 mockMalformedJwt ,
1212} from '../../fixtures' ;
13- import { mockMachineAuthResponses , mockTokens , mockVerificationResults } from '../../fixtures/machine' ;
13+ import {
14+ mockMachineAuthResponses ,
15+ mockSignedOAuthAccessTokenJwt ,
16+ mockTokens ,
17+ mockVerificationResults ,
18+ } from '../../fixtures/machine' ;
1419import { server } from '../../mock-server' ;
1520import type { AuthReason } from '../authStatus' ;
1621import { AuthErrorReason , AuthStatus } from '../authStatus' ;
@@ -1498,40 +1503,12 @@ describe('tokens.authenticateRequest(options)', () => {
14981503 } ) ;
14991504
15001505 test ( 'rejects OAuth JWT token when acceptsToken is session_token' , async ( ) => {
1501- const request = mockRequest ( { authorization : `Bearer ${ mockTokens . oauth_token } ` } ) ;
1502- const result = await authenticateRequest ( request , mockOptions ( { acceptsToken : 'session_token' } ) ) ;
1503-
1504- expect ( result ) . toBeSignedOut ( {
1505- reason : AuthErrorReason . TokenTypeMismatch ,
1506- message : '' ,
1507- tokenType : 'session_token' ,
1508- isAuthenticated : false ,
1509- } ) ;
1510- expect ( result . toAuth ( ) ) . toBeSignedOutToAuth ( ) ;
1511- } ) ;
1512-
1513- test ( 'rejects M2M token when acceptsToken is session_token' , async ( ) => {
1514- const request = mockRequest ( { authorization : `Bearer ${ mockTokens . m2m_token } ` } ) ;
1506+ const request = mockRequest ( { authorization : `Bearer ${ mockSignedOAuthAccessTokenJwt } ` } ) ;
15151507 const result = await authenticateRequest ( request , mockOptions ( { acceptsToken : 'session_token' } ) ) ;
15161508
15171509 expect ( result ) . toBeSignedOut ( {
15181510 reason : AuthErrorReason . TokenTypeMismatch ,
15191511 message : '' ,
1520- tokenType : 'session_token' ,
1521- isAuthenticated : false ,
1522- } ) ;
1523- expect ( result . toAuth ( ) ) . toBeSignedOutToAuth ( ) ;
1524- } ) ;
1525-
1526- test ( 'rejects API key when acceptsToken is session_token' , async ( ) => {
1527- const request = mockRequest ( { authorization : `Bearer ${ mockTokens . api_key } ` } ) ;
1528- const result = await authenticateRequest ( request , mockOptions ( { acceptsToken : 'session_token' } ) ) ;
1529-
1530- expect ( result ) . toBeSignedOut ( {
1531- reason : AuthErrorReason . TokenTypeMismatch ,
1532- message : '' ,
1533- tokenType : 'session_token' ,
1534- isAuthenticated : false ,
15351512 } ) ;
15361513 expect ( result . toAuth ( ) ) . toBeSignedOutToAuth ( ) ;
15371514 } ) ;
0 commit comments