@@ -1308,29 +1308,41 @@ describe('admin.auth', () => {
13081308 recaptchaConfig : {
13091309 emailPasswordEnforcementState : 'AUDIT' ,
13101310 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1311+ useAccountDefender : true ,
13111312 } ,
13121313 } ;
13131314 const projectConfigOption2 : UpdateProjectConfigRequest = {
13141315 recaptchaConfig : {
13151316 emailPasswordEnforcementState : 'OFF' ,
1317+ useAccountDefender : false ,
1318+ } ,
1319+ } ;
1320+ const projectConfigOption3 : UpdateProjectConfigRequest = {
1321+ recaptchaConfig : {
1322+ emailPasswordEnforcementState : 'OFF' ,
1323+ useAccountDefender : true ,
13161324 } ,
13171325 } ;
13181326 const expectedProjectConfig1 : any = {
13191327 recaptchaConfig : {
13201328 emailPasswordEnforcementState : 'AUDIT' ,
13211329 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1330+ useAccountDefender : true ,
13221331 } ,
13231332 } ;
13241333 const expectedProjectConfig2 : any = {
13251334 recaptchaConfig : {
13261335 emailPasswordEnforcementState : 'OFF' ,
13271336 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1337+ useAccountDefender : false ,
13281338 } ,
13291339 } ;
13301340
13311341 it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
13321342 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
13331343 . then ( ( actualProjectConfig ) => {
1344+ // ReCAPTCHA keys are generated differently each time.
1345+ delete actualProjectConfig . recaptchaConfig ?. recaptchaKeys ;
13341346 expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
13351347 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
13361348 } )
@@ -1346,6 +1358,11 @@ describe('admin.auth', () => {
13461358 expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
13471359 } ) ;
13481360 } ) ;
1361+
1362+ it ( 'updateProjectConfig() should reject when trying to enable Account Defender while reCAPTCHA is disabled' , ( ) => {
1363+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption3 )
1364+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
1365+ } ) ;
13491366 } ) ;
13501367
13511368 describe ( 'Tenant management operations' , ( ) => {
@@ -1436,6 +1453,7 @@ describe('admin.auth', () => {
14361453 action : 'BLOCK' ,
14371454 } ,
14381455 ] ,
1456+ useAccountDefender : true ,
14391457 } ,
14401458 } ;
14411459 const expectedUpdatedTenant2 : any = {
@@ -1491,6 +1509,7 @@ describe('admin.auth', () => {
14911509 action : 'BLOCK' ,
14921510 } ,
14931511 ] ,
1512+ useAccountDefender : false ,
14941513 } ,
14951514 } ;
14961515
@@ -2007,8 +2026,6 @@ describe('admin.auth', () => {
20072026 expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
20082027 } ) ;
20092028 } ) ;
2010-
2011- < < < << << HEAD
20122029 it ( 'updateTenant() should not disable SMS MFA when TOTP is disabled' , ( ) => {
20132030 expectedUpdatedTenantSmsEnabledTotpDisabled . tenantId = createdTenantId ;
20142031 const updateRequestSMSEnabledTOTPDisabled : UpdateTenantRequest = {
@@ -2040,8 +2057,25 @@ describe('admin.auth', () => {
20402057 } ) ;
20412058 } ) ;
20422059
2043- = === ===
2044- >>> >>> > 50 ef232 ( Recapcha integ test ( #1599 ) )
2060+ it ( 'updateTenant() enable Account Defender should be rejected when tenant reCAPTCHA is disabled' ,
2061+ function ( ) {
2062+ // Skipping for now as Emulator resolves this operation, which is not expected.
2063+ // TODO: investigate with Rest API and Access team for this behavior.
2064+ if ( authEmulatorHost ) {
2065+ return this . skip ( ) ;
2066+ }
2067+ expectedUpdatedTenant . tenantId = createdTenantId ;
2068+ const updatedOptions : UpdateTenantRequest = {
2069+ displayName : expectedUpdatedTenant2 . displayName ,
2070+ recaptchaConfig : {
2071+ emailPasswordEnforcementState : 'OFF' ,
2072+ useAccountDefender : true ,
2073+ } ,
2074+ } ;
2075+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
2076+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
2077+ } ) ;
2078+
20452079 it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
20462080 const tenantManager = getAuth ( ) . tenantManager ( ) ;
20472081 let tenant = await tenantManager . createTenant ( {
0 commit comments