Skip to content

Commit f57c7d7

Browse files
committed
Branch tenant checks based on emulator vs prod
1 parent 538cfe5 commit f57c7d7

File tree

1 file changed

+77
-18
lines changed

1 file changed

+77
-18
lines changed

test/integration/auth.spec.ts

Lines changed: 77 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,19 @@ 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')
1261+
.eql(expectedCreatedTenant.displayName);
1262+
expect(actualTenantObj).to.have.property('emailSignInConfig')
1263+
.eql(expectedCreatedTenant.emailSignInConfig);
1264+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled')
1265+
.eql(expectedCreatedTenant.anonymousSignInEnabled);
1266+
expect(actualTenantObj).to.have.property('multiFactorConfig')
1267+
.eql(expectedCreatedTenant.multiFactorConfig);
1268+
} else {
1269+
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
1270+
}
12561271
});
12571272
});
12581273

@@ -1494,8 +1509,11 @@ describe('admin.auth', () => {
14941509
}
14951510
});
14961511

1497-
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1498-
it.skip('should support CRUD operations', () => {
1512+
it('should support CRUD operations', function () {
1513+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1514+
if (authEmulatorHost) {
1515+
return this.skip(); // Not yet supported in Auth Emulator.
1516+
}
14991517
return tenantAwareAuth.createProviderConfig(authProviderConfig)
15001518
.then((config) => {
15011519
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1571,9 +1589,12 @@ describe('admin.auth', () => {
15711589
});
15721590
}
15731591
});
1574-
1575-
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1576-
it.skip('should support CRUD operations', () => {
1592+
1593+
it('should support CRUD operations', function () {
1594+
// TODO(lisajian): Unskip once auth emulator supports OIDC/SAML
1595+
if (authEmulatorHost) {
1596+
return this.skip(); // Not yet supported in Auth Emulator.
1597+
}
15771598
return tenantAwareAuth.createProviderConfig(authProviderConfig)
15781599
.then((config) => {
15791600
assertDeepEqualUnordered(authProviderConfig, config);
@@ -1598,7 +1619,19 @@ describe('admin.auth', () => {
15981619
it('getTenant() should resolve with expected tenant', () => {
15991620
return getAuth().tenantManager().getTenant(createdTenantId)
16001621
.then((actualTenant) => {
1601-
expect(actualTenant.toJSON()).to.deep.equal(expectedCreatedTenant);
1622+
const actualTenantObj = actualTenant.toJSON();
1623+
if (authEmulatorHost) {
1624+
expect(actualTenantObj).to.have.property('displayName')
1625+
.eql(expectedCreatedTenant.displayName);
1626+
expect(actualTenantObj).to.have.property('emailSignInConfig')
1627+
.eql(expectedCreatedTenant.emailSignInConfig);
1628+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled')
1629+
.eql(expectedCreatedTenant.anonymousSignInEnabled);
1630+
expect(actualTenantObj).to.have.property('multiFactorConfig')
1631+
.eql(expectedCreatedTenant.multiFactorConfig);
1632+
} else {
1633+
expect(actualTenantObj).to.deep.equal(expectedCreatedTenant);
1634+
}
16021635
});
16031636
});
16041637

@@ -1622,6 +1655,32 @@ describe('admin.auth', () => {
16221655
// Test clearing of phone numbers.
16231656
testPhoneNumbers: null,
16241657
};
1658+
if (authEmulatorHost) {
1659+
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions)
1660+
.then((actualTenant) => {
1661+
const actualTenantObj = actualTenant.toJSON();
1662+
expect(actualTenantObj).to.have.property('displayName')
1663+
.eql(expectedUpdatedTenant.displayName);
1664+
expect(actualTenantObj).to.have.property('emailSignInConfig')
1665+
.eql(expectedUpdatedTenant.emailSignInConfig);
1666+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled')
1667+
.eql(expectedUpdatedTenant.anonymousSignInEnabled);
1668+
expect(actualTenantObj).to.have.property('multiFactorConfig')
1669+
.eql(expectedUpdatedTenant.multiFactorConfig);
1670+
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions2);
1671+
})
1672+
.then((actualTenant) => {
1673+
const actualTenantObj = actualTenant.toJSON();
1674+
expect(actualTenantObj).to.have.property('displayName')
1675+
.eql(expectedUpdatedTenant2.displayName);
1676+
expect(actualTenantObj).to.have.property('emailSignInConfig')
1677+
.eql(expectedUpdatedTenant2.emailSignInConfig);
1678+
expect(actualTenantObj).to.have.property('anonymousSignInEnabled')
1679+
.eql(expectedUpdatedTenant2.anonymousSignInEnabled);
1680+
expect(actualTenantObj).to.have.property('multiFactorConfig')
1681+
.eql(expectedUpdatedTenant2.multiFactorConfig);
1682+
});
1683+
}
16251684
return getAuth().tenantManager().updateTenant(createdTenantId, updatedOptions)
16261685
.then((actualTenant) => {
16271686
expect(actualTenant.toJSON()).to.deep.equal(expectedUpdatedTenant);

0 commit comments

Comments
 (0)