Skip to content

Commit a28a692

Browse files
committed
Update multi-tenancy tests to run against auth emulator
1 parent 79769d0 commit a28a692

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

test/integration/auth.spec.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,10 +1183,9 @@ describe('admin.auth', () => {
11831183
state: 'ENABLED',
11841184
factorIds: ['phone'],
11851185
},
1186-
testPhoneNumbers: {
1187-
'+16505551234': '019287',
1188-
'+16505550676': '985235',
1189-
},
1186+
// Test phone numbers are ignored in auth emulator. For more information,
1187+
// please refer to this section of the auth emulator DD:
1188+
// go/firebase-auth-emulator-dd#heading=h.odk06so2ydjd
11901189
};
11911190
const expectedUpdatedTenant: any = {
11921191
displayName: 'testTenantUpdated',
@@ -1199,9 +1198,10 @@ describe('admin.auth', () => {
11991198
state: 'DISABLED',
12001199
factorIds: [],
12011200
},
1202-
testPhoneNumbers: {
1203-
'+16505551234': '123456',
1204-
},
1201+
// Though test phone numbers are ignored in the auth emulator,
1202+
// non-standard update behavior will still initialize this to an empty
1203+
// object.
1204+
testPhoneNumbers: {},
12051205
};
12061206
const expectedUpdatedTenant2: any = {
12071207
displayName: 'testTenantUpdated',
@@ -1214,6 +1214,10 @@ describe('admin.auth', () => {
12141214
state: 'ENABLED',
12151215
factorIds: ['phone'],
12161216
},
1217+
// Though test phone numbers are ignored in the auth emulator,
1218+
// non-standard update behavior will still initialize this to an empty
1219+
// object.
1220+
testPhoneNumbers: {},
12171221
};
12181222

12191223
// https://mochajs.org/
@@ -1490,7 +1494,8 @@ describe('admin.auth', () => {
14901494
}
14911495
});
14921496

1493-
it('should support CRUD operations', () => {
1497+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1498+
it.skip('should support CRUD operations', () => {
14941499
return tenantAwareAuth.createProviderConfig(authProviderConfig)
14951500
.then((config) => {
14961501
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1567,7 +1572,8 @@ describe('admin.auth', () => {
15671572
}
15681573
});
15691574

1570-
it('should support CRUD operations', () => {
1575+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1576+
it.skip('should support CRUD operations', () => {
15711577
return tenantAwareAuth.createProviderConfig(authProviderConfig)
15721578
.then((config) => {
15731579
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1675,15 +1681,28 @@ describe('admin.auth', () => {
16751681
});
16761682

16771683
it('deleteTenant() should successfully delete the provided tenant', () => {
1684+
const allTenantIds: string[] = [];
1685+
const listAllTenantIds = (tenantIds: string[], nextPageToken?: string): Promise<void> => {
1686+
return getAuth().tenantManager().listTenants(100, nextPageToken)
1687+
.then((result) => {
1688+
result.tenants.forEach((tenant) => {
1689+
tenantIds.push(tenant.tenantId);
1690+
});
1691+
if (result.pageToken) {
1692+
return listAllTenantIds(tenantIds, result.pageToken);
1693+
}
1694+
});
1695+
};
1696+
16781697
return getAuth().tenantManager().deleteTenant(createdTenantId)
16791698
.then(() => {
1680-
return getAuth().tenantManager().getTenant(createdTenantId);
1699+
// Use listTenants() instead of getTenant() to check that the tenant
1700+
// is no longer present, because Auth Emulator implicitly creates the
1701+
// tenant in getTenant() when it is not found
1702+
return listAllTenantIds(allTenantIds);
16811703
})
16821704
.then(() => {
1683-
throw new Error('unexpected success');
1684-
})
1685-
.catch((error) => {
1686-
expect(error.code).to.equal('auth/tenant-not-found');
1705+
expect(allTenantIds).to.not.contain(createdTenantId);
16871706
});
16881707
});
16891708
});

0 commit comments

Comments
 (0)