Skip to content
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

10313 Bug: Actually use TOKEN_EXPIRATION_TIME_HOURS 🤦 #5479

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,29 @@ import { validUser } from '../../../../../shared/src/test/mockUsers';
describe('Verify User Pending Email', () => {
const TOKEN = '41189629-abe1-46d7-b7a4-9d3834f919cb';
const TOKEN_TIMESTAMP_VALID = createISODateString();
const TOKEN_TIMESTAMP_ALMOST_INVALID = DateTime.now()
.setZone('utc')
.minus({ hours: TOKEN_EXPIRATION_TIME_HOURS - 1 })
.toISO()!;

const TOKEN_TIMESTAMP_EXPIRED: string = DateTime.now()
.setZone('utc')
.minus({ hours: TOKEN_EXPIRATION_TIME_HOURS + 1 })
.toISO()!;

describe('userTokenHasExpired', () => {
it('should return true if no token', () => {
it('should return true when no token', () => {
expect(userTokenHasExpired(undefined)).toBe(true);
});
it('should return true if token is outside the expiration window', () => {
it('should return true when token is outside the expiration window', () => {
expect(userTokenHasExpired(TOKEN_TIMESTAMP_EXPIRED)).toBe(true);
});
it('should return false if token is within expiration window', () => {
it('should return false when token is fresh', () => {
expect(userTokenHasExpired(TOKEN_TIMESTAMP_VALID)).toBe(false);
});
it('should return false whem token is almost but not yet expired', () => {
expect(userTokenHasExpired(TOKEN_TIMESTAMP_ALMOST_INVALID)).toBe(false);
});
});

describe('verifyUserPendingEmailInteractor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const userTokenHasExpired = (
calculateDifferenceInHours(
createISODateString(),
tokenExpirationTimestamp,
) > 1
) > TOKEN_EXPIRATION_TIME_HOURS
);
};

Expand Down
Loading