@@ -1265,29 +1265,41 @@ describe('admin.auth', () => {
1265
1265
recaptchaConfig : {
1266
1266
emailPasswordEnforcementState : 'AUDIT' ,
1267
1267
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1268
+ useAccountDefender : true ,
1268
1269
} ,
1269
1270
} ;
1270
1271
const projectConfigOption2 : UpdateProjectConfigRequest = {
1271
1272
recaptchaConfig : {
1272
1273
emailPasswordEnforcementState : 'OFF' ,
1274
+ useAccountDefender : false ,
1275
+ } ,
1276
+ } ;
1277
+ const projectConfigOption3 : UpdateProjectConfigRequest = {
1278
+ recaptchaConfig : {
1279
+ emailPasswordEnforcementState : 'OFF' ,
1280
+ useAccountDefender : true ,
1273
1281
} ,
1274
1282
} ;
1275
1283
const expectedProjectConfig1 : any = {
1276
1284
recaptchaConfig : {
1277
1285
emailPasswordEnforcementState : 'AUDIT' ,
1278
1286
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1287
+ useAccountDefender : true ,
1279
1288
} ,
1280
1289
} ;
1281
1290
const expectedProjectConfig2 : any = {
1282
1291
recaptchaConfig : {
1283
1292
emailPasswordEnforcementState : 'OFF' ,
1284
1293
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1294
+ useAccountDefender : false ,
1285
1295
} ,
1286
1296
} ;
1287
1297
1288
1298
it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
1289
1299
return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
1290
1300
. then ( ( actualProjectConfig ) => {
1301
+ // ReCAPTCHA keys are generated differently each time.
1302
+ delete actualProjectConfig . recaptchaConfig ?. recaptchaKeys ;
1291
1303
expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
1292
1304
return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
1293
1305
} )
@@ -1303,6 +1315,11 @@ describe('admin.auth', () => {
1303
1315
expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
1304
1316
} ) ;
1305
1317
} ) ;
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
+ } ) ;
1306
1323
} ) ;
1307
1324
1308
1325
describe ( 'Tenant management operations' , ( ) => {
@@ -1369,6 +1386,7 @@ describe('admin.auth', () => {
1369
1386
action : 'BLOCK' ,
1370
1387
} ,
1371
1388
] ,
1389
+ useAccountDefender : true ,
1372
1390
} ,
1373
1391
} ;
1374
1392
const expectedUpdatedTenant2 : any = {
@@ -1395,6 +1413,7 @@ describe('admin.auth', () => {
1395
1413
action : 'BLOCK' ,
1396
1414
} ,
1397
1415
] ,
1416
+ useAccountDefender : false ,
1398
1417
} ,
1399
1418
} ;
1400
1419
@@ -1893,6 +1912,25 @@ describe('admin.auth', () => {
1893
1912
} ) ;
1894
1913
} ) ;
1895
1914
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
+
1896
1934
it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
1897
1935
const tenantManager = getAuth ( ) . tenantManager ( ) ;
1898
1936
let tenant = await tenantManager . createTenant ( {
0 commit comments