功能修改
This commit is contained in:
@@ -9,7 +9,7 @@ const provider: AiProviderResponse = {
|
||||
id: "ai.openai",
|
||||
name: "OpenAI",
|
||||
kind: "openai",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
baseUrlConfigured: true,
|
||||
apiKeyConfigured: true,
|
||||
models: ["gpt-4.1"],
|
||||
defaultModel: "gpt-4.1",
|
||||
@@ -35,6 +35,7 @@ const plugin: GamePluginResponse = {
|
||||
pages: [{ key: "logs", title: "Logs", path: "/logs", permissions: ["server.logs.read"], bridgeActions: ["logs.query"] }],
|
||||
tags: ["example"],
|
||||
aiPurposes: ["logs.diagnose"],
|
||||
productionLifecycle: { operations: ["install", "enable", "disable", "upgrade", "rollback", "retire", "dependency-check"], dependencyPolicy: "optional", approvalRequired: ["disable", "rollback", "retire"] },
|
||||
runtimeProfiles: { lifecycleProfiles: [{ key: "local", mode: "local-process", capabilities: ["process.install", "process.start", "process.stop"] }] },
|
||||
status: "installed"
|
||||
};
|
||||
@@ -57,6 +58,7 @@ const marketplacePlugin: MarketplacePluginResponse = {
|
||||
pages: [{ key: "logs", title: "Logs", path: "/logs", permissions: ["server.logs.read"], bridgeActions: ["logs.query"] }],
|
||||
tags: ["example"],
|
||||
aiPurposes: ["logs.diagnose"],
|
||||
productionLifecycle: { operations: ["install", "enable", "disable", "upgrade", "rollback", "retire", "dependency-check"], dependencyPolicy: "optional", approvalRequired: ["disable", "rollback", "retire"] },
|
||||
status: "installed",
|
||||
source: "platform-registry"
|
||||
};
|
||||
@@ -181,7 +183,7 @@ describe("PlatformApiClient AI providers", () => {
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
kind: provider.kind,
|
||||
baseUrl: provider.baseUrl,
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
apiKeyRef: "secret://providers/openai",
|
||||
models: provider.models,
|
||||
defaultModel: provider.defaultModel,
|
||||
@@ -725,11 +727,13 @@ describe("PlatformApiClient AI providers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps raw key fields out of provider responses", () => {
|
||||
it("keeps raw key and base URL fields out of provider responses", () => {
|
||||
expect("apiKey" in provider).toBe(false);
|
||||
expect("rawApiKey" in provider).toBe(false);
|
||||
expect(provider.apiKeyConfigured).toBe(true);
|
||||
expect("apiKeyRef" in provider).toBe(false);
|
||||
expect("baseUrl" in provider).toBe(false);
|
||||
expect(provider.baseUrlConfigured).toBe(true);
|
||||
});
|
||||
|
||||
it("calls auth endpoints and attaches bearer sessions", async () => {
|
||||
@@ -804,6 +808,24 @@ describe("PlatformApiClient AI providers", () => {
|
||||
});
|
||||
expect(onAuthFailure).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("surfaces allow-listed plugin capability denials", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({
|
||||
code: "forbidden",
|
||||
message: "plugin does not declare required permission: server.run.distribution"
|
||||
}), { status: 403, headers: { "Content-Type": "application/json" } })));
|
||||
|
||||
const client = new PlatformApiClient("/api/v1", () => "admin-session");
|
||||
await expect(client.generateRunDistribution("server-local-debug", {
|
||||
targetOs: "linux",
|
||||
targetArch: "amd64",
|
||||
idempotencyKey: "test"
|
||||
})).rejects.toMatchObject({
|
||||
status: 403,
|
||||
code: "forbidden",
|
||||
message: "插件未声明所需权限:server.run.distribution"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function jsonResponse(body: unknown): Response {
|
||||
|
||||
Reference in New Issue
Block a user