fix(doctor,configure): skip gateway auth for loopback-only setups

This commit is contained in:
Knox
2026-02-16 22:21:02 +05:30
committed by Peter Steinberger
parent 6757a9fedc
commit 9aa8db5c81
3 changed files with 71 additions and 53 deletions

View File

@@ -82,30 +82,33 @@ async function runTrustedProxyPrompt(params: {
tailscaleMode?: "off" | "serve";
}) {
return runGatewayPrompt({
selectQueue: ["loopback", "trusted-proxy", params.tailscaleMode ?? "off"],
selectQueue: ["lan", params.tailscaleMode ?? "off", "trusted-proxy"],
textQueue: params.textQueue,
authConfigFactory: ({ mode, trustedProxy }) => ({ mode, trustedProxy }),
});
}
describe("promptGatewayConfig", () => {
it("generates a token when the prompt returns undefined", async () => {
it("skips gateway auth setup for loopback-only gateways", async () => {
const { result } = await runGatewayPrompt({
selectQueue: ["loopback", "token", "off"],
textQueue: ["18789", undefined],
selectQueue: ["loopback", "off"],
textQueue: ["18789"],
randomToken: "generated-token",
authConfigFactory: ({ mode, token, password }) => ({ mode, token, password }),
});
expect(result.token).toBe("generated-token");
expect(result.token).toBeUndefined();
expect(result.config.gateway?.auth).toBeUndefined();
expect(mocks.buildGatewayAuthConfig).not.toHaveBeenCalled();
});
it("does not set password to literal 'undefined' when prompt returns undefined", async () => {
it("configures password auth when gateway is exposed", async () => {
const { call } = await runGatewayPrompt({
selectQueue: ["loopback", "password", "off"],
selectQueue: ["lan", "off", "password"],
textQueue: ["18789", undefined],
randomToken: "unused",
authConfigFactory: ({ mode, token, password }) => ({ mode, token, password }),
});
expect(call?.mode).toBe("password");
expect(call?.password).not.toBe("undefined");
expect(call?.password).toBe("");
});