fix: proxy provider profile management routes

This commit is contained in:
Codex Agent
2026-06-05 17:43:48 +08:00
parent 210d7b6a7d
commit a0f76f5a3d
3 changed files with 105 additions and 0 deletions
@@ -125,6 +125,80 @@ test("cloud web proxies Admin Access write routes", async () => {
}
});
test("cloud web proxies provider profile management write routes", async () => {
const upstreamRequests = [];
const upstream = createServer(async (request, response) => {
let body = "";
for await (const chunk of request) body += chunk;
upstreamRequests.push({
method: request.method,
url: request.url,
authorization: request.headers.authorization,
body
});
response.writeHead(200, { "content-type": "application/json" });
response.end(JSON.stringify({ ok: true, path: request.url }));
});
await listen(upstream);
const cloudWeb = createCloudWebServer({
serviceId: "hwlab-cloud-web",
cloudApiBaseUrl: serverUrl(upstream),
cloudApiProxyTimeoutMs: 1000,
healthPayload: () => ({ status: "ok" }),
roots: [],
sendJson(response, statusCode, body) {
const payload = JSON.stringify(body);
response.writeHead(statusCode, {
"content-type": "application/json",
"content-length": Buffer.byteLength(payload)
});
response.end(payload);
}
});
await listen(cloudWeb);
try {
const credentialBody = JSON.stringify({ apiKey: "sk-test-redacted" });
const credentialResponse = await fetch(`${serverUrl(cloudWeb)}/v1/admin/provider-profiles/deepseek/credential`, {
method: "PUT",
headers: {
"content-type": "application/json",
authorization: "Bearer hwl_live_admin"
},
body: credentialBody
});
assert.equal(credentialResponse.status, 200);
const validateResponse = await fetch(`${serverUrl(cloudWeb)}/v1/admin/provider-profiles/deepseek/validate`, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: "Bearer hwl_live_admin"
},
body: "{}"
});
assert.equal(validateResponse.status, 200);
assert.equal(upstreamRequests.length, 2);
assert.deepEqual(upstreamRequests[0], {
method: "PUT",
url: "/v1/admin/provider-profiles/deepseek/credential",
authorization: "Bearer hwl_live_admin",
body: credentialBody
});
assert.deepEqual(upstreamRequests[1], {
method: "POST",
url: "/v1/admin/provider-profiles/deepseek/validate",
authorization: "Bearer hwl_live_admin",
body: "{}"
});
} finally {
await close(cloudWeb);
await close(upstream);
}
});
test("cloud web forwards hwpod node-ops plans to cloud-api", async () => {
const upstreamRequests = [];
const upstream = createServer(async (request, response) => {