@@ -8,9 +8,6 @@ const AppError = require('../../../../lib/error');
88const {
99 strategy,
1010} = require ( '../../../../lib/routes/auth-schemes/verified-session-token' ) ;
11- const authMethods = require ( '../../../../lib/authMethods' ) ;
12-
13- const HAWK_HEADER = 'Hawk id="123", ts="123", nonce="123", mac="123"' ;
1411
1512describe ( 'lib/routes/auth-schemes/verified-session-token' , ( ) => {
1613 let config ;
@@ -21,10 +18,6 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
2118 let request ;
2219 let getCredentialsFunc ;
2320
24- before ( ( ) => {
25- sinon . stub ( authMethods , 'availableAuthenticationMethods' ) ;
26- } ) ;
27-
2821 beforeEach ( ( ) => {
2922 // Default valid state. This state should pass email verified check, session token verified check,
3023 // and account assurance level check.
@@ -53,12 +46,10 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
5346 authenticatorAssuranceLevel : 1 ,
5447 } ;
5548
56- authMethods . availableAuthenticationMethods = sinon . fake . resolves (
57- new Set ( [ 'pwd' , 'email' ] )
58- ) ;
59-
6049 request = {
61- headers : { authorization : HAWK_HEADER } ,
50+ headers : {
51+ authorization : 'Hawk id="123", ts="123", nonce="123", mac="123"' ,
52+ } ,
6253 auth : { mode : 'required' } ,
6354 route : { path : '/foo/{id}' } ,
6455 } ;
@@ -209,9 +200,10 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
209200
210201 it ( 'fails when AAL mismatch' , async ( ) => {
211202 // Force account AAL=2 by returning otp along with pwd/email
212- authMethods . availableAuthenticationMethods = sinon . fake . resolves (
213- new Set ( [ 'pwd' , 'email' , 'otp' ] )
214- ) ;
203+ db . totpToken = sinon . fake . resolves ( {
204+ verified : true ,
205+ enabled : true ,
206+ } ) ;
215207
216208 const authStrategy = strategy ( getCredentialsFunc , db , config , statsd ) ( ) ;
217209 try {
@@ -231,9 +223,10 @@ describe('lib/routes/auth-schemes/verified-session-token', () => {
231223
232224 it ( 'skips AAL check when configured' , async ( ) => {
233225 // Force account AAL=2 by returning otp along with pwd/email
234- authMethods . availableAuthenticationMethods = sinon . fake . resolves (
235- new Set ( [ 'pwd' , 'email' , 'otp' ] )
236- ) ;
226+ db . totpToken = sinon . fake . resolves ( {
227+ enabled : true ,
228+ verified : true ,
229+ } ) ;
237230
238231 // Skip AAL check for path
239232 config . authStrategies . verifiedSessionToken . skipAalCheckForRoutes = '/foo.*' ;
0 commit comments