Files
modelstudioai__cli/packages/cli/tests/e2e/token-plan.e2e.test.ts
T
若麒 2debfdba6b feat(auth): add OpenAPI AK/SK auth domain for token plan
- add openapi auth requirement with command-scoped access key flags and paired credential resolution
- persist OpenAPI credentials through auth login/status/logout using access_key_* config fields
- route token-plan commands through the centralized ACS signing client
- keep legacy openapi_access_key_* config readable while rejecting it as a new config set key
- refresh docs, generated references, telemetry authMethod, and e2e coverage
2026-07-09 15:03:48 +08:00

50 lines
2.1 KiB
TypeScript

import { describe, expect, test } from "vite-plus/test";
import { makeE2eOutputDir, parseStdoutJson, runCli } from "./helpers.ts";
describe("e2e: token-plan", () => {
test("token-plan help shows centralized OpenAPI auth flags", async () => {
const { stderr, exitCode } = await runCli(["token-plan", "list-seats", "--help"]);
expect(exitCode, stderr).toBe(0);
expect(stderr).toMatch(/--access-key-id/);
expect(stderr).toMatch(/--access-key-secret/);
});
test("token-plan dry-run does not require OpenAPI AK/SK", async () => {
const { stdout, stderr, exitCode } = await runCli(
["token-plan", "list-seats", "--dry-run", "--output", "json"],
{
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
},
);
expect(exitCode, stderr).toBe(0);
const data = parseStdoutJson<{ endpoint?: string; query?: Record<string, unknown> }>(stdout);
expect(data.endpoint).toContain("/tokenplan/subscription/seat-detail");
expect(data.query).toBeDefined();
});
test("token-plan non-dry-run requires OpenAPI AK/SK", async () => {
const configDir = makeE2eOutputDir("token-plan-missing-openapi");
const { stderr, exitCode } = await runCli(["token-plan", "list-seats"], {
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
});
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/OpenAPI AK\/SK|access-key-id|ALIBABA_CLOUD_ACCESS_KEY_ID/);
});
test("token-plan partial OpenAPI env reports AK/SK hint without API key onboarding", async () => {
const configDir = makeE2eOutputDir("token-plan-partial-openapi-env");
const { stderr, exitCode } = await runCli(["token-plan", "list-seats"], {
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "ak-e2e-placeholder",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
});
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/Incomplete OpenAPI AK\/SK/);
expect(stderr).toMatch(/ALIBABA_CLOUD_ACCESS_KEY_ID/);
expect(stderr).not.toMatch(/auth login --api-key/);
});
});