refactor: align provider and task contracts
This commit is contained in:
@@ -119,7 +119,7 @@ test("admin RBAC rejects finance access and redacts support channel internals",
|
||||
const { store, server, base } = await start("support");
|
||||
try {
|
||||
store.channels[0].providerName = "internal-provider";
|
||||
store.channels[0].providerModelId = "internal-model";
|
||||
store.channels[0].models[0].requestModelId = "internal-model";
|
||||
store.channels[0].baseUrl = "https://provider.example.com";
|
||||
const login = await fetch(`${base}/api/v1/admin/auth/login`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ email: "admin@example.com", password: "change-me-now" }) });
|
||||
const loginPayload = await login.json() as { data: { accessToken: string } };
|
||||
@@ -165,12 +165,12 @@ test("OpenAI image channel creation does not probe implicitly and explicit probi
|
||||
return previousFetch(input, init);
|
||||
};
|
||||
const auth = { authorization: `Bearer ${loginPayload.data.accessToken}`, "content-type": "application/json" };
|
||||
const created = await fetch(`${base}/api/v1/admin/channels`, { method: "POST", headers: { ...auth, "idempotency-key": "openai-channel-create" }, body: JSON.stringify({ label: "OpenAI 图片渠道", providerType: "openai-images", providerModelId: "gpt-image-2", baseUrl: "https://1.1.1.1/v1", secretRef: "k", resolutionModelMap: { "1K": "gpt-image-2", "2K": "gpt-image-2-2k", invalid: "should-drop" } }) });
|
||||
const created = await fetch(`${base}/api/v1/admin/channels`, { method: "POST", headers: { ...auth, "idempotency-key": "openai-channel-create" }, body: JSON.stringify({ label: "OpenAI 图片渠道", providerType: "openai-images", models: [{ requestModelId: "gpt-image-2", source: "manual", enabled: true }, { requestModelId: "gpt-image-2-2k", source: "manual", enabled: true }], baseUrl: "https://1.1.1.1/v1", secretRef: "k" }) });
|
||||
assert.equal(created.status, 201);
|
||||
const createdPayload = await created.json() as { data: { item: Record<string, unknown> } };
|
||||
assert.equal(createdPayload.data.item.secretRef, "configured");
|
||||
assert.equal(createdPayload.data.item.baseUrl, "https://1.1.1.1/v1");
|
||||
assert.deepEqual(createdPayload.data.item.resolutionModelMap, { "1K": "gpt-image-2", "2K": "gpt-image-2-2k" });
|
||||
assert.deepEqual(createdPayload.data.item.models, [{ requestModelId: "gpt-image-2", source: "manual", enabled: true }, { requestModelId: "gpt-image-2-2k", source: "manual", enabled: true }]);
|
||||
const channel = store.channels.find((item) => item.id === createdPayload.data.item.id);
|
||||
assert.ok(channel);
|
||||
assert.notEqual(channel.secretRef, "k");
|
||||
@@ -182,7 +182,7 @@ test("OpenAI image channel creation does not probe implicitly and explicit probi
|
||||
assert.equal(probeRequests[0]?.method, "GET");
|
||||
assert.equal(probeRequests[0]?.authorization, "Bearer k");
|
||||
|
||||
const invalid = await fetch(`${base}/api/v1/admin/channels`, { method: "POST", headers: { ...auth, "idempotency-key": "openai-channel-http" }, body: JSON.stringify({ label: "不安全渠道", providerType: "openai-images", providerModelId: "gpt-image-2", baseUrl: "http://1.1.1.1/v1", secretRef: "1234567890123456" }) });
|
||||
const invalid = await fetch(`${base}/api/v1/admin/channels`, { method: "POST", headers: { ...auth, "idempotency-key": "openai-channel-http" }, body: JSON.stringify({ label: "不安全渠道", providerType: "openai-images", models: [{ requestModelId: "gpt-image-2", source: "manual", enabled: true }], baseUrl: "http://1.1.1.1/v1", secretRef: "1234567890123456" }) });
|
||||
assert.equal(invalid.status, 201);
|
||||
assert.equal(store.channels.some((item) => item.label === "不安全渠道"), true);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user