@@ -20,8 +20,8 @@ const VALID_RAW_CONFIG: RawPasskeyConfig = {
2020 enabled : true ,
2121 rpId : 'accounts.firefox.com' ,
2222 allowedOrigins : [ 'https://accounts.firefox.com' ] ,
23- challengeTimeout : 60000 ,
2423 maxPasskeysPerUser : 10 ,
24+ challengeTimeout : 30_000 ,
2525 userVerification : 'required' ,
2626 residentKey : 'required' ,
2727 authenticatorAttachment : '' ,
@@ -90,13 +90,6 @@ describe('PasskeyChallengeRedisProvider', () => {
9090} ) ;
9191
9292describe ( 'PasskeyConfigProvider' , ( ) => {
93- describe ( 'when passkeys.enabled is false' , ( ) => {
94- it ( 'returns null without validation' , async ( ) => {
95- const { config } = await buildModule ( { enabled : false } ) ;
96- expect ( config ) . toBeNull ( ) ;
97- } ) ;
98- } ) ;
99-
10093 describe ( 'when config is valid' , ( ) => {
10194 it ( 'returns a PasskeyConfig instance' , async ( ) => {
10295 const { config } = await buildModule ( VALID_RAW_CONFIG ) ;
@@ -107,7 +100,7 @@ describe('PasskeyConfigProvider', () => {
107100 const { config } = await buildModule ( VALID_RAW_CONFIG ) ;
108101 expect ( config ! . rpId ) . toBe ( 'accounts.firefox.com' ) ;
109102 expect ( config ! . allowedOrigins ) . toEqual ( [ 'https://accounts.firefox.com' ] ) ;
110- expect ( config ! . challengeTimeout ) . toBe ( 60000 ) ;
103+ expect ( config ! . challengeTimeout ) . toBe ( 30_000 ) ;
111104 expect ( config ! . maxPasskeysPerUser ) . toBe ( 10 ) ;
112105 expect ( config ! . userVerification ) . toBe ( 'required' ) ;
113106 expect ( config ! . residentKey ) . toBe ( 'required' ) ;
@@ -125,46 +118,46 @@ describe('PasskeyConfigProvider', () => {
125118 } ) ;
126119
127120 describe ( 'when config is invalid' , ( ) => {
128- it ( 'returns null ' , async ( ) => {
129- const { config } = await buildModule ( {
130- ... VALID_RAW_CONFIG ,
131- rpId : '' ,
132- allowedOrigins : [ 'not-a-valid-origin' ] ,
133- } ) ;
134- expect ( config ) . toBeNull ( ) ;
121+ it ( 'throws ' , async ( ) => {
122+ await expect ( ( ) =>
123+ buildModule ( {
124+ ... VALID_RAW_CONFIG ,
125+ rpId : '' ,
126+ } )
127+ ) . rejects . toThrow ( 'property rpId has failed the following constraints' ) ;
135128 } ) ;
136129
137- it ( 'logs an error with the validation message' , async ( ) => {
138- const { logger } = await buildModule ( {
139- ...VALID_RAW_CONFIG ,
140- allowedOrigins : [ 'not-a-valid-origin' ] ,
141- } ) ;
142- expect ( logger . error ) . toHaveBeenCalledWith (
143- 'passkey.config.invalid' ,
144- expect . objectContaining ( {
145- message : expect . stringContaining (
146- 'Passkeys disabled due to malformed config'
147- ) ,
130+ it ( 'rejects allowedOrigins with trailing path' , async ( ) => {
131+ await expect ( ( ) =>
132+ buildModule ( {
133+ ...VALID_RAW_CONFIG ,
134+ allowedOrigins : 'not-a-valid-origin' ,
148135 } )
136+ ) . rejects . toThrow (
137+ 'property allowedOrigins has failed the following constraints'
149138 ) ;
150139 } ) ;
151140
152141 it ( 'rejects allowedOrigins with trailing path' , async ( ) => {
153- const { config, logger } = await buildModule ( {
154- ...VALID_RAW_CONFIG ,
155- allowedOrigins : [ 'https://accounts.firefox.com/path' ] ,
156- } ) ;
157- expect ( config ) . toBeNull ( ) ;
158- expect ( logger . error ) . toHaveBeenCalled ( ) ;
142+ await expect ( ( ) =>
143+ buildModule ( {
144+ ...VALID_RAW_CONFIG ,
145+ allowedOrigins : [ 'https://accounts.firefox.com/path' ] ,
146+ } )
147+ ) . rejects . toThrow (
148+ 'property allowedOrigins has failed the following constraints'
149+ ) ;
159150 } ) ;
160151
161152 it ( 'rejects empty allowedOrigins array' , async ( ) => {
162- const { config, logger } = await buildModule ( {
163- ...VALID_RAW_CONFIG ,
164- allowedOrigins : [ ] ,
165- } ) ;
166- expect ( config ) . toBeNull ( ) ;
167- expect ( logger . error ) . toHaveBeenCalled ( ) ;
153+ await expect ( ( ) =>
154+ buildModule ( {
155+ ...VALID_RAW_CONFIG ,
156+ allowedOrigins : [ ] ,
157+ } )
158+ ) . rejects . toThrow (
159+ 'property allowedOrigins has failed the following constraints'
160+ ) ;
168161 } ) ;
169162 } ) ;
170163} ) ;
0 commit comments