Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions test/integration/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,12 @@ describe('admin.auth', () => {
const rawPassword = 'password';
const rawSalt = 'NaCl';

before(() => {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
before(function() {
if (!createdTenantId) {
this.skip();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this happen? if the tenant creation fails in an earlier test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the skip test is not getting applied for nested tests. So i added a check when no tenant is created (typically when the test is skipped or if tenant creation fails) to skip the nested tests.

} else {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
}
});

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

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

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

it('generateSignInWithEmailLink() should generate the link for tenant specific user', () => {
// Generate link for sign-in to confirm it is generated in the expected
// tenant context.
return tenantAwareAuth.generateSignInWithEmailLink(updatedEmail, actionCodeSettings)
.then((link) => {
// Confirm tenant ID set in link.
expect(getTenantId(link)).equal(createdTenantId);
});
});

it('revokeRefreshTokens() should revoke the tokens for the tenant specific user', () => {
// Revoke refresh tokens.
// On revocation, tokensValidAfterTime will be updated to current time. All tokens issued
Expand Down Expand Up @@ -678,16 +690,22 @@ describe('admin.auth', () => {
enableRequestSigning: false,
};

before(() => {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
before(function() {
if (!createdTenantId) {
this.skip();
} else {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
}
});

// Delete SAML configuration at the end of test suite.
after(() => {
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
.catch((error) => {
// Ignore error.
});
if (tenantAwareAuth) {
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
.catch((error) => {
// Ignore error.
});
}
});

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

before(() => {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
before(function() {
if (!createdTenantId) {
this.skip();
} else {
tenantAwareAuth = admin.auth().tenantManager().authForTenant(createdTenantId);
}
});

// Delete OIDC configuration at the end of test suite.
after(() => {
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
.catch((error) => {
// Ignore error.
});
if (tenantAwareAuth) {
return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId)
.catch((error) => {
// Ignore error.
});
}
});

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