



























@@ -0,0 +1,65 @@
1+import { spawnSync } from "node:child_process";
2+import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
3+import path from "node:path";
4+import { describe, expect, it } from "vitest";
5+import { createScriptTestHarness } from "./test-helpers.ts";
6+7+const SCRIPT = "scripts/claude-auth-status.sh";
8+9+describe("claude-auth-status.sh", () => {
10+const harness = createScriptTestHarness();
11+12+it("prints expiry timestamps on macOS without GNU date", () => {
13+const root = harness.createTempDir("openclaw-claude-auth-status-");
14+const bin = path.join(root, "bin");
15+mkdirSync(bin, { recursive: true });
16+const openclaw = path.join(bin, "openclaw");
17+const futureMs = String(Date.now() + 2 * 60 * 60 * 1000);
18+19+writeFileSync(
20+openclaw,
21+[
22+"#!/usr/bin/env bash",
23+"set -euo pipefail",
24+'if [ "$*" = "models status --json" ]; then',
25+"cat <<'JSON'",
26+JSON.stringify({
27+auth: {
28+oauth: {
29+profiles: [
30+{
31+provider: "anthropic",
32+type: "oauth",
33+profileId: "anthropic:test",
34+expiresAt: Number(futureMs),
35+},
36+],
37+},
38+providers: [{ provider: "anthropic", profiles: { apiKey: 0 } }],
39+},
40+}),
41+"JSON",
42+"else",
43+"exit 2",
44+"fi",
45+"",
46+].join("\n"),
47+);
48+chmodSync(openclaw, 0o755);
49+50+const result = spawnSync("bash", [SCRIPT, "full"], {
51+cwd: process.cwd(),
52+encoding: "utf8",
53+env: {
54+ ...process.env,
55+HOME: root,
56+PATH: `${bin}:${process.env.PATH ?? ""}`,
57+},
58+});
59+60+expect(result.status).toBe(0);
61+expect(result.stderr).not.toContain("date:");
62+expect(result.stdout).toContain("Claude Code Auth Status");
63+expect(result.stdout.match(/Expires:/g)).toHaveLength(2);
64+});
65+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。