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
feat: added secret version test with secret import
=66ded779fc82
diff --git a/backend/e2e-test/routes/v1/secret-replication.spec.ts b/backend/e2e-test/routes/v1/secret-replication.spec.tsindex d28223d2ce..f762165a22 100644--- a/backend/e2e-test/routes/v1/secret-replication.spec.ts+++ b/backend/e2e-test/routes/v1/secret-replication.spec.ts@@ -5,9 +5,9 @@ import { createSecretV2, deleteSecretV2, getSecretByNameV2, getSecretsV2 } fromimport { seedData1 } from "@app/db/seed-data";// dev <- stage <- prod-describe.each([{ path: "/" }, { path: "/deep" }])(- "Secret replication waterfall pattern testing - %path",- ({ path: testSuitePath }) => {+describe.each([{ secretPath: "/" }, { secretPath: "/deep" }])(+ "Secret replication waterfall pattern testing - %secretPath",+ ({ secretPath: testSuitePath }) => {beforeAll(async () => {let prodFolder: { id: string };let stagingFolder: { id: string };@@ -140,6 +140,7 @@ describe.each([{ path: "/" }, { path: "/deep" }])(secretPath: testSuitePath,authToken: jwtAuthToken});+expect(listSecrets.imports).toEqual(expect.arrayContaining([expect.objectContaining({diff --git a/backend/e2e-test/routes/v3/secret-reference.spec.ts b/backend/e2e-test/routes/v3/secret-reference.spec.tsindex 42f3b9c14c..fb23cdc259 100644--- a/backend/e2e-test/routes/v3/secret-reference.spec.ts+++ b/backend/e2e-test/routes/v3/secret-reference.spec.ts@@ -1,4 +1,5 @@import { createFolder, deleteFolder } from "e2e-test/testUtils/folders";+import { createSecretImport, deleteSecretImport } from "e2e-test/testUtils/secret-imports";import { createSecretV2, deleteSecretV2, getSecretByNameV2, getSecretsV2 } from "e2e-test/testUtils/secrets";import { seedData1 } from "@app/db/seed-data";@@ -150,4 +151,180 @@ describe("Secret expansion", () => {await Promise.all(secrets.map((el) => deleteSecretV2(el)));});++ test("Non replicated secret import secret expansion on local reference and nested reference", async () => {+ const secrets = [+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep",+ authToken: jwtAuthToken,+ key: "DEEP_KEY_1",+ value: "testing"+ },+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep/nested",+ authToken: jwtAuthToken,+ key: "NESTED_KEY_1",+ value: "reference"+ },+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep/nested",+ authToken: jwtAuthToken,+ key: "NESTED_KEY_2",+ // eslint-disable-next-line+ value: "secret ${NESTED_KEY_1} ${prod.deep.DEEP_KEY_1}"+ },+ {+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken,+ key: "KEY",+ // eslint-disable-next-line+ value: "hello world"+ }+ ];++ await Promise.all(secrets.map((el) => createSecretV2(el)));+ const secretImportFromProdToDev = await createSecretImport({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken,+ importEnv: "prod",+ importPath: "/deep/nested"+ });++ const listSecrets = await getSecretsV2({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken+ });+ expect(listSecrets.imports).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ secretPath: "/deep/nested",+ environment: "prod",+ secrets: expect.arrayContaining([+ expect.objectContaining({+ secretKey: "NESTED_KEY_1",+ secretValue: "reference"+ }),+ expect.objectContaining({+ secretKey: "NESTED_KEY_2",+ secretValue: "secret reference testing"+ })+ ])+ })+ ])+ );++ await Promise.all(secrets.map((el) => deleteSecretV2(el)));+ await deleteSecretImport({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ authToken: jwtAuthToken,+ id: secretImportFromProdToDev.id,+ secretPath: "/"+ });+ });++ test(+ "Replicated secret import secret expansion on local reference and nested reference",+ async () => {+ const secrets = [+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep",+ authToken: jwtAuthToken,+ key: "DEEP_KEY_1",+ value: "testing"+ },+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep/nested",+ authToken: jwtAuthToken,+ key: "NESTED_KEY_1",+ value: "reference"+ },+ {+ environmentSlug: "prod",+ workspaceId: projectId,+ secretPath: "/deep/nested",+ authToken: jwtAuthToken,+ key: "NESTED_KEY_2",+ // eslint-disable-next-line+ value: "secret ${NESTED_KEY_1} ${prod.deep.DEEP_KEY_1}"+ },+ {+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken,+ key: "KEY",+ // eslint-disable-next-line+ value: "hello world"+ }+ ];++ await Promise.all(secrets.map((el) => createSecretV2(el)));+ const secretImportFromProdToDev = await createSecretImport({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken,+ importEnv: "prod",+ importPath: "/deep/nested",+ isReplication: true+ });++ // wait for 5 second for replication to finish+ await new Promise((resolve) => {+ setTimeout(resolve, 5000); // time to breathe for db+ });++ const listSecrets = await getSecretsV2({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ secretPath: "/",+ authToken: jwtAuthToken+ });+ expect(listSecrets.imports).toEqual(+ expect.arrayContaining([+ expect.objectContaining({+ secretPath: `/__reserve_replication_${secretImportFromProdToDev.id}`,+ environment: seedData1.environment.slug,+ secrets: expect.arrayContaining([+ expect.objectContaining({+ secretKey: "NESTED_KEY_1",+ secretValue: "reference"+ }),+ expect.objectContaining({+ secretKey: "NESTED_KEY_2",+ secretValue: "secret reference testing"+ })+ ])+ })+ ])+ );++ await Promise.all(secrets.map((el) => deleteSecretV2(el)));+ await deleteSecretImport({+ environmentSlug: seedData1.environment.slug,+ workspaceId: projectId,+ authToken: jwtAuthToken,+ id: secretImportFromProdToDev.id,+ secretPath: "/"+ });+ },+ { timeout: 10000 }+ );});diff --git a/backend/e2e-test/vitest-environment-knex.ts b/backend/e2e-test/vitest-environment-knex.tsindex f57e543734..7be0b860f8 100644--- a/backend/e2e-test/vitest-environment-knex.ts+++ b/backend/e2e-test/vitest-environment-knex.ts@@ -30,7 +30,7 @@ export default {});const redis = new Redis(cfg.REDIS_URL);- await redis.flushdb("ASYNC");+ await redis.flushdb("SYNC");try {await db.migrate.rollback(