test(FN-4981): complete Step 2 — add push missing-apiKey coverage
Fusion-Task-Id: FN-4981 Fusion-Task-Lineage: 0b3fae6a-a86b-44d5-94e8-4c94429d4767
This commit is contained in:
committed by
gsxdsm
parent
13e5775e17
commit
47775e9428
@@ -15,6 +15,7 @@ import {
|
||||
import { createServer } from "../server.js";
|
||||
import { request } from "../test-request.js";
|
||||
import * as helpers from "../routes/register-settings-sync-helpers.js";
|
||||
import { MISSING_REMOTE_NODE_API_KEY_MESSAGE } from "../routes/register-settings-sync-helpers.js";
|
||||
import * as core from "@fusion/core";
|
||||
|
||||
vi.mock("../routes/register-settings-sync-helpers.js", async () => {
|
||||
@@ -103,6 +104,21 @@ describe("routes secrets sync", () => {
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["undefined", undefined],
|
||||
["empty string", ""],
|
||||
["null", null],
|
||||
])("POST /api/nodes/:id/secrets/push 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/push", 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" });
|
||||
|
||||
Reference in New Issue
Block a user