Clarify Hose elevation flag

This commit is contained in:
gitea committed 2026-09-22 13:46:16 +08:00
1 parent 4321814261
commit 941a1597c0
6 files changed
+38 -21

No files matched your search

+19 -7
View File
@@ -171,14 +171,14 @@ describe("corps link onboarding", () => {
expect(readDirectory(enterprises)).toEqual([]);
});
test("rejects --as-hose when passed with a Seal native delegate link", async () => {
test("rejects --elevate-hose when passed with a Seal native delegate link", async () => {
mockSealLinkRequests();
const link = "https://acme-01.sealai.cc/delegate?token=del-tok";
const result = await runCli(["corps", "add-link", link, "--as-hose"]);
const result = await runCli(["corps", "add-link", link, "--elevate-hose"]);
expect(result.isError).toBe(true);
expect(result.stderr).toContain("Option --as-hose cannot be used with a Seal native delegate link");
expect(result.stderr).toContain("Option --elevate-hose cannot be used with a Seal native delegate link");
});
test("rejects a link when Seal identity does not match ekbCorpId", async () => {
@@ -744,12 +744,12 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(config.source.staffId).toBe("acme-01:admin01");
});
test("corps add-link --as-hose automatically registers as Hose OpenAPI configuration", async () => {
test("corps add-link --elevate-hose automatically registers as Hose OpenAPI configuration", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const link = hoseLink();
const result = await runCli(["corps", "add-link", link, "--as-hose", "--name", "Acme Auto Hose", "--force"]);
const result = await runCli(["corps", "add-link", link, "--elevate-hose", "--name", "Acme Auto Hose", "--force"]);
expect(result.isError).toBe(false);
expect(result.exitCode).toBe(0);
@@ -763,11 +763,11 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(config.source.appSecurity).toBe("sec_secret_password_456789");
});
test("corps add-link --as-hose --dry-run does not save a Hose configuration", async () => {
test("corps add-link --elevate-hose --dry-run does not save a Hose configuration", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const result = await runCli(["corps", "add-link", hoseLink(), "--as-hose", "--dry-run"]);
const result = await runCli(["corps", "add-link", hoseLink(), "--elevate-hose", "--dry-run"]);
expect(result.isError).toBe(false);
const parsed = JSON.parse(result.stdout);
@@ -783,6 +783,18 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
expect(readDirectory(enterprises)).toEqual([]);
});
test("corps add-link keeps --as-hose as a deprecated compatibility alias", async () => {
const enterprises = setupConfigEnv();
mockHoseKeysRequests();
const result = await runCli(["corps", "add-link", hoseLink(), "--as-hose", "--force"]);
expect(result.isError).toBe(false);
expect(result.exitCode).toBe(0);
expect(result.stderr).toContain("'--as-hose' is deprecated");
expect(existsSync(join(enterprises, "acme-01.json"))).toBe(true);
});
test("auth extract-keys alias works before any enterprise is configured", async () => {
setupConfigEnv();
mockHoseKeysRequests();
+10 -5
View File
@@ -1045,17 +1045,22 @@ export async function handleCorpsCommand(action: string | undefined, maybeName:
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
if (!link) {
throw new Error(
"Usage: seal-use corps add-link <url> [--name <customName>] [--as-hose] [--overwrite]"
"Usage: seal-use corps add-link <url> [--name <customName>] [--elevate-hose] [--overwrite]"
);
}
const dryRun = booleanOption(args.options["dry-run"]) === true || booleanOption(args.options.dryRun) === true;
const asHose = booleanOption(args.options["as-hose"]) === true || booleanOption(args.options.hose) === true;
if (asHose) {
const legacyAsHose =
booleanOption(args.options["as-hose"]) === true || booleanOption(args.options.hose) === true;
const elevateHose = booleanOption(args.options["elevate-hose"]) === true || legacyAsHose;
if (legacyAsHose && !booleanOption(args.options["elevate-hose"])) {
console.error("⚠️ Notice: '--as-hose' is deprecated; use '--elevate-hose' to request Hose credential elevation.");
}
if (elevateHose) {
const scores = scoreAssistLink(link);
const winner = scores[0];
if (winner?.kind === "seal-delegate") {
throw new Error(
"Option --as-hose cannot be used with a Seal native delegate link. Seal delegate links directly authenticate to Seal."
"Option --elevate-hose cannot be used with a Seal native delegate link. Seal delegate links directly authenticate to Seal."
);
}
await addLinkAsHoseCorp(
@@ -1735,7 +1740,7 @@ async function addLinkAsHoseCorp(
result.keys,
result.corpId,
selection ?? {},
`seal-use corps add-link "<url>" --as-hose`
`seal-use corps add-link "<url>" --elevate-hose`
);
console.error(
dryRun