-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lambda): limited CustomMessage lambda support
Only supports the ForgotPassword flow so far
- Loading branch information
Showing
16 changed files
with
498 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { User } from "../services/userPoolClient"; | ||
|
||
export const user = (): User => ({ | ||
Attributes: [], | ||
Enabled: true, | ||
Password: "Password123!", | ||
UserCreateDate: new Date().getTime(), | ||
UserLastModifiedDate: new Date().getTime(), | ||
Username: "Username", | ||
UserStatus: "CONFIRMED", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { MockLogger } from "../../__tests__/mockLogger"; | ||
import { ConsoleMessageSender } from "./consoleMessageSender"; | ||
import * as TDB from "../../__tests__/testDataBuilder"; | ||
|
||
describe("consoleMessageSender", () => { | ||
const user = TDB.user(); | ||
const destination = "[email protected]"; | ||
const mockLog = MockLogger; | ||
const sender = new ConsoleMessageSender(mockLog); | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe.each(["sendEmail", "sendSms"] as const)("%s", (fn) => { | ||
it("prints the message to the console", async () => { | ||
await sender[fn](user, destination, { | ||
__code: "1234", | ||
}); | ||
|
||
expect(mockLog.info).toHaveBeenCalledWith( | ||
expect.stringMatching(/Username:\s+Username/) | ||
); | ||
expect(mockLog.info).toHaveBeenCalledWith( | ||
expect.stringMatching(/Destination:\[email protected]/) | ||
); | ||
expect(mockLog.info).toHaveBeenCalledWith( | ||
expect.stringMatching(/Code:\s+1234/) | ||
); | ||
}); | ||
|
||
it("doesn't print undefined fields", async () => { | ||
await sender[fn](user, destination, { | ||
__code: "1234", | ||
emailMessage: undefined, | ||
}); | ||
|
||
expect(mockLog.info).not.toHaveBeenCalledWith( | ||
expect.stringMatching(/Email Message/) | ||
); | ||
}); | ||
|
||
it("prints additional fields", async () => { | ||
await sender[fn](user, destination, { | ||
__code: "1234", | ||
emailMessage: "this is the email message", | ||
}); | ||
|
||
expect(mockLog.info).toHaveBeenCalledWith( | ||
expect.stringMatching(/Email Message:\s+this is the email message/) | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.