Skip to content

Commit 86c8822

Browse files
authored
fix(tests): setEnvDefaults test with AUTH_SECRET/config.secret values (#10400)
1 parent aafa6dd commit 86c8822

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

packages/core/test/env.test.ts

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"
1+
import {
2+
afterAll,
3+
afterEach,
4+
beforeEach,
5+
describe,
6+
expect,
7+
it,
8+
vi,
9+
} from "vitest"
210

311
import { AuthConfig } from "../src/index.js"
412
import { setEnvDefaults, createActionURL } from "../src/lib/utils/env.js"
@@ -86,9 +94,9 @@ describe("config is inferred from environment variables", () => {
8694

8795
it.each([
8896
[{ AUTH_TRUST_HOST: "1", AUTH_SECRET: "asdf" }, { trustHost: true }],
89-
[{ VERCEL: "1" }, { trustHost: true, secret: "asdf" }],
97+
[{ VERCEL: "1", AUTH_SECRET: "asdf" }, { trustHost: true }],
9098
[{ NODE_ENV: "development", AUTH_SECRET: "asdf" }, { trustHost: true }],
91-
[{ NODE_ENV: "test" }, { trustHost: true, secret: "asdf" }],
99+
[{ NODE_ENV: "test", AUTH_SECRET: "asdf" }, { trustHost: true }],
92100
[
93101
{ AUTH_URL: "http://example.com", AUTH_SECRET: "asdf" },
94102
{ trustHost: true },
@@ -100,7 +108,7 @@ describe("config is inferred from environment variables", () => {
100108
})
101109

102110
describe("createActionURL", () => {
103-
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
111+
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => { })
104112

105113
afterEach(() => {
106114
consoleWarnSpy.mockClear()
@@ -189,34 +197,34 @@ const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
189197
expect(consoleWarnSpy).not.toHaveBeenCalled()
190198
})
191199

192-
it.each([
193-
{
194-
args: {
195-
action: "signout",
196-
protocol: undefined,
197-
headers: new Headers({}),
198-
env: { AUTH_URL: "http://localhost:3000/my-app/api/auth/" },
199-
basePath: "/my-app/api/auth",
200-
},
201-
expected: "http://localhost:3000/my-app/api/auth/signout",
202-
},
203-
{
204-
args: {
205-
action: "signout",
206-
protocol: undefined,
207-
headers: new Headers({}),
208-
env: { AUTH_URL: "https://sub.domain.env.com/my-app" },
209-
basePath: "/api/auth",
210-
},
211-
expected: "https://sub.domain.env.com/api/auth/signout",
212-
},
213-
])("Duplicate path configurations: %j", ({ args, expected }) => {
214-
// @ts-expect-error
215-
expect(createActionURL(...Object.values(args)).toString()).toBe(expected)
216-
expect(consoleWarnSpy).toHaveBeenCalled()
217-
})
218-
219-
afterAll(() => {
220-
consoleWarnSpy.mockRestore();
221-
})
200+
it.each([
201+
{
202+
args: {
203+
action: "signout",
204+
protocol: undefined,
205+
headers: new Headers({}),
206+
env: { AUTH_URL: "http://localhost:3000/my-app/api/auth/" },
207+
basePath: "/my-app/api/auth",
208+
},
209+
expected: "http://localhost:3000/my-app/api/auth/signout",
210+
},
211+
{
212+
args: {
213+
action: "signout",
214+
protocol: undefined,
215+
headers: new Headers({}),
216+
env: { AUTH_URL: "https://sub.domain.env.com/my-app" },
217+
basePath: "/api/auth",
218+
},
219+
expected: "https://sub.domain.env.com/api/auth/signout",
220+
},
221+
])("Duplicate path configurations: %j", ({ args, expected }) => {
222+
// @ts-expect-error
223+
expect(createActionURL(...Object.values(args)).toString()).toBe(expected)
224+
expect(consoleWarnSpy).toHaveBeenCalled()
225+
})
226+
227+
afterAll(() => {
228+
consoleWarnSpy.mockRestore()
229+
})
222230
})

0 commit comments

Comments
 (0)