@@ -1255,6 +1255,56 @@ describe('admin.auth', () => {
1255
1255
} ) ;
1256
1256
} ) ;
1257
1257
1258
+ describe ( 'Project config management operations' , ( ) => {
1259
+ before ( function ( ) {
1260
+ if ( authEmulatorHost ) {
1261
+ this . skip ( ) ; // getConfig is not supported in Auth Emulator
1262
+ }
1263
+ } ) ;
1264
+ const projectConfigOption1 : UpdateProjectConfigRequest = {
1265
+ recaptchaConfig : {
1266
+ emailPasswordEnforcementState : 'AUDIT' ,
1267
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1268
+ } ,
1269
+ } ;
1270
+ const projectConfigOption2 : UpdateProjectConfigRequest = {
1271
+ recaptchaConfig : {
1272
+ emailPasswordEnforcementState : 'OFF' ,
1273
+ } ,
1274
+ } ;
1275
+ const expectedProjectConfig1 : any = {
1276
+ recaptchaConfig : {
1277
+ emailPasswordEnforcementState : 'AUDIT' ,
1278
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1279
+ } ,
1280
+ } ;
1281
+ const expectedProjectConfig2 : any = {
1282
+ recaptchaConfig : {
1283
+ emailPasswordEnforcementState : 'OFF' ,
1284
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1285
+ } ,
1286
+ } ;
1287
+
1288
+ it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
1289
+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
1290
+ . then ( ( actualProjectConfig ) => {
1291
+ expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
1292
+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
1293
+ } )
1294
+ . then ( ( actualProjectConfig ) => {
1295
+ expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig2 ) ;
1296
+ } ) ;
1297
+ } ) ;
1298
+
1299
+ it ( 'getProjectConfig() should resolve with expected project config' , ( ) => {
1300
+ return getAuth ( ) . projectConfigManager ( ) . getProjectConfig ( )
1301
+ . then ( ( actualConfig ) => {
1302
+ const actualConfigObj = actualConfig . toJSON ( ) ;
1303
+ expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
1304
+ } ) ;
1305
+ } ) ;
1306
+ } ) ;
1307
+
1258
1308
describe ( 'Tenant management operations' , ( ) => {
1259
1309
let createdTenantId : string ;
1260
1310
const createdTenants : string [ ] = [ ] ;
@@ -1311,6 +1361,15 @@ describe('admin.auth', () => {
1311
1361
testPhoneNumbers : {
1312
1362
'+16505551234' : '123456' ,
1313
1363
} ,
1364
+ recaptchaConfig : {
1365
+ emailPasswordEnforcementState : 'AUDIT' ,
1366
+ managedRules : [
1367
+ {
1368
+ endScore : 0.3 ,
1369
+ action : 'BLOCK' ,
1370
+ } ,
1371
+ ] ,
1372
+ } ,
1314
1373
} ;
1315
1374
const expectedUpdatedTenant2 : any = {
1316
1375
displayName : 'testTenantUpdated' ,
@@ -1328,6 +1387,15 @@ describe('admin.auth', () => {
1328
1387
disallowedRegions : [ 'AC' , 'AD' ] ,
1329
1388
}
1330
1389
} ,
1390
+ recaptchaConfig : {
1391
+ emailPasswordEnforcementState : 'OFF' ,
1392
+ managedRules : [
1393
+ {
1394
+ endScore : 0.3 ,
1395
+ action : 'BLOCK' ,
1396
+ } ,
1397
+ ] ,
1398
+ } ,
1331
1399
} ;
1332
1400
1333
1401
// https://mochajs.org/
@@ -1740,6 +1808,7 @@ describe('admin.auth', () => {
1740
1808
} ,
1741
1809
multiFactorConfig : deepCopy ( expectedUpdatedTenant . multiFactorConfig ) ,
1742
1810
testPhoneNumbers : deepCopy ( expectedUpdatedTenant . testPhoneNumbers ) ,
1811
+ recaptchaConfig : deepCopy ( expectedUpdatedTenant . recaptchaConfig ) ,
1743
1812
} ;
1744
1813
const updatedOptions2 : UpdateTenantRequest = {
1745
1814
emailSignInConfig : {
@@ -1750,6 +1819,7 @@ describe('admin.auth', () => {
1750
1819
// Test clearing of phone numbers.
1751
1820
testPhoneNumbers : null ,
1752
1821
smsRegionConfig : deepCopy ( expectedUpdatedTenant2 . smsRegionConfig ) ,
1822
+ recaptchaConfig : deepCopy ( expectedUpdatedTenant2 . recaptchaConfig ) ,
1753
1823
} ;
1754
1824
if ( authEmulatorHost ) {
1755
1825
return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
@@ -1801,6 +1871,28 @@ describe('admin.auth', () => {
1801
1871
} ) ;
1802
1872
} ) ;
1803
1873
1874
+ it ( 'updateTenant() should not update tenant reCAPTCHA config is undefined' , ( ) => {
1875
+ expectedUpdatedTenant . tenantId = createdTenantId ;
1876
+ const updatedOptions2 : UpdateTenantRequest = {
1877
+ displayName : expectedUpdatedTenant2 . displayName ,
1878
+ recaptchaConfig : undefined ,
1879
+ } ;
1880
+ if ( authEmulatorHost ) {
1881
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions2 )
1882
+ . then ( ( actualTenant ) => {
1883
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1884
+ // Not supported in Auth Emulator
1885
+ delete ( actualTenantObj as { testPhoneNumbers ?: Record < string , string > } ) . testPhoneNumbers ;
1886
+ delete expectedUpdatedTenant2 . testPhoneNumbers ;
1887
+ expect ( actualTenantObj ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
1888
+ } ) ;
1889
+ }
1890
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions2 )
1891
+ . then ( ( actualTenant ) => {
1892
+ expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
1893
+ } ) ;
1894
+ } ) ;
1895
+
1804
1896
it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
1805
1897
const tenantManager = getAuth ( ) . tenantManager ( ) ;
1806
1898
let tenant = await tenantManager . createTenant ( {
0 commit comments