@@ -1164,29 +1164,41 @@ describe('admin.auth', () => {
1164
1164
recaptchaConfig : {
1165
1165
emailPasswordEnforcementState : 'AUDIT' ,
1166
1166
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1167
+ useAccountDefender : true ,
1167
1168
} ,
1168
1169
} ;
1169
1170
const projectConfigOption2 : UpdateProjectConfigRequest = {
1170
1171
recaptchaConfig : {
1171
1172
emailPasswordEnforcementState : 'OFF' ,
1173
+ useAccountDefender : false ,
1174
+ } ,
1175
+ } ;
1176
+ const projectConfigOption3 : UpdateProjectConfigRequest = {
1177
+ recaptchaConfig : {
1178
+ emailPasswordEnforcementState : 'OFF' ,
1179
+ useAccountDefender : true ,
1172
1180
} ,
1173
1181
} ;
1174
1182
const expectedProjectConfig1 : any = {
1175
1183
recaptchaConfig : {
1176
1184
emailPasswordEnforcementState : 'AUDIT' ,
1177
1185
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1186
+ useAccountDefender : true ,
1178
1187
} ,
1179
1188
} ;
1180
1189
const expectedProjectConfig2 : any = {
1181
1190
recaptchaConfig : {
1182
1191
emailPasswordEnforcementState : 'OFF' ,
1183
1192
managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1193
+ useAccountDefender : false ,
1184
1194
} ,
1185
1195
} ;
1186
1196
1187
1197
it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
1188
1198
return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
1189
1199
. then ( ( actualProjectConfig ) => {
1200
+ // ReCAPTCHA keys are generated differently each time.
1201
+ delete actualProjectConfig . recaptchaConfig ?. recaptchaKeys ;
1190
1202
expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
1191
1203
return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
1192
1204
} )
@@ -1202,6 +1214,11 @@ describe('admin.auth', () => {
1202
1214
expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
1203
1215
} ) ;
1204
1216
} ) ;
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
+ } ) ;
1205
1222
} ) ;
1206
1223
1207
1224
describe ( 'Tenant management operations' , ( ) => {
@@ -1268,6 +1285,7 @@ describe('admin.auth', () => {
1268
1285
action : 'BLOCK' ,
1269
1286
} ,
1270
1287
] ,
1288
+ useAccountDefender : true ,
1271
1289
} ,
1272
1290
} ;
1273
1291
const expectedUpdatedTenant2 : any = {
@@ -1289,6 +1307,7 @@ describe('admin.auth', () => {
1289
1307
action : 'BLOCK' ,
1290
1308
} ,
1291
1309
] ,
1310
+ useAccountDefender : false ,
1292
1311
} ,
1293
1312
} ;
1294
1313
@@ -1764,6 +1783,25 @@ describe('admin.auth', () => {
1764
1783
} ) ;
1765
1784
} ) ;
1766
1785
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
+
1767
1805
it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
1768
1806
const tenantManager = getAuth ( ) . tenantManager ( ) ;
1769
1807
let tenant = await tenantManager . createTenant ( {
0 commit comments