feat(auth): support OpenAPI persistent credentials, auto-refresh, and Web login link generation (v0.8.10)

This commit is contained in:
gitea committed 2026-09-28 16:50:18 +08:00
1 parent 1d825269f4
commit 96c5a3f242
27 files changed
+2994 -583

No files matched your search

+48
View File
@@ -315,4 +315,52 @@ describe("cli/commands/corps > handleCorpsCommand search & aliases", () => {
expect(res.stdout).toContain("search <关键词>");
expect(res.stdout).toContain("find");
});
it("generates login link via corps link [corp] with preserveSensitiveStdout=true", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = (async () =>
new Response(JSON.stringify({ items: [] }), {
status: 200,
headers: { "content-type": "application/json" },
})) as unknown as typeof fetch;
try {
const res = await handleCorpsCommand(
{
area: "corps",
action: "link",
args: ["corpAlpha"],
options: {},
raw: ["corps", "link", "corpAlpha"],
},
searchRuntime
);
expect(res.exitCode).toBe(0);
expect(res.preserveSensitiveStdout).toBe(true);
expect(res.stdout).toContain("thirdparty.html?accessToken=token-alpha&ekbCorpId=alphaPhysicalId");
} finally {
globalThis.fetch = originalFetch;
}
});
it("supports corps add-persistent --dry-run", async () => {
const res = await handleCorpsCommand(
{
area: "corps",
action: "add-persistent",
args: [],
options: {
"app-key": "key-1",
"app-security": "sec-1",
"dry-run": true,
},
raw: ["corps", "add-persistent", "--app-key=key-1", "--app-security=sec-1", "--dry-run"],
},
searchRuntime
);
expect(res.exitCode).toBe(0);
expect(res.stdout).toContain("通过 OpenAPI 持久化密钥接入企业");
});
});