Skip to content

Commit 83aea9b

Browse files
Updates multi-tenancy integration tests. (#623)
- Enables email action link generation tests after backend bug was fixed. - Adds email link sign-in test case. - Fixes issues with nested multi-tenancy tests not being skipped when they are supposed to.
1 parent 1124348 commit 83aea9b

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

test/integration/auth.spec.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,12 @@ describe('admin.auth', () => {
520520
const rawPassword = 'password';
521521
const rawSalt = 'NaCl';
522522

523-
before(() => {
524-
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
523+
before(function() {
524+
if (!createdTenantId) {
525+
this.skip();
526+
} else {
527+
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
528+
}
525529
});
526530

527531
// Delete test user at the end of test suite.
@@ -571,9 +575,7 @@ describe('admin.auth', () => {
571575
});
572576
});
573577

574-
// Ignore email action link tests for now as there is a bug in the returned tenant ID:
575-
// expected '1085102361755-testTenant1-6rjsn' to equal 'testTenant1-6rjsn'
576-
xit('generateEmailVerificationLink() should generate the link for tenant specific user', () => {
578+
it('generateEmailVerificationLink() should generate the link for tenant specific user', () => {
577579
// Generate email verification link to confirm it is generated in the expected
578580
// tenant context.
579581
return tenantAwareAuth.generateEmailVerificationLink(updatedEmail, actionCodeSettings)
@@ -583,7 +585,7 @@ describe('admin.auth', () => {
583585
});
584586
});
585587

586-
xit('generatePasswordResetLink() should generate the link for tenant specific user', () => {
588+
it('generatePasswordResetLink() should generate the link for tenant specific user', () => {
587589
// Generate password reset link to confirm it is generated in the expected
588590
// tenant context.
589591
return tenantAwareAuth.generatePasswordResetLink(updatedEmail, actionCodeSettings)
@@ -593,6 +595,16 @@ describe('admin.auth', () => {
593595
});
594596
});
595597

598+
it('generateSignInWithEmailLink() should generate the link for tenant specific user', () => {
599+
// Generate link for sign-in to confirm it is generated in the expected
600+
// tenant context.
601+
return tenantAwareAuth.generateSignInWithEmailLink(updatedEmail, actionCodeSettings)
602+
.then((link) => {
603+
// Confirm tenant ID set in link.
604+
expect(getTenantId(link)).equal(createdTenantId);
605+
});
606+
});
607+
596608
it('revokeRefreshTokens() should revoke the tokens for the tenant specific user', () => {
597609
// Revoke refresh tokens.
598610
// On revocation, tokensValidAfterTime will be updated to current time. All tokens issued
@@ -678,16 +690,22 @@ describe('admin.auth', () => {
678690
enableRequestSigning: false,
679691
};
680692

681-
before(() => {
682-
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
693+
before(function() {
694+
if (!createdTenantId) {
695+
this.skip();
696+
} else {
697+
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
698+
}
683699
});
684700

685701
// Delete SAML configuration at the end of test suite.
686702
after(() => {
687-
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
688-
.catch((error) => {
689-
// Ignore error.
690-
});
703+
if (tenantAwareAuth) {
704+
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
705+
.catch((error) => {
706+
// Ignore error.
707+
});
708+
}
691709
});
692710

693711
it('should support CRUD operations', () => {
@@ -730,16 +748,22 @@ describe('admin.auth', () => {
730748
clientId: 'CLIENT_ID3',
731749
};
732750

733-
before(() => {
734-
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
751+
before(function() {
752+
if (!createdTenantId) {
753+
this.skip();
754+
} else {
755+
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
756+
}
735757
});
736758

737759
// Delete OIDC configuration at the end of test suite.
738760
after(() => {
739-
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
740-
.catch((error) => {
741-
// Ignore error.
742-
});
761+
if (tenantAwareAuth) {
762+
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
763+
.catch((error) => {
764+
// Ignore error.
765+
});
766+
}
743767
});
744768

745769
it('should support CRUD operations', () => {

0 commit comments

Comments
 (0)