Skip to content

Commit

Permalink
test: add test for invalid callbackUrl handling
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Jun 20, 2022
1 parent 7cf4956 commit e498483
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/next-auth/tests/assert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ it("Show error page if secret is not defined", async () => {
expect(log.error).toBeCalledWith("NO_SECRET", expect.anything())
})

it("Should show configuration error page on invalid `callbackUrl`", async () => {
const { res, log } = await handler(
{ providers: [] },
{ prod: true, params: { callbackUrl: "invalid-callback" } }
)

expect(res.status).toBe(500)
expect(res.html).toMatch(/there is a problem with the server configuration./i)
expect(res.html).toMatch(/check the server logs for more information./i)

expect(log.error).toBeCalledWith(
"INVALID_CALLBACK_URL_ERROR",
expect.anything()
)
})

it("Allow relative `callbackUrl`", async () => {
const { res, log } = await handler(
{ providers: [] },
Expand Down

0 comments on commit e498483

Please sign in to comment.