fix(oauth): derive oauth.json from state dir

This commit is contained in:
Peter Steinberger
2026-01-04 19:08:13 +01:00
parent 3300fba57c
commit e005dcb8e7
5 changed files with 115 additions and 9 deletions

30
src/config/paths.test.ts Normal file
View File

@@ -0,0 +1,30 @@
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;
expect(resolveOAuthDir(env, "/custom/state")).toBe("/custom/oauth");
expect(resolveOAuthPath(env, "/custom/state")).toBe(
"/custom/oauth/oauth.json",
);
});
it("derives oauth path from CLAWDBOT_STATE_DIR when unset", () => {
const env = {
CLAWDBOT_STATE_DIR: "/custom/state",
} as NodeJS.ProcessEnv;
expect(resolveOAuthDir(env, "/custom/state")).toBe(
"/custom/state/credentials",
);
expect(resolveOAuthPath(env, "/custom/state")).toBe(
"/custom/state/credentials/oauth.json",
);
});
});