@@ -1298,6 +1298,56 @@ describe('admin.auth', () => {
1298
1298
} ) ;
1299
1299
} ) ;
1300
1300
1301
+ describe ( 'Project config management operations' , ( ) => {
1302
+ before ( function ( ) {
1303
+ if ( authEmulatorHost ) {
1304
+ this . skip ( ) ; // getConfig is not supported in Auth Emulator
1305
+ }
1306
+ } ) ;
1307
+ const projectConfigOption1 : UpdateProjectConfigRequest = {
1308
+ recaptchaConfig : {
1309
+ emailPasswordEnforcementState : 'AUDIT' ,
1310
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1311
+ } ,
1312
+ } ;
1313
+ const projectConfigOption2 : UpdateProjectConfigRequest = {
1314
+ recaptchaConfig : {
1315
+ emailPasswordEnforcementState : 'OFF' ,
1316
+ } ,
1317
+ } ;
1318
+ const expectedProjectConfig1 : any = {
1319
+ recaptchaConfig : {
1320
+ emailPasswordEnforcementState : 'AUDIT' ,
1321
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1322
+ } ,
1323
+ } ;
1324
+ const expectedProjectConfig2 : any = {
1325
+ recaptchaConfig : {
1326
+ emailPasswordEnforcementState : 'OFF' ,
1327
+ managedRules : [ { endScore : 0.1 , action : 'BLOCK' } ] ,
1328
+ } ,
1329
+ } ;
1330
+
1331
+ it ( 'updateProjectConfig() should resolve with the updated project config' , ( ) => {
1332
+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption1 )
1333
+ . then ( ( actualProjectConfig ) => {
1334
+ expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig1 ) ;
1335
+ return getAuth ( ) . projectConfigManager ( ) . updateProjectConfig ( projectConfigOption2 ) ;
1336
+ } )
1337
+ . then ( ( actualProjectConfig ) => {
1338
+ expect ( actualProjectConfig . toJSON ( ) ) . to . deep . equal ( expectedProjectConfig2 ) ;
1339
+ } ) ;
1340
+ } ) ;
1341
+
1342
+ it ( 'getProjectConfig() should resolve with expected project config' , ( ) => {
1343
+ return getAuth ( ) . projectConfigManager ( ) . getProjectConfig ( )
1344
+ . then ( ( actualConfig ) => {
1345
+ const actualConfigObj = actualConfig . toJSON ( ) ;
1346
+ expect ( actualConfigObj ) . to . deep . equal ( expectedProjectConfig2 ) ;
1347
+ } ) ;
1348
+ } ) ;
1349
+ } ) ;
1350
+
1301
1351
describe ( 'Tenant management operations' , ( ) => {
1302
1352
let createdTenantId : string ;
1303
1353
const createdTenants : string [ ] = [ ] ;
@@ -1378,6 +1428,15 @@ describe('admin.auth', () => {
1378
1428
testPhoneNumbers : {
1379
1429
'+16505551234' : '123456' ,
1380
1430
} ,
1431
+ recaptchaConfig : {
1432
+ emailPasswordEnforcementState : 'AUDIT' ,
1433
+ managedRules : [
1434
+ {
1435
+ endScore : 0.3 ,
1436
+ action : 'BLOCK' ,
1437
+ } ,
1438
+ ] ,
1439
+ } ,
1381
1440
} ;
1382
1441
const expectedUpdatedTenant2 : any = {
1383
1442
displayName : 'testTenantUpdated' ,
@@ -1424,6 +1483,15 @@ describe('admin.auth', () => {
1424
1483
disallowedRegions : [ 'AC' , 'AD' ] ,
1425
1484
}
1426
1485
} ,
1486
+ recaptchaConfig : {
1487
+ emailPasswordEnforcementState : 'OFF' ,
1488
+ managedRules : [
1489
+ {
1490
+ endScore : 0.3 ,
1491
+ action : 'BLOCK' ,
1492
+ } ,
1493
+ ] ,
1494
+ } ,
1427
1495
} ;
1428
1496
1429
1497
// https://mochajs.org/
@@ -1836,6 +1904,7 @@ describe('admin.auth', () => {
1836
1904
} ,
1837
1905
multiFactorConfig : deepCopy ( expectedUpdatedTenant . multiFactorConfig ) ,
1838
1906
testPhoneNumbers : deepCopy ( expectedUpdatedTenant . testPhoneNumbers ) ,
1907
+ recaptchaConfig : deepCopy ( expectedUpdatedTenant . recaptchaConfig ) ,
1839
1908
} ;
1840
1909
const updatedOptions2 : UpdateTenantRequest = {
1841
1910
emailSignInConfig : {
@@ -1846,6 +1915,7 @@ describe('admin.auth', () => {
1846
1915
// Test clearing of phone numbers.
1847
1916
testPhoneNumbers : null ,
1848
1917
smsRegionConfig : deepCopy ( expectedUpdatedTenant2 . smsRegionConfig ) ,
1918
+ recaptchaConfig : deepCopy ( expectedUpdatedTenant2 . recaptchaConfig ) ,
1849
1919
} ;
1850
1920
if ( authEmulatorHost ) {
1851
1921
return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
@@ -1914,11 +1984,31 @@ describe('admin.auth', () => {
1914
1984
} ) ;
1915
1985
}
1916
1986
return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updateRequestNoMfaConfig )
1987
+ } ) ;
1988
+
1989
+ it ( 'updateTenant() should not update tenant reCAPTCHA config is undefined' , ( ) => {
1990
+ expectedUpdatedTenant . tenantId = createdTenantId ;
1991
+ const updatedOptions2 : UpdateTenantRequest = {
1992
+ displayName : expectedUpdatedTenant2 . displayName ,
1993
+ recaptchaConfig : undefined ,
1994
+ } ;
1995
+ if ( authEmulatorHost ) {
1996
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions2 )
1997
+ . then ( ( actualTenant ) => {
1998
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1999
+ // Not supported in Auth Emulator
2000
+ delete ( actualTenantObj as { testPhoneNumbers ?: Record < string , string > } ) . testPhoneNumbers ;
2001
+ delete expectedUpdatedTenant2 . testPhoneNumbers ;
2002
+ expect ( actualTenantObj ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
2003
+ } ) ;
2004
+ }
2005
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions2 )
1917
2006
. then ( ( actualTenant ) => {
1918
2007
expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
1919
2008
} ) ;
1920
2009
} ) ;
1921
2010
2011
+ < < < << << HEAD
1922
2012
it ( 'updateTenant() should not disable SMS MFA when TOTP is disabled' , ( ) => {
1923
2013
expectedUpdatedTenantSmsEnabledTotpDisabled . tenantId = createdTenantId ;
1924
2014
const updateRequestSMSEnabledTOTPDisabled : UpdateTenantRequest = {
@@ -1950,6 +2040,8 @@ describe('admin.auth', () => {
1950
2040
} ) ;
1951
2041
} ) ;
1952
2042
2043
+ = === ===
2044
+ >>> >>> > 50 ef232 ( Recapcha integ test ( #1599 ) )
1953
2045
it ( 'updateTenant() should be able to enable/disable anon provider' , async ( ) => {
1954
2046
const tenantManager = getAuth ( ) . tenantManager ( ) ;
1955
2047
let tenant = await tenantManager . createTenant ( {
0 commit comments