31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { resumeService } from "../src/services/product-service-clients.js";
|
|
|
|
const originalFetch = globalThis.fetch;
|
|
const requests: Array<{ url: string; headers: Headers; body: string }> = [];
|
|
|
|
globalThis.fetch = async (input, init) => {
|
|
const request = new Request(input, init);
|
|
requests.push({
|
|
url: request.url,
|
|
headers: request.headers,
|
|
body: await request.text(),
|
|
});
|
|
return new Response("{}", { status: 200, headers: { "content-type": "application/json" } });
|
|
};
|
|
|
|
try {
|
|
await resumeService.state("user_canonical");
|
|
await resumeService.listResumes("user_canonical");
|
|
await resumeService.createResume({ user_id: "user_from_payload" }, "user_canonical");
|
|
|
|
assert.equal(requests.length, 3);
|
|
for (const request of requests) {
|
|
assert.equal(request.headers.get("x-growqr-user"), "user_canonical");
|
|
assert.match(request.headers.get("authorization") ?? "", /^Bearer /);
|
|
}
|
|
console.log("resume user identity forwarding: all assertions passed");
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|