test(FN-4981): complete Step 3 — add pull missing-apiKey coverage

Fusion-Task-Id: FN-4981
Fusion-Task-Lineage: 0b3fae6a-a86b-44d5-94e8-4c94429d4767
This commit is contained in:
Fusion (runfusion.ai)
2026-05-18 04:15:40 -07:00
committed by gsxdsm
parent 47775e9428
commit 765a6fed0a

View File

@@ -119,6 +119,21 @@ describe("routes secrets sync", () => {
expect(/(forbidden-pass|forbidden-value|"salt"\s*:|"nonce"\s*:|"ciphertext"\s*:)/.test(JSON.stringify(res.body))).toBe(false);
});
it.each([
["undefined", undefined],
["empty string", ""],
["null", null],
])("POST /api/nodes/:id/secrets/pull rejects missing remote apiKey (%s)", async (_shape, apiKey) => {
vi.spyOn(CentralCore.prototype, "getNode").mockResolvedValue({ ...remoteNode, url: "http://remote.test", apiKey: apiKey as string } as any);
const res = await request(fixture.app, "POST", "/api/nodes/node-remote-001/secrets/pull", JSON.stringify({}), { "content-type": "application/json" });
expect(res.status).toBe(400);
expect((res.body as any).error).toBe(MISSING_REMOTE_NODE_API_KEY_MESSAGE);
expect(mockedFetchFromRemoteNode).not.toHaveBeenCalled();
expect(/(forbidden-pass|forbidden-value|"salt"\s*:|"nonce"\s*:|"ciphertext"\s*:)/.test(JSON.stringify(res.body))).toBe(false);
});
it("POST /api/nodes/:id/secrets/pull happy path and skip reserved", async () => {
await setSyncPassphrase(secrets, "shared-pass");
await secrets.createSecret({ scope: "project", key: "EXISTING", plaintextValue: "old" });