2026-01-08 02:44:09 +00:00
|
|
|
import path from "node:path";
|
2026-01-04 19:08:13 +01:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
|
|
import { resolveOAuthDir, resolveOAuthPath } from "./paths.js";
|
|
|
|
|
|
|
|
|
|
describe("oauth paths", () => {
|
|
|
|
|
it("prefers CLAWDBOT_OAUTH_DIR over CLAWDBOT_STATE_DIR", () => {
|
|
|
|
|
const env = {
|
|
|
|
|
CLAWDBOT_OAUTH_DIR: "/custom/oauth",
|
|
|
|
|
CLAWDBOT_STATE_DIR: "/custom/state",
|
|
|
|
|
} as NodeJS.ProcessEnv;
|
|
|
|
|
|
2026-01-14 14:31:43 +00:00
|
|
|
expect(resolveOAuthDir(env, "/custom/state")).toBe(path.resolve("/custom/oauth"));
|
2026-01-04 19:08:13 +01:00
|
|
|
expect(resolveOAuthPath(env, "/custom/state")).toBe(
|
2026-01-08 02:44:09 +00:00
|
|
|
path.join(path.resolve("/custom/oauth"), "oauth.json"),
|
2026-01-04 19:08:13 +01:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("derives oauth path from CLAWDBOT_STATE_DIR when unset", () => {
|
|
|
|
|
const env = {
|
|
|
|
|
CLAWDBOT_STATE_DIR: "/custom/state",
|
|
|
|
|
} as NodeJS.ProcessEnv;
|
|
|
|
|
|
2026-01-14 14:31:43 +00:00
|
|
|
expect(resolveOAuthDir(env, "/custom/state")).toBe(path.join("/custom/state", "credentials"));
|
2026-01-04 19:08:13 +01:00
|
|
|
expect(resolveOAuthPath(env, "/custom/state")).toBe(
|
2026-01-08 02:44:09 +00:00
|
|
|
path.join("/custom/state", "credentials", "oauth.json"),
|
2026-01-04 19:08:13 +01:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|