Skip to content

Commit 5f67e2d

Browse files
committed
Branch tenant checks based on emulator vs prod
1 parent 73415dc commit 5f67e2d

File tree

1 file changed

+61
-18
lines changed

1 file changed

+61
-18
lines changed

test/integration/auth.spec.ts

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,14 @@ describe('admin.auth', () => {
11831183
state: 'ENABLED',
11841184
factorIds: ['phone'],
11851185
},
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
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
1190+
testPhoneNumbers: {
1191+
'+16505551234': '019287',
1192+
'+16505550676': '985235',
1193+
},
11891194
};
11901195
const expectedUpdatedTenant: any = {
11911196
displayName: 'testTenantUpdated',
@@ -1198,10 +1203,12 @@ describe('admin.auth', () => {
11981203
state: 'DISABLED',
11991204
factorIds: [],
12001205
},
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: {},
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
1209+
testPhoneNumbers: {
1210+
'+16505551234': '123456',
1211+
},
12051212
};
12061213
const expectedUpdatedTenant2: any = {
12071214
displayName: 'testTenantUpdated',
@@ -1214,10 +1221,6 @@ describe('admin.auth', () => {
12141221
state: 'ENABLED',
12151222
factorIds: ['phone'],
12161223
},
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: {},
12211224
};
12221225

12231226
// https://mochajs.org/
@@ -1252,7 +1255,15 @@ describe('admin.auth', () => {
12521255
createdTenantId = actualTenant.tenantId;
12531256
createdTenants.push(createdTenantId);
12541257
expectedCreatedTenant.tenantId = createdTenantId;
1255-
expect(actualTenant.toJSON()).to.deep.equal(expectedCreatedTenant);
1258+
const actualTenantObj = actualTenant.toJSON();
1259+
if (authEmulatorHost) {
1260+
expect(actualTenantObj).to.have.property('displayName').eql(expectedCreatedTenant.displayName);
1261+
expect(actualTenantObj).to.have.property('emailSignInConfig').eql(expectedCreatedTenant.emailSignInConfig);
1262+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled').eql(expectedCreatedTenant.anonymousSignInEnabled);
1263+
expect(actualTenantObj).to.have.property('multiFactorConfig').eql(expectedCreatedTenant.multiFactorConfig);
1264+
} else {
1265+
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
1266+
}
12561267
});
12571268
});
12581269

@@ -1494,8 +1505,11 @@ describe('admin.auth', () => {
14941505
}
14951506
});
14961507

1497-
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1498-
it.skip('should support CRUD operations', () => {
1508+
it('should support CRUD operations', function () {
1509+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1510+
if (authEmulatorHost) {
1511+
return this.skip(); // Not yet supported in Auth Emulator.
1512+
}
14991513
return tenantAwareAuth.createProviderConfig(authProviderConfig)
15001514
.then((config) => {
15011515
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1571,9 +1585,12 @@ describe('admin.auth', () => {
15711585
});
15721586
}
15731587
});
1574-
1575-
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1576-
it.skip('should support CRUD operations', () => {
1588+
1589+
it('should support CRUD operations', function () {
1590+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1591+
if (authEmulatorHost) {
1592+
return this.skip(); // Not yet supported in Auth Emulator.
1593+
}
15771594
return tenantAwareAuth.createProviderConfig(authProviderConfig)
15781595
.then((config) => {
15791596
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1598,7 +1615,15 @@ describe('admin.auth', () => {
15981615
it('getTenant() should resolve with expected tenant', () => {
15991616
return getAuth().tenantManager().getTenant(createdTenantId)
16001617
.then((actualTenant) => {
1601-
expect(actualTenant.toJSON()).to.deep.equal(expectedCreatedTenant);
1618+
const actualTenantObj = actualTenant.toJSON();
1619+
if (authEmulatorHost) {
1620+
expect(actualTenantObj).to.have.property('displayName').eql(expectedCreatedTenant.displayName);
1621+
expect(actualTenantObj).to.have.property('emailSignInConfig').eql(expectedCreatedTenant.emailSignInConfig);
1622+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled').eql(expectedCreatedTenant.anonymousSignInEnabled);
1623+
expect(actualTenantObj).to.have.property('multiFactorConfig').eql(expectedCreatedTenant.multiFactorConfig);
1624+
} else {
1625+
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
1626+
}
16021627
});
16031628
});
16041629

@@ -1622,6 +1647,24 @@ describe('admin.auth', () => {
16221647
// Test clearing of phone numbers.
16231648
testPhoneNumbers: null,
16241649
};
1650+
if (authEmulatorHost) {
1651+
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions)
1652+
.then((actualTenant) => {
1653+
const actualTenantObj = actualTenant.toJSON();
1654+
expect(actualTenantObj).to.have.property('displayName').eql(expectedUpdatedTenant.displayName);
1655+
expect(actualTenantObj).to.have.property('emailSignInConfig').eql(expectedUpdatedTenant.emailSignInConfig);
1656+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled').eql(expectedUpdatedTenant.anonymousSignInEnabled);
1657+
expect(actualTenantObj).to.have.property('multiFactorConfig').eql(expectedUpdatedTenant.multiFactorConfig);
1658+
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions2);
1659+
})
1660+
.then((actualTenant) => {
1661+
const actualTenantObj = actualTenant.toJSON();
1662+
expect(actualTenantObj).to.have.property('displayName').eql(expectedUpdatedTenant2.displayName);
1663+
expect(actualTenantObj).to.have.property('emailSignInConfig').eql(expectedUpdatedTenant2.emailSignInConfig);
1664+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled').eql(expectedUpdatedTenant2.anonymousSignInEnabled);
1665+
expect(actualTenantObj).to.have.property('multiFactorConfig').eql(expectedUpdatedTenant2.multiFactorConfig);
1666+
});
1667+
}
16251668
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions)
16261669
.then((actualTenant) => {
16271670
expect(actualTenant.toJSON()).to.deep.equal(expectedUpdatedTenant);

0 commit comments

Comments
 (0)