Skip to content

Commit

Permalink
fix: year out of range
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
jagregory committed Nov 24, 2021
1 parent 785fb95 commit bc1fb6f
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/testDataBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const user = (): User => ({
Attributes: [],
Enabled: true,
Password: "Password123!",
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
Username: "Username",
UserStatus: "CONFIRMED",
});
4 changes: 2 additions & 2 deletions src/services/messageDelivery/messageDelivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe("Message Delivery", () => {
Attributes: [],
Password: "hunter2",
Enabled: true,
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
};

describe("when delivery method is EMAIL", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/services/triggers/userMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const UserMigration = ({
Attributes: attributesFromRecord(result.userAttributes ?? {}),
Enabled: true,
Password: password,
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
Username: uuid.v4(),
UserStatus: result.finalUserStatus ?? "CONFIRMED",
};
Expand Down
14 changes: 7 additions & 7 deletions src/services/userPoolClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ describe("User Pool Client", () => {
AllowedOAuthFlowsUserPoolClient: false,
ClientId: expect.stringMatching(/^[a-z0-9]{25}$/),
ClientName: "clientName",
CreationDate: now.getTime(),
LastModifiedDate: now.getTime(),
CreationDate: Math.floor(now.getTime() / 1000),
LastModifiedDate: Math.floor(now.getTime() / 1000),
RefreshTokenValidity: 30,
UserPoolId: "local",
});
Expand All @@ -84,7 +84,7 @@ describe("User Pool Client", () => {

describe("saveUser", () => {
it("saves the user", async () => {
const now = new Date().getTime();
const now = Math.floor(new Date().getTime() / 1000);
const set = jest.fn();

const userPool = await UserPoolClientService.create(
Expand Down Expand Up @@ -154,8 +154,8 @@ describe("User Pool Client", () => {
{ Name: "email", Value: "[email protected]" },
{ Name: "phone_number", Value: "0411000111" },
],
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
Enabled: true,
},
};
Expand Down Expand Up @@ -259,8 +259,8 @@ describe("User Pool Client", () => {
{ Name: "email", Value: "[email protected]" },
{ Name: "phone_number", Value: "0411000111" },
],
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
Enabled: true,
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/services/userPoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export class UserPoolClientService implements UserPoolClient {
ClientId: id,
ClientName: name,
UserPoolId: this.config.Id,
CreationDate: new Date().getTime(),
LastModifiedDate: new Date().getTime(),
CreationDate: Math.floor(new Date().getTime() / 1000),
LastModifiedDate: Math.floor(new Date().getTime() / 1000),
AllowedOAuthFlowsUserPoolClient: false,
RefreshTokenValidity: 30,
};
Expand Down
4 changes: 2 additions & 2 deletions src/targets/adminCreateUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const AdminCreateUser = ({
Enabled: true,
UserStatus: "CONFIRMED",
ConfirmationCode: undefined,
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
};
await userPool.saveUser(user);
// TODO: Shuldn't return password.
Expand Down
2 changes: 1 addition & 1 deletion src/targets/changePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ChangePassword = ({
await userPool.saveUser({
...user,
Password: ProposedPassword,
UserLastModifiedDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
});
// TODO: Should possibly return something?
return {};
Expand Down
20 changes: 10 additions & 10 deletions src/targets/confirmForgotPassword.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe("ConfirmForgotPassword target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand All @@ -86,8 +86,8 @@ describe("ConfirmForgotPassword target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand All @@ -108,8 +108,8 @@ describe("ConfirmForgotPassword target", () => {
ConfirmationCode: undefined,
Enabled: true,
Password: "newPassword",
UserCreateDate: now.getTime(),
UserLastModifiedDate: newNow.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(newNow.getTime() / 1000),
UserStatus: "CONFIRMED",
Username: "0000-0000",
});
Expand All @@ -124,8 +124,8 @@ describe("ConfirmForgotPassword target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand Down Expand Up @@ -161,8 +161,8 @@ describe("ConfirmForgotPassword target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand Down
2 changes: 1 addition & 1 deletion src/targets/confirmForgotPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ConfirmForgotPassword = ({

await userPool.saveUser({
...user,
UserLastModifiedDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
UserStatus: "CONFIRMED",
ConfirmationCode: undefined,
Password: body.Password,
Expand Down
20 changes: 10 additions & 10 deletions src/targets/confirmSignUp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe("ConfirmSignUp target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand All @@ -83,8 +83,8 @@ describe("ConfirmSignUp target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand All @@ -105,8 +105,8 @@ describe("ConfirmSignUp target", () => {
ConfirmationCode: undefined,
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: newNow.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(newNow.getTime() / 1000),
UserStatus: "CONFIRMED",
Username: "0000-0000",
});
Expand All @@ -121,8 +121,8 @@ describe("ConfirmSignUp target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand Down Expand Up @@ -158,8 +158,8 @@ describe("ConfirmSignUp target", () => {
ConfirmationCode: "4567",
Enabled: true,
Password: "pwd",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "UNCONFIRMED",
Username: "0000-0000",
});
Expand Down
2 changes: 1 addition & 1 deletion src/targets/confirmSignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ConfirmSignUp = ({
...user,
UserStatus: "CONFIRMED",
ConfirmationCode: undefined,
UserLastModifiedDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
});

if (triggers.enabled("PostConfirmation")) {
Expand Down
4 changes: 2 additions & 2 deletions src/targets/createUserPoolClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe("CreateUserPoolClient target", () => {
const createdAppClient: AppClient = {
RefreshTokenValidity: 30,
AllowedOAuthFlowsUserPoolClient: false,
LastModifiedDate: new Date().getTime(),
CreationDate: new Date().getTime(),
LastModifiedDate: Math.floor(new Date().getTime() / 1000),
CreationDate: Math.floor(new Date().getTime() / 1000),
UserPoolId: "userPoolId",
ClientId: "abc",
ClientName: "clientName",
Expand Down
4 changes: 2 additions & 2 deletions src/targets/describeUserPoolClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe("DescribeUserPoolClient target", () => {
const existingAppClient: AppClient = {
RefreshTokenValidity: 30,
AllowedOAuthFlowsUserPoolClient: false,
LastModifiedDate: new Date().getTime(),
CreationDate: new Date().getTime(),
LastModifiedDate: Math.floor(new Date().getTime() / 1000),
CreationDate: Math.floor(new Date().getTime() / 1000),
UserPoolId: "userPoolId",
ClientId: "abc",
ClientName: "clientName",
Expand Down
16 changes: 8 additions & 8 deletions src/targets/forgotPassword.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ describe("ForgotPassword target", () => {
Attributes: [{ Name: "email", Value: "[email protected]" }],
Enabled: true,
Password: "hunter2",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "CONFIRMED",
Username: "0000-0000",
});
Expand All @@ -87,8 +87,8 @@ describe("ForgotPassword target", () => {
Attributes: [{ Name: "email", Value: "[email protected]" }],
Enabled: true,
Password: "hunter2",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "CONFIRMED",
Username: "0000-0000",
},
Expand All @@ -114,8 +114,8 @@ describe("ForgotPassword target", () => {
Attributes: [{ Name: "email", Value: "[email protected]" }],
Enabled: true,
Password: "hunter2",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
UserStatus: "CONFIRMED",
Username: "0000-0000",
});
Expand All @@ -130,8 +130,8 @@ describe("ForgotPassword target", () => {
ConfirmationCode: "1234",
Enabled: true,
Password: "hunter2",
UserCreateDate: now.getTime(),
UserLastModifiedDate: now.getTime(),
UserCreateDate: Math.floor(now.getTime() / 1000),
UserLastModifiedDate: Math.floor(now.getTime() / 1000),
// TODO: validate whether an already confirmed user should stay confirmed when password reset starts?
UserStatus: "CONFIRMED",
Username: "0000-0000",
Expand Down
2 changes: 1 addition & 1 deletion src/targets/forgotPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ForgotPassword = ({

await userPool.saveUser({
...user,
UserLastModifiedDate: new Date().getTime(),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
ConfirmationCode: code,
});

Expand Down
4 changes: 2 additions & 2 deletions src/targets/getUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ describe("GetUser target", () => {
Password: "hunter2",
Username: "0000-0000",
Enabled: true,
UserCreateDate: new Date().getTime(),
UserLastModifiedDate: new Date().getTime(),
UserCreateDate: Math.floor(new Date().getTime() / 1000),
UserLastModifiedDate: Math.floor(new Date().getTime() / 1000),
ConfirmationCode: "1234",
});

Expand Down
Loading

0 comments on commit bc1fb6f

Please sign in to comment.