@@ -1164,29 +1164,41 @@ describe('admin.auth', () => {
11641164 recaptchaConfig : {
11651165 emailPasswordEnforcementState : 'AUDIT' ,
11661166 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1167+ useAccountDefender : true ,
11671168 } ,
11681169 } ;
11691170 const projectConfigOption2 : UpdateProjectConfigRequest = {
11701171 recaptchaConfig : {
11711172 emailPasswordEnforcementState : 'OFF' ,
1173+ useAccountDefender : false ,
1174+ } ,
1175+ } ;
1176+ const projectConfigOption3 : UpdateProjectConfigRequest = {
1177+ recaptchaConfig : {
1178+ emailPasswordEnforcementState : 'OFF' ,
1179+ useAccountDefender : true ,
11721180 } ,
11731181 } ;
11741182 const expectedProjectConfig1 : any = {
11751183 recaptchaConfig : {
11761184 emailPasswordEnforcementState : 'AUDIT' ,
11771185 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1186+ useAccountDefender : true ,
11781187 } ,
11791188 } ;
11801189 const expectedProjectConfig2 : any = {
11811190 recaptchaConfig : {
11821191 emailPasswordEnforcementState : 'OFF' ,
11831192 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1193+ useAccountDefender : false ,
11841194 } ,
11851195 } ;
11861196
11871197 it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
11881198 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
11891199 . then ( ( actualProjectConfig ) => {
1200+ // ReCAPTCHA keys are generated differently each time.
1201+ delete actualProjectConfig . recaptchaConfig ?. recaptchaKeys ;
11901202 expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
11911203 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
11921204 } )
@@ -1202,6 +1214,11 @@ describe('admin.auth', () => {
12021214 expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
12031215 } ) ;
12041216 } ) ;
1217+
1218+ it ( 'updateProjectConfig() should reject when trying to enable Account Defender while reCAPTCHA is disabled' , ( ) => {
1219+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption3 )
1220+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
1221+ } ) ;
12051222 } ) ;
12061223
12071224 describe ( 'Tenant management operations' , ( ) => {
@@ -1268,6 +1285,7 @@ describe('admin.auth', () => {
12681285 action : 'BLOCK' ,
12691286 } ,
12701287 ] ,
1288+ useAccountDefender : true ,
12711289 } ,
12721290 } ;
12731291 const expectedUpdatedTenant2 : any = {
@@ -1289,6 +1307,7 @@ describe('admin.auth', () => {
12891307 action : 'BLOCK' ,
12901308 } ,
12911309 ] ,
1310+ useAccountDefender : false ,
12921311 } ,
12931312 } ;
12941313
@@ -1764,6 +1783,25 @@ describe('admin.auth', () => {
17641783 } ) ;
17651784 } ) ;
17661785
1786+ it ( 'updateTenant() enable Account Defender should be rejected when tenant reCAPTCHA is disabled' ,
1787+ function ( ) {
1788+ // Skipping for now as Emulator resolves this operation, which is not expected.
1789+ // TODO: investigate with Rest API and Access team for this behavior.
1790+ if ( authEmulatorHost ) {
1791+ return this . skip ( ) ;
1792+ }
1793+ expectedUpdatedTenant . tenantId = createdTenantId ;
1794+ const updatedOptions : UpdateTenantRequest = {
1795+ displayName : expectedUpdatedTenant2 . displayName ,
1796+ recaptchaConfig : {
1797+ emailPasswordEnforcementState : 'OFF' ,
1798+ useAccountDefender : true ,
1799+ } ,
1800+ } ;
1801+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
1802+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
1803+ } ) ;
1804+
17671805 it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
17681806 const tenantManager = getAuth ( ) . tenantManager ( ) ;
17691807 let tenant = await tenantManager . createTenant ( {
0 commit comments