feat: add secure WP7-02 external executor
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 48s
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 48s
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
buildControlledExecutionPlan,
|
||||
buildProviderRequest,
|
||||
buildSanitizedResponseEvidence,
|
||||
executeProviderRequest,
|
||||
normalizeProviderResponse,
|
||||
validateSanitizedEvidence,
|
||||
} from "../../scripts/lib/wp7-02-controlled-executor.mjs";
|
||||
@@ -107,3 +108,33 @@ test("TDD-WP7-EXT-001 rejects sensitive or shared evidence fields", () => {
|
||||
}
|
||||
assert.throws(() => validateSanitizedEvidence({ status: "passed", verified: true }), /WP7_02_SHARED_VERIFIED_FORBIDDEN/);
|
||||
});
|
||||
|
||||
test("TDD-WP7-EXT-001 confines the credential to the request header and discards provider error bodies", async () => {
|
||||
const credentialMarker = "controlled-secret-value-for-test-only";
|
||||
const success = await executeProviderRequest({
|
||||
fetchImpl: async (_url, init) => {
|
||||
assert.equal(init.headers.authorization, `Bearer ${credentialMarker}`);
|
||||
return new Response(JSON.stringify({
|
||||
candidates: [{ content: { parts: [{ inlineData: { data: onePixelPng.toString("base64"), mimeType: "image/png" } }] } }],
|
||||
}), { headers: { "content-type": "application/json" }, status: 200 });
|
||||
},
|
||||
modelConfig: models[0],
|
||||
prompt: "controlled fixture prompt",
|
||||
ratio: "1:1",
|
||||
token: credentialMarker,
|
||||
});
|
||||
assert.equal(success.http_status, 200);
|
||||
assert.doesNotMatch(JSON.stringify({ ...success, normalized: undefined }), new RegExp(credentialMarker));
|
||||
|
||||
await assert.rejects(() => executeProviderRequest({
|
||||
fetchImpl: async () => new Response(JSON.stringify({ provider_body: credentialMarker }), { status: 502 }),
|
||||
modelConfig: models[0],
|
||||
prompt: "controlled fixture prompt",
|
||||
ratio: "1:1",
|
||||
token: credentialMarker,
|
||||
}), (error) => {
|
||||
assert.equal(error.message, "WP7_02_UPSTREAM_HTTP_502");
|
||||
assert.doesNotMatch(error.message, new RegExp(credentialMarker));
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user