48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { buildGatewayAuthConfig } from "./configure.js";
|
|
|
|
describe("buildGatewayAuthConfig", () => {
|
|
it("preserves allowTailscale when switching to token", () => {
|
|
const result = buildGatewayAuthConfig({
|
|
existing: {
|
|
mode: "password",
|
|
password: "secret",
|
|
allowTailscale: true,
|
|
},
|
|
mode: "token",
|
|
token: "abc",
|
|
});
|
|
|
|
expect(result).toEqual({ mode: "token", token: "abc", allowTailscale: true });
|
|
});
|
|
|
|
it("drops password when switching to token", () => {
|
|
const result = buildGatewayAuthConfig({
|
|
existing: {
|
|
mode: "password",
|
|
password: "secret",
|
|
allowTailscale: false,
|
|
},
|
|
mode: "token",
|
|
token: "abc",
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
mode: "token",
|
|
token: "abc",
|
|
allowTailscale: false,
|
|
});
|
|
});
|
|
|
|
it("drops token when switching to password", () => {
|
|
const result = buildGatewayAuthConfig({
|
|
existing: { mode: "token", token: "abc" },
|
|
mode: "password",
|
|
password: "secret",
|
|
});
|
|
|
|
expect(result).toEqual({ mode: "password", password: "secret" });
|
|
});
|
|
});
|