-
Notifications
You must be signed in to change notification settings - Fork 393
Adds basic integration tests for the following in multi-tenancy context: #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bojeil-google
commented
Jun 25, 2019
- User management
- Custom claims
- Import users
- List users
- Token revocation
- Email link generation (skipped due to backend bug)
- OIDC/SAML management APIs.
- User management - Custom claims - Import users - List users - Token revocation - Email link generation (skipped due to backend bug) - OIDC/SAML management APIs.
Removes unnecessary import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about verifyIdToken()? Do we need integration test for that, or is unit test sufficient already?
I want to add testing for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good. Just a few suggestions for improvement.
test/integration/auth.spec.ts
Outdated
.then((userRecord) => { | ||
createdUserUid = userRecord.uid; | ||
expect(userRecord.tenantId).to.equal(createdTenantId); | ||
expect(userRecord.email.toLowerCase()).to.equal(newUserData.email.toLowerCase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call toLowerCase() on line 515 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/integration/auth.spec.ts
Outdated
|
||
it('revokeRefreshTokens() should revoke the tokens for the tenant specific user', () => { | ||
// Revoke refresh tokens. | ||
currentTime = new Date().getTime() - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a comment to explain - 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes to clarify and added comments.
test/integration/auth.spec.ts
Outdated
.then((listUsersResult) => { | ||
// Confirm expected user returned in the list. | ||
let expectedUserFound = false; | ||
listUsersResult.users.forEach((user) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the functional style is more readable for this sort of things:
const allUsersBelongToTenant = listUsersResult.users.every(user => user.tenantId == createdTenantId);
expect(allUsersBelongToTenant).to.be.true;
const knownUserInTenant = listUsersResult.users.some(user => user.uid == createdUserUid);
expect(knownUserInTenant).to.be.true;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const rawSalt = 'NaCl'; | ||
|
||
before(() => { | ||
tenantAwareAuth = admin.auth().forTenant(createdTenantId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this outside before
? Something like:
const tenantAwareAuth = admin.auth().forTenant(createdTenantId);
Here and in other similar describe blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't because initializeApp
has to be called before I do this. We call it in before
at setup: https://github.com/firebase/firebase-admin-node/blob/auth-multi-tenancy/test/integration/setup.ts#L40
It is not worth a refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM