-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: retrieve internal user id instead and pass it to the UserSignIn …
…audit log instead of using the Cognito sub id
- Loading branch information
Showing
3 changed files
with
30 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ import { Session } from "next-auth"; | |
import { logEvent } from "@lib/auditLogs"; | ||
jest.mock("@lib/auditLogs"); | ||
const mockedLogEvent = jest.mocked(logEvent, { shallow: true }); | ||
import { JWT } from "next-auth/jwt"; | ||
|
||
describe("User query tests should fail gracefully", () => { | ||
it("getOrCreateUser should fail gracefully - create", async () => { | ||
|
@@ -26,7 +25,7 @@ describe("User query tests should fail gracefully", () => { | |
}) | ||
); | ||
|
||
const result = await getOrCreateUser({ email: "[email protected]" } as JWT); | ||
const result = await getOrCreateUser("", "[email protected]", undefined); | ||
expect(result).toEqual(null); | ||
expect(mockedLogEvent).not.toBeCalled(); | ||
}); | ||
|
@@ -45,7 +44,7 @@ describe("User query tests should fail gracefully", () => { | |
clientVersion: "4.3.2", | ||
}) | ||
); | ||
const result = await getOrCreateUser({ email: "[email protected]" } as JWT); | ||
const result = await getOrCreateUser("", "[email protected]", undefined); | ||
expect(result).toEqual(null); | ||
expect(mockedLogEvent).not.toBeCalled(); | ||
}); | ||
|
@@ -80,7 +79,7 @@ describe("getOrCreateUser", () => { | |
|
||
(prismaMock.user.findUnique as jest.MockedFunction<any>).mockResolvedValue(user); | ||
|
||
const result = await getOrCreateUser({ email: "[email protected]" } as JWT); | ||
const result = await getOrCreateUser("", "[email protected]", undefined); | ||
expect(result).toMatchObject(user); | ||
expect(mockedLogEvent).not.toBeCalled(); | ||
}); | ||
|
@@ -99,10 +98,7 @@ describe("getOrCreateUser", () => { | |
}); | ||
(prismaMock.user.create as jest.MockedFunction<any>).mockResolvedValue(user); | ||
|
||
const result = await getOrCreateUser({ | ||
name: "test", | ||
email: "[email protected]", | ||
} as JWT); | ||
const result = await getOrCreateUser("test", "[email protected]", undefined); | ||
|
||
expect(result).toMatchObject(user); | ||
expect(prismaMock.user.create).toBeCalledWith({ | ||
|
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