@@ -1265,29 +1265,41 @@ describe('admin.auth', () => {
12651265 recaptchaConfig : {
12661266 emailPasswordEnforcementState : 'AUDIT' ,
12671267 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1268+ useAccountDefender : true ,
12681269 } ,
12691270 } ;
12701271 const projectConfigOption2 : UpdateProjectConfigRequest = {
12711272 recaptchaConfig : {
12721273 emailPasswordEnforcementState : 'OFF' ,
1274+ useAccountDefender : false ,
1275+ } ,
1276+ } ;
1277+ const projectConfigOption3 : UpdateProjectConfigRequest = {
1278+ recaptchaConfig : {
1279+ emailPasswordEnforcementState : 'OFF' ,
1280+ useAccountDefender : true ,
12731281 } ,
12741282 } ;
12751283 const expectedProjectConfig1 : any = {
12761284 recaptchaConfig : {
12771285 emailPasswordEnforcementState : 'AUDIT' ,
12781286 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1287+ useAccountDefender : true ,
12791288 } ,
12801289 } ;
12811290 const expectedProjectConfig2 : any = {
12821291 recaptchaConfig : {
12831292 emailPasswordEnforcementState : 'OFF' ,
12841293 managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1294+ useAccountDefender : false ,
12851295 } ,
12861296 } ;
12871297
12881298 it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
12891299 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
12901300 . then ( ( actualProjectConfig ) => {
1301+ // ReCAPTCHA keys are generated differently each time.
1302+ delete actualProjectConfig . recaptchaConfig ?. recaptchaKeys ;
12911303 expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
12921304 return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
12931305 } )
@@ -1303,6 +1315,11 @@ describe('admin.auth', () => {
13031315 expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
13041316 } ) ;
13051317 } ) ;
1318+
1319+ it ( 'updateProjectConfig() should reject when trying to enable Account Defender while reCAPTCHA is disabled' , ( ) => {
1320+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption3 )
1321+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
1322+ } ) ;
13061323 } ) ;
13071324
13081325 describe ( 'Tenant management operations' , ( ) => {
@@ -1369,6 +1386,7 @@ describe('admin.auth', () => {
13691386 action : 'BLOCK' ,
13701387 } ,
13711388 ] ,
1389+ useAccountDefender : true ,
13721390 } ,
13731391 } ;
13741392 const expectedUpdatedTenant2 : any = {
@@ -1395,6 +1413,7 @@ describe('admin.auth', () => {
13951413 action : 'BLOCK' ,
13961414 } ,
13971415 ] ,
1416+ useAccountDefender : false ,
13981417 } ,
13991418 } ;
14001419
@@ -1893,6 +1912,25 @@ describe('admin.auth', () => {
18931912 } ) ;
18941913 } ) ;
18951914
1915+ it ( 'updateTenant() enable Account Defender should be rejected when tenant reCAPTCHA is disabled' ,
1916+ function ( ) {
1917+ // Skipping for now as Emulator resolves this operation, which is not expected.
1918+ // TODO: investigate with Rest API and Access team for this behavior.
1919+ if ( authEmulatorHost ) {
1920+ return this . skip ( ) ;
1921+ }
1922+ expectedUpdatedTenant . tenantId = createdTenantId ;
1923+ const updatedOptions : UpdateTenantRequest = {
1924+ displayName : expectedUpdatedTenant2 . displayName ,
1925+ recaptchaConfig : {
1926+ emailPasswordEnforcementState : 'OFF' ,
1927+ useAccountDefender : true ,
1928+ } ,
1929+ } ;
1930+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
1931+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/racaptcha-not-enabled' ) ;
1932+ } ) ;
1933+
18961934 it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
18971935 const tenantManager = getAuth ( ) . tenantManager ( ) ;
18981936 let tenant = await tenantManager . createTenant ( {
0 commit comments