Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

test(e2e): drop legacy webhook cases ported to the Go suite

varonix71fdaf3af307
diff --git a/backend/e2e-test/routes/v1/access-approval-global-request-routing.spec.ts b/backend/e2e-test/routes/v1/access-approval-global-request-routing.spec.ts
index e9e205759b..d64750c06f 100644
--- a/backend/e2e-test/routes/v1/access-approval-global-request-routing.spec.ts
+++ b/backend/e2e-test/routes/v1/access-approval-global-request-routing.spec.ts
@@ -1,5 +1,3 @@
-import { createFakeWebhookServer } from "e2e-test/fakes/webhook-destination";
-import { createWebhook } from "e2e-test/testUtils/webhooks";
import { Knex } from "knex";
import { TableName } from "@app/db/schemas";
@@ -199,52 +197,4 @@ describe("Access approval request routing", () => {
const grants = await db(TableName.ApprovalRequestGrants).where({ requestId });
expect(grants).toHaveLength(0);
});
-
- test("Creating a request on the global system sends the access request webhook", async () => {
- const secretPath = "/routing-global-webhook";
- const fakeWebhookServer = await createFakeWebhookServer();
- const webhook = await createWebhook({
- projectId: seedData1.project.id,
- environmentSlug: seedData1.environment.slug,
- webhookUrl: fakeWebhookServer.url,
- authToken: jwtAuthToken
- });
-
- try {
- const createRes = await createGlobalPolicy({ name: "routing-global-webhook", secretPath });
- expect(createRes.statusCode).toBe(200);
- const policyId = createRes.json().approval.id as string;
-
- const res = await createAccessRequest(secretPath);
- expect(res.statusCode).toBe(200);
- const { approval } = res.json();
-
- const message = await fakeWebhookServer.waitForMessage(
- (m) => (m.body as { request?: { id?: string } })?.request?.id === approval.id,
- 10_000
- );
- expect(message.body).toMatchObject({
- event: "secrets.access-request.modified",
- action: "created",
- project: { id: seedData1.project.id },
- request: {
- id: approval.id,
- status: "pending",
- isBypassed: false,
- policy: { id: policyId, name: "routing-global-webhook", hasSequencedApprovers: false },
- requestedAccess: {
- target: { environment: { slug: seedData1.environment.slug }, secretPath },
- isTemporary: false,
- permissions: [{ subject: "secrets", actions: ["read"] }]
- },
- requestedBy: { type: "user", id: seedData1.id },
- approvedAt: null,
- revokedAt: null
- }
- });
- } finally {
- await getDb()(TableName.Webhook).where({ id: webhook.id }).del();
- await fakeWebhookServer.stop();
- }
- }, 30_000);
});
diff --git a/backend/e2e-test/routes/v1/webhook.spec.ts b/backend/e2e-test/routes/v1/webhook.spec.ts
deleted file mode 100644
index 584bbe458e..0000000000
--- a/backend/e2e-test/routes/v1/webhook.spec.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { createFakeWebhookServer, TFakeWebhookServer } from "e2e-test/fakes/webhook-destination";
-import { createIsolatedOrgAndProject } from "e2e-test/testUtils/fixtures";
-import { createWebhook } from "e2e-test/testUtils/webhooks";
-
-const ENV = "dev";
-
-const SANITIZED_WEBHOOK_KEYS = [
- "createdAt",
- "envId",
- "environment",
- "eventsFilter",
- "id",
- "isDisabled",
- "lastRunErrorMessage",
- "lastStatus",
- "projectId",
- "secretPath",
- "type",
- "updatedAt"
-];
-
-describe("Webhook router", () => {
- let projectId: string;
- let authToken: string;
- let cleanup: () => Promise<void>;
- let fakeWebhookServer: TFakeWebhookServer;
-
- beforeAll(async () => {
- ({ projectId, authToken, cleanup } = await createIsolatedOrgAndProject("webhook-router-e2e"));
- fakeWebhookServer = await createFakeWebhookServer();
- });
-
- afterAll(async () => {
- await fakeWebhookServer.stop();
- await cleanup();
- });
-
- test("DELETE returns only the sanitized webhook fields", async () => {
- const webhook = await createWebhook({
- projectId,
- environmentSlug: ENV,
- webhookUrl: fakeWebhookServer.url,
- authToken
- });
-
- const res = await testServer.inject({
- method: "DELETE",
- url: `/api/v1/webhooks/${webhook.id}`,
- headers: { authorization: `Bearer ${authToken}` }
- });
-
- expect(res.statusCode).toBe(200);
- const deleted = res.json().webhook as Record<string, unknown>;
- // An exact key match, so a future encrypted column cannot leak through this route unnoticed.
- expect(Object.keys(deleted).sort()).toEqual(SANITIZED_WEBHOOK_KEYS);
- expect(deleted.id).toBe(webhook.id);
- });
-});
diff --git a/backend/e2e-test/routes/v3/secrets-management.spec.ts b/backend/e2e-test/routes/v3/secrets-management.spec.ts
deleted file mode 100644
index 949e749fa7..0000000000
--- a/backend/e2e-test/routes/v3/secrets-management.spec.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { createFakeWebhookServer, TFakeWebhookServer } from "e2e-test/fakes/webhook-destination";
-import { createIsolatedOrgAndProject } from "e2e-test/testUtils/fixtures";
-import { createSecretV2 } from "e2e-test/testUtils/secrets";
-import { createWebhook, waitForWebhookRun } from "e2e-test/testUtils/webhooks";
-
-const ENV = "dev";
-
-// Covers domain-level side effects of secrets management actions, as distinct from the routes'
-// own CRUD behavior (secrets.spec.ts / tests/suites/secretmanager/secrets). A webhook is the observable signal
-// used here, but the thing under test is that the domain action fires the event, not webhook
-// delivery mechanics.
-describe("Secrets management", () => {
- // A webhook run is a queue round trip (1s debounce delay + the HTTP attempt), so it takes longer
- // than the 5s default.
- vi.setConfig({ testTimeout: 30_000, hookTimeout: 30_000 });
-
- let projectId: string;
- let authToken: string;
- let cleanup: () => Promise<void>;
-
- beforeAll(async () => {
- ({ projectId, authToken, cleanup } = await createIsolatedOrgAndProject("secrets-management-e2e"));
- });
-
- afterAll(async () => {
- await cleanup();
- });
-
- describe("Secret changes trigger webhook events", () => {
- let fakeWebhookServer: TFakeWebhookServer;
-
- beforeAll(async () => {
- fakeWebhookServer = await createFakeWebhookServer();
- });
-
- afterAll(async () => {
- await fakeWebhookServer.stop();
- });
-
- test("a secret change enqueues and runs a webhook delivery", async () => {
- const webhook = await createWebhook({
- projectId,
- environmentSlug: ENV,
- webhookUrl: fakeWebhookServer.url,
- authToken
- });
- expect(webhook.lastStatus).toBeNull();
-
- await createSecretV2({
- workspaceId: projectId,
- environmentSlug: ENV,
- secretPath: "/",
- key: "WEBHOOK_TRIGGER_TEST",
- value: "value",
- authToken
- });
-
- // The fake is shared by every test in this file, so messages from other tests can arrive
- // interleaved; matching on this test's own project is what makes waitForMessage return the
- // right one instead of racing whichever test's delivery happens to land first.
- const message = await fakeWebhookServer.waitForMessage(
- (m) => (m.body as { event?: string; project?: { workspaceId?: string } })?.project?.workspaceId === projectId
- );
- expect(message.method).toBe("POST");
- expect(message.body).toMatchObject({ event: "secrets.modified" });
-
- // lastStatus is only ever written by fnTriggerWebhook, which only runs inside the
- // SecretWebhook queue worker (secret-queue.ts). Confirming it lands on "success" is proof
- // the whole pipeline, not just delivery, completed.
- const ranWebhook = await waitForWebhookRun({ webhookId: webhook.id, authToken });
- expect(ranWebhook.lastStatus).toBe("success");
- });
- });
-});
diff --git a/backend/e2e-test/testUtils/webhooks.ts b/backend/e2e-test/testUtils/webhooks.ts
deleted file mode 100644
index b17ea5ad88..0000000000
--- a/backend/e2e-test/testUtils/webhooks.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-type TWebhook = {
- id: string;
- lastStatus: string | null;
- lastRunErrorMessage: string | null;
-};
-
-export const createWebhook = async (dto: {
- projectId: string;
- environmentSlug: string;
- secretPath?: string;
- webhookUrl: string;
- authToken: string;
-}) => {
- const res = await testServer.inject({
- method: "POST",
- url: "/api/v1/webhooks",
- headers: { authorization: `Bearer ${dto.authToken}` },
- body: {
- projectId: dto.projectId,
- environment: dto.environmentSlug,
- webhookUrl: dto.webhookUrl,
- secretPath: dto.secretPath ?? "/"
- }
- });
- expect(res.statusCode).toBe(200);
- return res.json().webhook as TWebhook;
-};
-
-export const getWebhook = async (dto: { webhookId: string; authToken: string }) => {
- const res = await testServer.inject({
- method: "GET",
- url: `/api/v1/webhooks/${dto.webhookId}`,
- headers: { authorization: `Bearer ${dto.authToken}` }
- });
- expect(res.statusCode).toBe(200);
- return res.json().webhook as TWebhook;
-};
-
-const POLL_TIMEOUT_MS = 3_000;
-const POLL_INTERVAL_MS = 100;
-
-// The webhook trigger job runs with a 1s debounce delay plus whatever the receiver takes to
-// respond, so lastStatus flips some time after the secret write that queued it, not immediately.
-export const waitForWebhookRun = async (dto: { webhookId: string; authToken: string }) => {
- const deadline = Date.now() + POLL_TIMEOUT_MS;
-
- for (;;) {
- // eslint-disable-next-line no-await-in-loop
- const webhook = await getWebhook(dto);
- if (webhook.lastStatus !== null) return webhook;
-
- if (Date.now() >= deadline) {
- throw new Error(`Timed out after ${POLL_TIMEOUT_MS}ms waiting for webhook "${dto.webhookId}" to run`);
- }
-
- // eslint-disable-next-line no-await-in-loop
- await new Promise((resolve) => {
- setTimeout(resolve, POLL_INTERVAL_MS);
- });
- }
-};