-
Notifications
You must be signed in to change notification settings - Fork 356
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
fix(auth): Properly parse the lastRefreshTime. #888
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,10 @@ describe('admin.auth', () => { | |
.then((userRecord) => { | ||
expect(userRecord.metadata.lastRefreshTime).to.exist; | ||
expect(isUTCString(userRecord.metadata.lastRefreshTime!)); | ||
const creationTime = new Date(userRecord.metadata.creationTime).getTime(); | ||
const lastRefreshTime = new Date(userRecord.metadata.lastRefreshTime!).getTime(); | ||
expect(creationTime).lte(lastRefreshTime); | ||
expect(lastRefreshTime).lte(creationTime + 3600*1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add spaces: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
}); | ||
} finally { | ||
admin.auth().deleteUser('lastRefreshTimeUser'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,10 +616,12 @@ describe('UserInfo', () => { | |
describe('UserMetadata', () => { | ||
const expectedLastLoginAt = 1476235905000; | ||
const expectedCreatedAt = 1476136676000; | ||
const expectedLastRefreshAt = "2016-10-12T01:31:45.000Z" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use single quotes: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
const actualMetadata: UserMetadata = new UserMetadata({ | ||
localId: 'uid123', | ||
lastLoginAt: expectedLastLoginAt.toString(), | ||
createdAt: expectedCreatedAt.toString(), | ||
lastRefreshAt: expectedLastRefreshAt, | ||
}); | ||
const expectedMetadataJSON = { | ||
lastSignInTime: new Date(expectedLastLoginAt).toUTCString(), | ||
|
@@ -676,6 +678,10 @@ describe('UserMetadata', () => { | |
(actualMetadata as any).creationTime = new Date(); | ||
}).to.throw(Error); | ||
}); | ||
|
||
it('should return expected lastRefreshTime', () => { | ||
expect(actualMetadata.lastRefreshTime).to.equal(new Date(expectedLastRefreshAt).toUTCString()) | ||
}); | ||
}); | ||
|
||
describe('toJSON', () => { | ||
|
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.
You also need to return this in
toJSON
and add a test for itThere 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.
It's in the followup (#889)