Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test(e2e): drop legacy rotation cases now covered on postgres in the go suite
varonixbc561c47b395
diff --git a/backend/e2e-test/routes/v2/secret-rotation.spec.ts b/backend/e2e-test/routes/v2/secret-rotation.spec.tsindex 89d60e0227..1547f87ac2 100644--- a/backend/e2e-test/routes/v2/secret-rotation.spec.ts+++ b/backend/e2e-test/routes/v2/secret-rotation.spec.ts@@ -4,21 +4,19 @@ import { createAwsAppConnection, deleteAwsAppConnection } from "e2e-test/testUtiimport { createIsolatedOrgAndProject } from "e2e-test/testUtils/fixtures";import { createFolder } from "e2e-test/testUtils/folders";import {- checkRotationCredentials,createSecretRotation,deleteSecretRotation,- getGeneratedCredentials,getSecretRotation,listSecretRotations,rotateSecretRotation} from "e2e-test/testUtils/secret-rotations";-import { createSecretV2, getSecretsV2, updateSecretV2 } from "e2e-test/testUtils/secrets";+import { getSecretsV2 } from "e2e-test/testUtils/secrets";import { SecretRotationStatus } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";-// What is under test is the rotation plumbing: issuing the first credential, publishing each new-// one into the two mapped secrets, which credential the provider is handed to retire, and what-// survives a failure. The provider is AWS IAM user secrets, faked for the whole run+// What is under test is which credential the provider is handed to retire, and what survives a+// failure after the new credential is published. The rest of the rotation plumbing is covered on+// PostgreSQL by tests/suites/secretmanager/rotations. The provider is AWS IAM user secrets, faked for the whole run// (e2e-test/fakes/aws-iam-user-secret-rotation-fns.ts and the alias block in// vitest.e2e.config.mts), so none of this reaches IAM.//@@ -70,25 +68,15 @@ describe("Secret rotations", async () => {return Object.fromEntries(secrets.map((secret) => [secret.secretKey, secret.secretValue]));};- // Creates a rotation at /services with the standard secret keys. The options are the two things- // tests vary: the keys it publishes to (for the tests about keys already being taken) and the- // status a refused creation is expected to answer with.- const newRotation = async (- name: string,- options: {- secretsMapping?: { accessKeyId: string; secretAccessKey: string };- secretPath?: string;- expectStatusCode?: number;- } = {}- ) =>+ // Creates a rotation at /services with the standard secret keys.+ const newRotation = async (name: string) =>createSecretRotation({name,projectId,connectionId,environmentSlug: ENV,- secretPath: options.secretPath ?? "/services",- secretsMapping: options.secretsMapping ?? SECRET_KEYS,- expectStatusCode: options.expectStatusCode,+ secretPath: "/services",+ secretsMapping: SECRET_KEYS,authToken});@@ -131,20 +119,6 @@ describe("Secret rotations", async () => {await cleanupOrg();});- describe("Creating a rotation issues the first credential and publishes it", () => {- test("The mapped secrets hold the issued credential and the provider has one live key", async () => {- const { secretRotation } = await newRotation("publishes-first-credential");-- expect(await secretsAt("/services")).toEqual(secretsHolding(1));- expect(fakeIamUserSecret.keys()).toEqual(liveKeys(1));- expect(secretRotation!.activeIndex).toBe(0);- expect(secretRotation!.rotationStatus).toBe(SecretRotationStatus.Success);- // Auto rotation is off, so there is nothing for the cron to pick up:- // findSecretRotationsToQueue gates on this being set as well as on isAutoRotationEnabled.- expect(secretRotation!.nextRotationAt).toBeNull();- });- });-// The two provider shapes. Both rotate through the same service call and both are handed the// same two credentials; they differ in which one they retire, so the keys left live are what// show the service handed over the right ones. Getting them the wrong way round would revoke@@ -196,54 +170,9 @@ describe("Secret rotations", async () => {expect(fakeIamUserSecret.keys()).toEqual(liveKeys(2, 3));expect(second.secretRotation!.activeIndex).toBe(0);});-- test("Both credentials are readable, newest in the slot the active index names", async () => {- const { secretRotation } = await newRotation("generated-credentials");- const rotationId = secretRotation!.id;-- await rotateSecretRotation({ rotationId, authToken });- await rotateSecretRotation({ rotationId, authToken });-- expect(await getGeneratedCredentials({ rotationId, authToken })).toEqual({- generatedCredentials: [credential(3), credential(2)],- activeIndex: 0- });- });});- describe("A rotation that cannot issue a credential changes nothing", () => {- test("A provider that refuses the first credential leaves no rotation and no secrets", async () => {- fakeIamUserSecret.failIssueWith("IAM denied CreateAccessKey");-- const { error } = await newRotation("issue-refused", { expectStatusCode: 400 });-- expect(error!.message).toContain("IAM denied CreateAccessKey");- expect(fakeIamUserSecret.keys()).toEqual({});- expect(await secretsAt("/services")).toEqual({});- expect(await listSecretRotations({ projectId, authToken })).toEqual([]);- });-- test("A provider that refuses a later credential leaves the working one published", async () => {- const { secretRotation } = await newRotation("issue-refused-later");- const rotationId = secretRotation!.id;-- fakeIamUserSecret.failIssueWith("IAM throttled CreateAccessKey");-- // A provider failure answers 500 rather than 4xx: rotateSecretRotation wraps whatever- // rotateGeneratedCredentials threw in an InternalServerError.- const { error } = await rotateSecretRotation({ rotationId, authToken, expectStatusCode: 500 });- expect(error!.message).toContain("IAM throttled CreateAccessKey");-- // The credential users hold is untouched, at the provider and in the mapped secrets.- expect(fakeIamUserSecret.keys()).toEqual(liveKeys(1));- expect(await secretsAt("/services")).toEqual(secretsHolding(1));-- const failed = await getSecretRotation({ rotationId, authToken });- expect(failed.rotationStatus).toBe(SecretRotationStatus.Failed);- expect(failed.lastRotationMessage).toContain("IAM throttled CreateAccessKey");- expect(failed.activeIndex).toBe(0);- });-+ describe("A rotation whose provider fails after publishing reports the failure", () => {test("A provider that fails after the new credential is published reports failure on a rotation that happened", async () => {const { secretRotation } = await newRotation("fails-after-publish");const rotationId = secretRotation!.id;@@ -263,129 +192,4 @@ describe("Secret rotations", async () => {expect(failed.rotationStatus).toBe(SecretRotationStatus.Failed);});});-- describe("A rotation is created against one free set of secret keys at one existing secret path", () => {- test("Creating a rotation is refused when the name is already used at the path", async () => {- await newRotation("taken-name");-- const { error } = await newRotation("taken-name", {- // Different keys, so this can only fail on the name.- secretsMapping: { accessKeyId: "OTHER_ACCESS_KEY_ID", secretAccessKey: "OTHER_SECRET_ACCESS_KEY" },- expectStatusCode: 400- });-- expect(error!.message).toContain("taken-name");- expect(error!.message).toContain("/services");- expect(await listSecretRotations({ projectId, authToken })).toHaveLength(1);- });-- test("Creating a rotation is refused when a mapped secret key already exists", async () => {- await createSecretV2({- authToken,- workspaceId: projectId,- environmentSlug: ENV,- secretPath: "/services",- key: "HAND_WRITTEN_KEY",- value: "hand-written-value"- });-- const { error } = await newRotation("taken-key", {- secretsMapping: { accessKeyId: "HAND_WRITTEN_KEY", secretAccessKey: "OTHER_SECRET_ACCESS_KEY" },- expectStatusCode: 400- });-- expect(error!.message).toContain("HAND_WRITTEN_KEY");- // The hand-written secret is still its own, and no credential was issued for a rotation- // that was refused before it reached the provider.- expect(await secretsAt("/services")).toEqual({ HAND_WRITTEN_KEY: "hand-written-value" });- expect(fakeIamUserSecret.keys()).toEqual({});- });-- test("Creating a rotation is refused when the secret path does not exist", async () => {- const { error } = await newRotation("missing-path", { secretPath: "/does/not/exist", expectStatusCode: 400 });-- expect(error!.message).toContain("/does/not/exist");- expect(error!.message).toContain(ENV);- expect(fakeIamUserSecret.keys()).toEqual({});- });- });-- describe("The rotation owns its mapped secrets until it is deleted", () => {- test("A mapped secret cannot be given a value by hand", async () => {- await newRotation("owns-secrets");-- await updateSecretV2({- workspaceId: projectId,- environmentSlug: ENV,- secretPath: "/services",- key: SECRET_KEYS.accessKeyId,- value: "hand-written-value",- authToken- }).expect((res) => {- expect(res.statusCode).toBe(400);- expect(res.json().message).toContain("Cannot update rotated secret");- });- expect(await secretsAt("/services")).toEqual(secretsHolding(1));- });-- test("Deleting a rotation with both flags set revokes the credentials and removes the secrets", async () => {- const { secretRotation } = await newRotation("deletes-everything");- const rotationId = secretRotation!.id;-- await rotateSecretRotation({ rotationId, authToken });-- await deleteSecretRotation({ rotationId, deleteSecrets: true, revokeGeneratedCredentials: true, authToken });-- // Both slots are revoked, not just the published one, so the previous credential cannot- // outlive the rotation that issued it.- expect(fakeIamUserSecret.keys()).toEqual({});- expect(await secretsAt("/services")).toEqual({});- expect(await listSecretRotations({ projectId, authToken })).toEqual([]);- });-- test("Deleting a rotation with neither flag set leaves the credential live and the secrets editable", async () => {- const { secretRotation } = await newRotation("leaves-everything");-- await deleteSecretRotation({- rotationId: secretRotation!.id,- deleteSecrets: false,- revokeGeneratedCredentials: false,- authToken- });-- // The provider was never asked to revoke anything, so the credential still works. This is- // the escape hatch for a rotation whose credential is in use elsewhere.- expect(fakeIamUserSecret.keys()).toEqual(liveKeys(1));- expect(await secretsAt("/services")).toEqual(secretsHolding(1));-- // Nothing owns the secrets now, so the write the rotation refused above succeeds.- await updateSecretV2({- workspaceId: projectId,- environmentSlug: ENV,- secretPath: "/services",- key: SECRET_KEYS.accessKeyId,- value: "hand-written-value",- authToken- });-- expect((await secretsAt("/services"))[SECRET_KEYS.accessKeyId]).toBe("hand-written-value");- });- });-- describe("A credential check reports what the provider says about the active credential", () => {- test("A credential revoked at the provider fails the check", async () => {- const { secretRotation } = await newRotation("check-credentials");- const rotationId = secretRotation!.id;-- await checkRotationCredentials({ rotationId, authToken });-- fakeIamUserSecret.revokeOutOfBand(credential(1).accessKeyId);-- const error = await checkRotationCredentials({ rotationId, authToken, expectStatusCode: 400 });-- expect(error!.message).toContain(credential(1).accessKeyId);- // The check reports, it does not repair: the rotation still holds the dead credential.- expect(await secretsAt("/services")).toEqual(secretsHolding(1));- });- });});