@@ -1183,6 +1183,10 @@ describe('admin.auth', () => {
1183
1183
state : 'ENABLED' ,
1184
1184
factorIds : [ 'phone' ] ,
1185
1185
} ,
1186
+ // These test phone numbers will not be checked when running integration
1187
+ // tests against the emulator suite and are ignored in auth emulator
1188
+ // altogether. For more information, please refer to this section of the
1189
+ // auth emulator DD: go/firebase-auth-emulator-dd#heading=h.odk06so2ydjd
1186
1190
testPhoneNumbers : {
1187
1191
'+16505551234' : '019287' ,
1188
1192
'+16505550676' : '985235' ,
@@ -1199,6 +1203,9 @@ describe('admin.auth', () => {
1199
1203
state : 'DISABLED' ,
1200
1204
factorIds : [ ] ,
1201
1205
} ,
1206
+ // Test phone numbers will not be checked when running integration tests
1207
+ // against emulator suite. For more information, please refer to:
1208
+ // go/firebase-auth-emulator-dd#heading=h.odk06so2ydjd
1202
1209
testPhoneNumbers : {
1203
1210
'+16505551234' : '123456' ,
1204
1211
} ,
@@ -1248,7 +1255,13 @@ describe('admin.auth', () => {
1248
1255
createdTenantId = actualTenant . tenantId ;
1249
1256
createdTenants . push ( createdTenantId ) ;
1250
1257
expectedCreatedTenant . tenantId = createdTenantId ;
1251
- expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedCreatedTenant ) ;
1258
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1259
+ if ( authEmulatorHost ) {
1260
+ // Not supported in Auth Emulator
1261
+ delete ( actualTenantObj as { testPhoneNumbers : Record < string , string > } ) . testPhoneNumbers ;
1262
+ delete expectedCreatedTenant . testPhoneNumbers ;
1263
+ }
1264
+ expect ( actualTenantObj ) . to . deep . equal ( expectedCreatedTenant ) ;
1252
1265
} ) ;
1253
1266
} ) ;
1254
1267
@@ -1490,7 +1503,11 @@ describe('admin.auth', () => {
1490
1503
}
1491
1504
} ) ;
1492
1505
1493
- it ( 'should support CRUD operations' , ( ) => {
1506
+ it ( 'should support CRUD operations' , function ( ) {
1507
+ // TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1508
+ if ( authEmulatorHost ) {
1509
+ return this . skip ( ) ; // Not yet supported in Auth Emulator.
1510
+ }
1494
1511
return tenantAwareAuth . createProviderConfig ( authProviderConfig )
1495
1512
. then ( ( config ) => {
1496
1513
assertDeepEqualUnordered ( authProviderConfig , config ) ;
@@ -1566,8 +1583,12 @@ describe('admin.auth', () => {
1566
1583
} ) ;
1567
1584
}
1568
1585
} ) ;
1569
-
1570
- it ( 'should support CRUD operations' , ( ) => {
1586
+
1587
+ it ( 'should support CRUD operations' , function ( ) {
1588
+ // TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1589
+ if ( authEmulatorHost ) {
1590
+ return this . skip ( ) ; // Not yet supported in Auth Emulator.
1591
+ }
1571
1592
return tenantAwareAuth . createProviderConfig ( authProviderConfig )
1572
1593
. then ( ( config ) => {
1573
1594
assertDeepEqualUnordered ( authProviderConfig , config ) ;
@@ -1592,7 +1613,13 @@ describe('admin.auth', () => {
1592
1613
it ( 'getTenant() should resolve with expected tenant' , ( ) => {
1593
1614
return getAuth ( ) . tenantManager ( ) . getTenant ( createdTenantId )
1594
1615
. then ( ( actualTenant ) => {
1595
- expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedCreatedTenant ) ;
1616
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1617
+ if ( authEmulatorHost ) {
1618
+ // Not supported in Auth Emulator
1619
+ delete ( actualTenantObj as { testPhoneNumbers : Record < string , string > } ) . testPhoneNumbers ;
1620
+ delete expectedCreatedTenant . testPhoneNumbers ;
1621
+ }
1622
+ expect ( actualTenantObj ) . to . deep . equal ( expectedCreatedTenant ) ;
1596
1623
} ) ;
1597
1624
} ) ;
1598
1625
@@ -1616,6 +1643,24 @@ describe('admin.auth', () => {
1616
1643
// Test clearing of phone numbers.
1617
1644
testPhoneNumbers : null ,
1618
1645
} ;
1646
+ if ( authEmulatorHost ) {
1647
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
1648
+ . then ( ( actualTenant ) => {
1649
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1650
+ // Not supported in Auth Emulator
1651
+ delete ( actualTenantObj as { testPhoneNumbers : Record < string , string > } ) . testPhoneNumbers ;
1652
+ delete expectedUpdatedTenant . testPhoneNumbers ;
1653
+ expect ( actualTenantObj ) . to . deep . equal ( expectedUpdatedTenant ) ;
1654
+ return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions2 ) ;
1655
+ } )
1656
+ . then ( ( actualTenant ) => {
1657
+ const actualTenantObj = actualTenant . toJSON ( ) ;
1658
+ // Not supported in Auth Emulator
1659
+ delete ( actualTenantObj as { testPhoneNumbers : Record < string , string > } ) . testPhoneNumbers ;
1660
+ delete expectedUpdatedTenant2 . testPhoneNumbers ;
1661
+ expect ( actualTenantObj ) . to . deep . equal ( expectedUpdatedTenant2 ) ;
1662
+ } ) ;
1663
+ }
1619
1664
return getAuth ( ) . tenantManager ( ) . updateTenant ( createdTenantId , updatedOptions )
1620
1665
. then ( ( actualTenant ) => {
1621
1666
expect ( actualTenant . toJSON ( ) ) . to . deep . equal ( expectedUpdatedTenant ) ;
@@ -1675,15 +1720,28 @@ describe('admin.auth', () => {
1675
1720
} ) ;
1676
1721
1677
1722
it ( 'deleteTenant() should successfully delete the provided tenant' , ( ) => {
1723
+ const allTenantIds : string [ ] = [ ] ;
1724
+ const listAllTenantIds = ( tenantIds : string [ ] , nextPageToken ?: string ) : Promise < void > => {
1725
+ return getAuth ( ) . tenantManager ( ) . listTenants ( 100 , nextPageToken )
1726
+ . then ( ( result ) => {
1727
+ result . tenants . forEach ( ( tenant ) => {
1728
+ tenantIds . push ( tenant . tenantId ) ;
1729
+ } ) ;
1730
+ if ( result . pageToken ) {
1731
+ return listAllTenantIds ( tenantIds , result . pageToken ) ;
1732
+ }
1733
+ } ) ;
1734
+ } ;
1735
+
1678
1736
return getAuth ( ) . tenantManager ( ) . deleteTenant ( createdTenantId )
1679
1737
. then ( ( ) => {
1680
- return getAuth ( ) . tenantManager ( ) . getTenant ( createdTenantId ) ;
1738
+ // Use listTenants() instead of getTenant() to check that the tenant
1739
+ // is no longer present, because Auth Emulator implicitly creates the
1740
+ // tenant in getTenant() when it is not found
1741
+ return listAllTenantIds ( allTenantIds ) ;
1681
1742
} )
1682
1743
. then ( ( ) => {
1683
- throw new Error ( 'unexpected success' ) ;
1684
- } )
1685
- . catch ( ( error ) => {
1686
- expect ( error . code ) . to . equal ( 'auth/tenant-not-found' ) ;
1744
+ expect ( allTenantIds ) . to . not . contain ( createdTenantId ) ;
1687
1745
} ) ;
1688
1746
} ) ;
1689
1747
} ) ;
0 commit comments