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(secret-sync): add end-to-end tests with a faked destination
Calvinae876869d957
diff --git a/.env.test.example b/.env.test.exampleindex bce047f77d..6437e1d470 100644--- a/.env.test.example+++ b/.env.test.example@@ -1,4 +1,12 @@-REDIS_URL=redis://localhost:6379-DB_CONNECTION_URI=postgres://infisical:infisical@localhost/infisical?sslmode=disable+# Read only when running the suites on the host. `make test-api-e2e` runs them in a container,+# where this file is absent and every setting is passed in explicitly.+#+# These point at the stack in docker-compose.test.yml. Start it with `make test-api-services`.+#+# Never point DB_CONNECTION_URI at the dev database: the e2e harness runs+# `DROP SCHEMA public CASCADE` on whatever database it is given, before every run.+REDIS_URL=redis://localhost:6380+DB_CONNECTION_URI=postgres://infisical:infisical@localhost:5436/infisical-test?sslmode=disable+AUTH_SECRET=4bnfe4e407b8921c104518903515b218-ENCRYPTION_KEY=4bnfe4e407b8921c104518903515b218\ No newline at end of file+ENCRYPTION_KEY=4bnfe4e407b8921c104518903515b218diff --git a/Makefile b/Makefileindex 9a71d2ce72..7c1ad83479 100644--- a/Makefile+++ b/Makefile@@ -44,6 +44,32 @@ reviewable-api:reviewable: reviewable-ui reviewable-api+# The API suites run against the throwaway stack in docker-compose.test.yml, never the dev one.+# That is not a preference: the e2e harness runs `DROP SCHEMA public CASCADE` on whatever+# database it is pointed at, so aiming it at the dev database takes your data with it.+# Everything else (image, environment, mounts, service dependencies) is declared there.+TEST_SUITE_COMPOSE = docker compose -f docker-compose.test.yml --profile runner++build-test-suite-image:+ $(TEST_SUITE_COMPOSE) build api-tests++# Only needed to run a suite from the host, against the published ports in .env.test.+# `make test-api-e2e` starts them itself and waits for them to report healthy.+up-test-suite-containers:+ $(TEST_SUITE_COMPOSE) up -d --wait db redis++down-test-suite-containers:+ $(TEST_SUITE_COMPOSE) down -v++# Narrow a run with SPEC=<pattern>, e.g. `make test-api-e2e SPEC=secret-sync`.+test-api-unit: build-test-suite-image+ $(TEST_SUITE_COMPOSE) run --rm api-tests npm run test:unit -- $(SPEC)++test-api-e2e: build-test-suite-image+ $(TEST_SUITE_COMPOSE) run --rm api-tests npm run test:e2e -- $(SPEC)++test-api: test-api-unit test-api-e2e+lint-docs:@./docs/scripts/lint-docs.sh --alldiff --git a/backend/e2e-test/fakes/aws-connection-fns.ts b/backend/e2e-test/fakes/aws-connection-fns.tsnew file mode 100644index 0000000000..be22ca9c47--- /dev/null+++ b/backend/e2e-test/fakes/aws-connection-fns.ts@@ -0,0 +1,89 @@+import { BadRequestError } from "@app/lib/errors";+import { AWSRegion } from "@app/services/app-connection/app-connection-enums";+import { TAwsConnectionConfig } from "@app/services/app-connection/aws/aws-connection-types";++import type * as RealProvider from "../../src/services/app-connection/aws/aws-connection-fns";++// AWS itself is not under test in the secret sync specs, so the whole provider is replaced.+// Wired up by test.alias in vitest.e2e.config.mts. Nothing under src/ references this file.+//+// The two pure exports come from the real module, and the type import above reaches it too.+// Both use this relative path deliberately: the aliases key on the specifiers+// "./aws-connection-fns" and "@app/services/app-connection/aws/aws-connection-fns", so this+// path is not itself aliased and does not resolve back to this file.+export {+ buildAwsConnectionConfig,+ getAwsConnectionListItem+} from "../../src/services/app-connection/aws/aws-connection-fns";++const DEFAULT_ACCOUNT_ID = "000000000000";++type TFakeAwsConnectionState = {+ accountId: string | null;+ validationError: string | null;+};++const state: TFakeAwsConnectionState = {+ accountId: DEFAULT_ACCOUNT_ID,+ validationError: null+};++// Behavior a spec can change. Every field resets between test files, so a spec never inherits+// another's configuration. See e2e-test/setup/reset-fakes.ts.+export const fakeAwsConnection = {+ reset: () => {+ state.accountId = DEFAULT_ACCOUNT_ID;+ state.validationError = null;+ },++ // What getAwsAccountId reports. null reproduces the real module's behavior when STS fails.+ returnsAccountId: (accountId: string | null) => {+ state.accountId = accountId;+ },++ // Make credential validation reject, as the real provider does for bad credentials.+ // Pass null to go back to accepting.+ failsValidationWith: (message: string | null) => {+ state.validationError = message;+ }+};++// Mirrors the real access-key branch, which hands back whatever the connection carries and+// makes no request. The assume-role branch is the one that calls STS, and no spec uses it.+export const getAwsConnectionConfig = (appConnection: TAwsConnectionConfig, region = AWSRegion.US_EAST_1) => {+ const { credentials } = appConnection;++ return Promise.resolve({+ region,+ credentials: {+ accessKeyId: "accessKeyId" in credentials ? credentials.accessKeyId : "fake-access-key-id",+ secretAccessKey: "secretAccessKey" in credentials ? credentials.secretAccessKey : "fake-secret-access-key",+ sessionToken: undefined as string | undefined+ }+ });+};++export const validateAwsConnectionCredentials = (appConnection: TAwsConnectionConfig) => {+ if (state.validationError) {+ // Same error type as the real module, so a spec can assert on the status and message.+ throw new BadRequestError({ message: `Unable to validate connection: ${state.validationError}` });+ }++ return Promise.resolve(appConnection.credentials);+};++// Takes no argument on purpose: callers pass a connection and JavaScript ignores it, while a+// zero-argument function still satisfies the real signature structurally.+export const getAwsAccountId = (): Promise<string | null> => Promise.resolve(state.accountId);++// Nothing forces a module replaced by an alias to match the module it replaces, so a signature+// change in the real provider would otherwise leave this fake quietly wrong. This assignment+// fails type-checking instead.+export const assertFakeMatchesRealProvider: Pick<+ typeof RealProvider,+ "validateAwsConnectionCredentials" | "getAwsAccountId" | "getAwsConnectionConfig"+> = {+ validateAwsConnectionCredentials,+ getAwsAccountId,+ getAwsConnectionConfig+};diff --git a/backend/e2e-test/fakes/aws-parameter-store-sync-fns.ts b/backend/e2e-test/fakes/aws-parameter-store-sync-fns.tsnew file mode 100644index 0000000000..2f36068ec7--- /dev/null+++ b/backend/e2e-test/fakes/aws-parameter-store-sync-fns.ts@@ -0,0 +1,148 @@+import { TAwsParameterStoreSyncWithCredentials } from "@app/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-types";+import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";+import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";+import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";++// Type-only, and by a path the aliases do not match, so this does not resolve back to here.+import type * as RealProvider from "../../src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns";++// Stands in for the AWS Parameter Store provider so the specs can assert what Infisical hands+// to a destination without reaching AWS. Wired up by test.alias in vitest.e2e.config.mts;+// nothing under src/ references this file.+//+// The reconciliation rules below are copied from the real module+// (aws-parameter-store-sync-fns.ts:356-479). They are the behavior under test, so a fake that+// only recorded its input would let a deletion or key schema regression pass unnoticed.++type TFakeStore = {+ secrets: Record<string, string>;+ writeError: string | null;+ runCount: number;+};++const stores = new Map<string, TFakeStore>();++const storeKeyFor = (region: string, path: string) => `${region}|${path}`;++const storeFor = (region: string, path: string): TFakeStore => {+ const key = storeKeyFor(region, path);+ let store = stores.get(key);++ if (!store) {+ store = { secrets: {}, writeError: null, runCount: 0 };+ stores.set(key, store);+ }++ return store;+};++const storeForSync = (secretSync: TAwsParameterStoreSyncWithCredentials) =>+ storeFor(secretSync.destinationConfig.region, secretSync.destinationConfig.path);++// Behavior a spec can change. Everything resets between test files, so a spec never inherits+// another's state or configuration. See e2e-test/setup/reset-fakes.ts.+export const fakeParameterStore = {+ reset: () => {+ stores.clear();+ },++ // A destination is addressed by the region and path the spec passes as destinationConfig+ // when it creates the sync, so it can be seeded before the sync exists.+ at: (region: string, path: string) => ({+ // Secrets already sitting at the destination before Infisical touches it.+ seed: (secrets: Record<string, string>) => {+ Object.assign(storeFor(region, path).secrets, secrets);+ },++ // What the destination holds now.+ read: (): Record<string, string> => ({ ...storeFor(region, path).secrets }),++ // Make every write fail, as a destination rejecting the request would.+ // Pass null to go back to accepting.+ rejectWritesWith: (message: string | null) => {+ storeFor(region, path).writeError = message;+ },++ // How many sync runs have reached this destination. Lets a spec assert that a change+ // did *not* trigger a run, which absence of a secret cannot prove on its own.+ runCount: (): number => storeFor(region, path).runCount+ })+};++export const AwsParameterStoreSyncFns = {+ syncSecrets: (secretSync: TAwsParameterStoreSyncWithCredentials, secretMap: TSecretMap) => {+ const { syncOptions, environment } = secretSync;+ const store = storeForSync(secretSync);++ store.runCount += 1;++ if (store.writeError) {+ throw new SecretSyncError({ message: store.writeError, shouldRetry: false });+ }++ const createdSecretKeys: string[] = [];+ const updatedSecretKeys: string[] = [];+ const deletedSecretKeys: string[] = [];++ for (const [key, { value }] of Object.entries(secretMap)) {+ // AWS rejects an empty parameter value, so the real module skips the write and lets the+ // deletion pass below remove the key instead.+ // eslint-disable-next-line no-continue+ if (!value) continue;++ if (Object.hasOwn(store.secrets, key)) {+ if (store.secrets[key] !== value) updatedSecretKeys.push(key);+ } else {+ createdSecretKeys.push(key);+ }++ store.secrets[key] = value;+ }++ if (syncOptions.disableSecretDeletion) {+ return Promise.resolve({ createdSecretKeys, updatedSecretKeys, deletedSecretKeys });+ }++ for (const key of Object.keys(store.secrets)) {+ // eslint-disable-next-line no-continue+ if (!matchesSchema(key, environment?.slug || "", syncOptions.keySchema)) continue;++ // The real module deletes a key that is absent from the map *or* present with an empty+ // value, so an emptied secret does not linger at the destination.+ if (!Object.hasOwn(secretMap, key) || !secretMap[key].value) {+ delete store.secrets[key];+ deletedSecretKeys.push(key);+ }+ }++ return Promise.resolve({ createdSecretKeys, updatedSecretKeys, deletedSecretKeys });+ },++ // Returns the destination as it stands. Key schema filtering and stripping is the caller's+ // job (secret-sync-fns.ts:643-645), so doing it here too would hide a bug in that wrapper.+ getSecrets: (secretSync: TAwsParameterStoreSyncWithCredentials): Promise<TSecretMap> =>+ Promise.resolve(+ Object.fromEntries(Object.entries(storeForSync(secretSync).secrets).map(([key, value]) => [key, { value }]))+ ),++ removeSecrets: (secretSync: TAwsParameterStoreSyncWithCredentials, secretMap: TSecretMap) => {+ const store = storeForSync(secretSync);++ if (store.writeError) {+ throw new SecretSyncError({ message: store.writeError, shouldRetry: false });+ }++ for (const key of Object.keys(store.secrets)) {+ if (Object.hasOwn(secretMap, key)) delete store.secrets[key];+ }++ return Promise.resolve();+ }+};++// Nothing forces a module replaced by an alias to match the module it replaces, so a signature+// change in the real provider would otherwise leave this fake quietly wrong. This assignment+// fails type-checking instead.+export const assertFakeMatchesRealProvider: Pick<typeof RealProvider, "AwsParameterStoreSyncFns"> = {+ AwsParameterStoreSyncFns+};diff --git a/backend/e2e-test/routes/v1/secret-sync.spec.ts b/backend/e2e-test/routes/v1/secret-sync.spec.tsnew file mode 100644index 0000000000..24c228602a--- /dev/null+++ b/backend/e2e-test/routes/v1/secret-sync.spec.ts@@ -0,0 +1,525 @@+import { fakeParameterStore } from "e2e-test/fakes/aws-parameter-store-sync-fns";+import { createFolder, deleteFolder } from "e2e-test/testUtils/folders";+import { createSecretImport } from "e2e-test/testUtils/secret-imports";+import {+ createAwsAppConnection,+ createSecretSync,+ deleteAppConnection,+ expectNoSyncRun,+ importSecretsForSync,+ removeSecretsForSync,+ triggerSecretSync+} from "e2e-test/testUtils/secret-syncs";+import { createSecretV2, deleteSecretV2, getSecretsV2 } from "e2e-test/testUtils/secrets";++import { SecretSyncInitialSyncBehavior } from "@app/services/secret-sync/secret-sync-enums";+import { SecretSyncStatus } from "@app/services/secret-sync/secret-sync-types";++// Covers the @e2e scenarios of "Feature: Secret Syncs" in the Test Specifications for Secrets+// Management. Each describe is one Rule and each test name is one Scenario, so a behavior+// change should show up here as an edited assertion rather than a silent pass.+//+// The destination is AWS Parameter Store, faked for the whole run (e2e-test/fakes/ and the+// alias block in vitest.e2e.config.mts). What is under test is Infisical resolving a set of+// secrets and handing them over, not AWS.++const REGION = "us-east-1";+const ENV = "dev";++// A distinct destination path per test, so a store leaking out of one test cannot be mistaken+// for another's result.+const pathFor = (name: string) => `/${name}/`;++describe("Secret syncs", async () => {+ let projectId: string;+ let connectionId: string;++ beforeAll(async () => {+ const projectRes = await testServer.inject({+ method: "POST",+ url: "/api/v1/projects",+ headers: { authorization: `Bearer ${jwtAuthToken}` },+ body: { projectName: `secret-sync-e2e-${Date.now()}` }+ });+ expect(projectRes.statusCode).toBe(200);+ projectId = projectRes.json().project.id as string;++ // Connections are org-scoped while syncs are project-scoped, so the name has to be unique+ // across the whole shared seeded org.+ connectionId = await createAwsAppConnection({+ name: `secret-sync-e2e-${Date.now()}`,+ authToken: jwtAuthToken+ });++ await createFolder({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath: "/",+ name: "services"+ });+ await createFolder({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath: "/services",+ name: "api"+ });+ });++ afterAll(async () => {+ await deleteAppConnection({ connectionId, authToken: jwtAuthToken });+ await testServer.inject({+ method: "DELETE",+ url: `/api/v1/projects/${projectId}`,+ headers: { authorization: `Bearer ${jwtAuthToken}` }+ });+ });++ beforeEach(() => {+ fakeParameterStore.reset();+ });++ const addSecret = (secretPath: string, key: string, value: string) =>+ createSecretV2({ authToken: jwtAuthToken, workspaceId: projectId, environmentSlug: ENV, secretPath, key, value });++ const removeSecret = (secretPath: string, key: string) =>+ deleteSecretV2({ authToken: jwtAuthToken, workspaceId: projectId, environmentSlug: ENV, secretPath, key });++ const secretKeysAt = async (secretPath: string) => {+ const { secrets } = await getSecretsV2({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath+ });+ return Object.fromEntries(secrets.map((secret) => [secret.secretKey, secret.secretValue]));+ };++ const newSync = async (+ name: string,+ overrides: Partial<Parameters<typeof createSecretSync>[0]> & { secretPath: string }+ ) => {+ const result = await createSecretSync({+ name,+ projectId,+ connectionId,+ environmentSlug: ENV,+ region: REGION,+ destinationPath: pathFor(name),+ authToken: jwtAuthToken,+ ...overrides+ });++ return result;+ };++ describe("A sync sends the secrets of its own source environment and secret path", () => {+ test("A sync sends the secrets of its source secret path", async () => {+ await addSecret("/services", "API_KEY", "api-value");++ const { secretSync } = await newSync("sends-source-path", { secretPath: "/services" });+ const sync = await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("sends-source-path"),+ authToken: jwtAuthToken+ });++ expect(sync.syncStatus).toBe(SecretSyncStatus.Succeeded);+ expect(fakeParameterStore.at(REGION, pathFor("sends-source-path")).read()).toEqual({ API_KEY: "api-value" });++ await removeSecret("/services", "API_KEY");+ });++ // The pin for recursive syncing. When a sync learns to walk child folders, this assertion+ // has to be rewritten deliberately rather than start failing by accident.+ test("A sync does not send the secrets of child secret paths", async () => {+ await addSecret("/services", "PARENT_KEY", "parent-value");+ await addSecret("/services/api", "CHILD_KEY", "child-value");++ const { secretSync } = await newSync("excludes-child-paths", { secretPath: "/services" });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("excludes-child-paths"),+ authToken: jwtAuthToken+ });++ const delivered = fakeParameterStore.at(REGION, pathFor("excludes-child-paths")).read();+ expect(delivered).toEqual({ PARENT_KEY: "parent-value" });+ expect(delivered).not.toHaveProperty("CHILD_KEY");++ await removeSecret("/services", "PARENT_KEY");+ await removeSecret("/services/api", "CHILD_KEY");+ });+ });++ describe("A sync resolves imported and referenced secret values before sending them", () => {+ test("A secret imported into the source secret path is sent to the destination", async () => {+ await addSecret("/", "SHARED_KEY", "shared-value");+ await addSecret("/services", "OWN_KEY", "own-value");+ await createSecretImport({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath: "/services",+ importEnv: ENV,+ importPath: "/"+ });++ const { secretSync } = await newSync("includes-imports", { secretPath: "/services" });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("includes-imports"),+ authToken: jwtAuthToken+ });++ expect(fakeParameterStore.at(REGION, pathFor("includes-imports")).read()).toEqual({+ OWN_KEY: "own-value",+ SHARED_KEY: "shared-value"+ });++ await removeSecret("/", "SHARED_KEY");+ await removeSecret("/services", "OWN_KEY");+ });+ });++ describe("The initial sync behavior decides what happens to secrets already at the destination", () => {+ test('Initial sync behavior "overwrite-destination" removes destination secrets Infisical does not have', async () => {+ await addSecret("/services", "API_KEY", "api-value");+ fakeParameterStore.at(REGION, pathFor("overwrite-destination")).seed({ STALE_KEY: "stale-value" });++ const { secretSync } = await newSync("overwrite-destination", {+ secretPath: "/services",+ initialSyncBehavior: SecretSyncInitialSyncBehavior.OverwriteDestination+ });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("overwrite-destination"),+ authToken: jwtAuthToken+ });++ expect(fakeParameterStore.at(REGION, pathFor("overwrite-destination")).read()).toEqual({+ API_KEY: "api-value"+ });++ await removeSecret("/services", "API_KEY");+ });++ test('Initial sync behavior "import-prioritize-source" keeps the Infisical value for a shared secret key', async () => {+ await addSecret("/services", "API_KEY", "infisical-value");+ fakeParameterStore.at(REGION, pathFor("prioritize-source")).seed({ API_KEY: "destination-value" });++ const { secretSync } = await newSync("prioritize-source", {+ secretPath: "/services",+ initialSyncBehavior: SecretSyncInitialSyncBehavior.ImportPrioritizeSource+ });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("prioritize-source"),+ authToken: jwtAuthToken+ });++ expect(fakeParameterStore.at(REGION, pathFor("prioritize-source")).read()).toEqual({+ API_KEY: "infisical-value"+ });+ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "infisical-value" });++ await removeSecret("/services", "API_KEY");+ });++ test('Initial sync behavior "import-prioritize-destination" takes the destination value into Infisical', async () => {+ await addSecret("/services", "API_KEY", "infisical-value");+ fakeParameterStore.at(REGION, pathFor("prioritize-destination")).seed({ API_KEY: "destination-value" });++ const { secretSync } = await newSync("prioritize-destination", {+ secretPath: "/services",+ initialSyncBehavior: SecretSyncInitialSyncBehavior.ImportPrioritizeDestination+ });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("prioritize-destination"),+ authToken: jwtAuthToken+ });++ // The import writes back into the project, which is the surprising half of this option.+ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "destination-value" });+ expect(fakeParameterStore.at(REGION, pathFor("prioritize-destination")).read()).toEqual({+ API_KEY: "destination-value"+ });++ await removeSecret("/services", "API_KEY");+ });++ test("The initial sync behavior applies only to the first sync run", async () => {+ await addSecret("/services", "API_KEY", "api-value");++ const { secretSync } = await newSync("first-run-only", {+ secretPath: "/services",+ initialSyncBehavior: SecretSyncInitialSyncBehavior.ImportPrioritizeDestination+ });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("first-run-only"),+ authToken: jwtAuthToken+ });++ // Arrives at the destination outside Infisical, after the first run has happened.+ fakeParameterStore.at(REGION, pathFor("first-run-only")).seed({ LATE_KEY: "late-value" });++ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("first-run-only"),+ authToken: jwtAuthToken+ });++ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "api-value" });+ expect(fakeParameterStore.at(REGION, pathFor("first-run-only")).read()).toEqual({ API_KEY: "api-value" });++ await removeSecret("/services", "API_KEY");+ });+ });++ describe("A later sync removes destination secrets Infisical no longer has, unless deletion is disabled", () => {+ test("Deleting a secret in Infisical removes it from the destination on the next sync run", async () => {+ await addSecret("/services", "API_KEY", "api-value");+ await addSecret("/services", "OLD_KEY", "old-value");++ const { secretSync } = await newSync("deletes-removed", { secretPath: "/services" });+ const address = { region: REGION, destinationPath: pathFor("deletes-removed"), authToken: jwtAuthToken };+ await triggerSecretSync({ syncId: secretSync!.id, ...address });++ await removeSecret("/services", "OLD_KEY");+ await triggerSecretSync({ syncId: secretSync!.id, ...address });++ expect(fakeParameterStore.at(REGION, pathFor("deletes-removed")).read()).toEqual({ API_KEY: "api-value" });++ await removeSecret("/services", "API_KEY");+ });++ test("The destination keeps the secret when the disable secret deletion parameter is set to true", async () => {+ await addSecret("/services", "API_KEY", "api-value");+ await addSecret("/services", "OLD_KEY", "old-value");++ const { secretSync } = await newSync("keeps-removed", {+ secretPath: "/services",+ disableSecretDeletion: true+ });+ const address = { region: REGION, destinationPath: pathFor("keeps-removed"), authToken: jwtAuthToken };+ await triggerSecretSync({ syncId: secretSync!.id, ...address });++ await removeSecret("/services", "OLD_KEY");+ await triggerSecretSync({ syncId: secretSync!.id, ...address });++ expect(fakeParameterStore.at(REGION, pathFor("keeps-removed")).read()).toEqual({+ API_KEY: "api-value",+ OLD_KEY: "old-value"+ });++ await removeSecret("/services", "API_KEY");+ });+ });++ describe("Importing from a destination brings its secrets into the source secret path", () => {+ test("An import creates secrets the source secret path does not have", async () => {+ fakeParameterStore.at(REGION, pathFor("import-creates")).seed({ DESTINATION_KEY: "destination-value" });++ const { secretSync } = await newSync("import-creates", { secretPath: "/services" });+ const { secretSync: imported } = await importSecretsForSync({+ syncId: secretSync!.id,+ importBehavior: "prioritize-source",+ authToken: jwtAuthToken+ });++ expect(imported!.importStatus).toBe(SecretSyncStatus.Succeeded);+ expect(await secretKeysAt("/services")).toEqual({ DESTINATION_KEY: "destination-value" });++ await removeSecret("/services", "DESTINATION_KEY");+ });++ test('An import with behavior "prioritize-destination" overwrites the Infisical value', async () => {+ await addSecret("/services", "API_KEY", "infisical-value");+ fakeParameterStore.at(REGION, pathFor("import-overwrites")).seed({ API_KEY: "destination-value" });++ const { secretSync } = await newSync("import-overwrites", { secretPath: "/services" });+ await importSecretsForSync({+ syncId: secretSync!.id,+ importBehavior: "prioritize-destination",+ authToken: jwtAuthToken+ });++ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "destination-value" });++ await removeSecret("/services", "API_KEY");+ });++ test("An import fails when a destination secret key is not a valid Infisical secret key", async () => {+ fakeParameterStore.at(REGION, pathFor("import-invalid-name")).seed({ "not a valid key": "destination-value" });++ const { secretSync } = await newSync("import-invalid-name", { secretPath: "/services" });+ const { secretSync: imported } = await importSecretsForSync({+ syncId: secretSync!.id,+ importBehavior: "prioritize-source",+ authToken: jwtAuthToken+ });++ expect(imported!.importStatus).toBe(SecretSyncStatus.Failed);+ expect(imported!.lastImportMessage).toContain("invalid secret name");+ expect(await secretKeysAt("/services")).toEqual({});+ });+ });++ describe("Removing secrets clears the destination and leaves Infisical unchanged", () => {+ test("A remove clears the sync's secrets from the destination", async () => {+ await addSecret("/services", "API_KEY", "api-value");++ const { secretSync } = await newSync("remove-clears", { secretPath: "/services" });+ await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath: pathFor("remove-clears"),+ authToken: jwtAuthToken+ });+ expect(fakeParameterStore.at(REGION, pathFor("remove-clears")).read()).toEqual({ API_KEY: "api-value" });++ const removed = await removeSecretsForSync({ syncId: secretSync!.id, authToken: jwtAuthToken });++ expect(removed.removeStatus).toBe(SecretSyncStatus.Succeeded);+ expect(fakeParameterStore.at(REGION, pathFor("remove-clears")).read()).toEqual({});+ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "api-value" });++ await removeSecret("/services", "API_KEY");+ });+ });++ describe("Automatic syncing is triggered by changes at the source secret path only", () => {+ test("Creating a secret at the source secret path triggers a sync run", async () => {+ const destinationPath = pathFor("auto-sync-source");+ const { secretSync } = await newSync("auto-sync-source", {+ secretPath: "/services",+ isAutoSyncEnabled: true+ });++ // Creating the sync with auto sync on already queues one run; wait it out so the run this+ // test cares about is the one the secret write causes.+ await triggerSecretSync({ syncId: secretSync!.id, region: REGION, destinationPath, authToken: jwtAuthToken });+ const runCountBefore = fakeParameterStore.at(REGION, destinationPath).runCount();++ await addSecret("/services", "NEW_KEY", "new-value");++ await triggerSecretSync({ syncId: secretSync!.id, region: REGION, destinationPath, authToken: jwtAuthToken });+ expect(fakeParameterStore.at(REGION, destinationPath).runCount()).toBeGreaterThan(runCountBefore);+ expect(fakeParameterStore.at(REGION, destinationPath).read()).toEqual({ NEW_KEY: "new-value" });++ await removeSecret("/services", "NEW_KEY");+ });++ // The second pin for recursive syncing: today a child folder write reaches nothing.+ test("Creating a secret in a child secret path does not trigger a sync run", async () => {+ const destinationPath = pathFor("auto-sync-child");+ await addSecret("/services", "PARENT_KEY", "parent-value");++ const { secretSync } = await newSync("auto-sync-child", {+ secretPath: "/services",+ isAutoSyncEnabled: true+ });+ await triggerSecretSync({ syncId: secretSync!.id, region: REGION, destinationPath, authToken: jwtAuthToken });+ const runCountBefore = fakeParameterStore.at(REGION, destinationPath).runCount();++ await addSecret("/services/api", "CHILD_KEY", "child-value");++ await expectNoSyncRun({ region: REGION, destinationPath, runCountBefore });+ expect(fakeParameterStore.at(REGION, destinationPath).read()).toEqual({ PARENT_KEY: "parent-value" });++ await removeSecret("/services", "PARENT_KEY");+ await removeSecret("/services/api", "CHILD_KEY");+ });++ test("A change at the source secret path does not trigger a sync run when the auto sync parameter is false", async () => {+ const destinationPath = pathFor("auto-sync-off");+ await newSync("auto-sync-off", { secretPath: "/services", isAutoSyncEnabled: false });++ await addSecret("/services", "NEW_KEY", "new-value");++ await expectNoSyncRun({ region: REGION, destinationPath, runCountBefore: 0 });+ expect(fakeParameterStore.at(REGION, destinationPath).read()).toEqual({});++ await removeSecret("/services", "NEW_KEY");+ });+ });++ describe("A failed sync run is reported on the sync and changes nothing", () => {+ test("A destination failure marks the sync failed and records the reason", async () => {+ const destinationPath = pathFor("destination-rejects");+ await addSecret("/services", "API_KEY", "api-value");+ fakeParameterStore.at(REGION, destinationPath).rejectWritesWith("Destination refused the write");++ const { secretSync } = await newSync("destination-rejects", { secretPath: "/services" });+ const sync = await triggerSecretSync({+ syncId: secretSync!.id,+ region: REGION,+ destinationPath,+ authToken: jwtAuthToken+ });++ expect(sync.syncStatus).toBe(SecretSyncStatus.Failed);+ expect(sync.lastSyncMessage).toContain("Destination refused the write");+ expect(await secretKeysAt("/services")).toEqual({ API_KEY: "api-value" });++ await removeSecret("/services", "API_KEY");+ });++ test("A sync whose source secret path no longer exists fails with a message naming the source", async () => {+ const destinationPath = pathFor("source-path-gone");+ const folder = await createFolder({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath: "/",+ name: "doomed"+ });+ await addSecret("/doomed", "API_KEY", "api-value");++ const { secretSync } = await newSync("source-path-gone", { secretPath: "/doomed" });+ await triggerSecretSync({ syncId: secretSync!.id, region: REGION, destinationPath, authToken: jwtAuthToken });++ await deleteFolder({+ authToken: jwtAuthToken,+ workspaceId: projectId,+ environmentSlug: ENV,+ secretPath: "/",+ id: folder.id+ });++ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/secret-syncs/aws-parameter-store/${secretSync!.id}/sync-secrets`,+ headers: { authorization: `Bearer ${jwtAuthToken}` }+ });++ // The source folder is gone, so the trigger itself refuses rather than queueing a run+ // that could not resolve a source.+ expect(res.statusCode).toBe(400);+ expect(res.json().message).toContain("folder no longer exists");+ });+ });++ describe("A sync is created against one existing source secret path and one matching connection", () => {+ test("Creating a sync for a secret path that does not exist fails", async () => {+ const { error } = await newSync("missing-source-path", {+ secretPath: "/does/not/exist",+ expectStatusCode: 400+ });++ expect(error!.message).toContain("/does/not/exist");+ expect(error!.message).toContain(ENV);+ });+ });+});diff --git a/backend/e2e-test/setup/reset-fakes.ts b/backend/e2e-test/setup/reset-fakes.tsnew file mode 100644index 0000000000..a4825d0293--- /dev/null+++ b/backend/e2e-test/setup/reset-fakes.ts@@ -0,0 +1,17 @@+import { fakeAwsConnection } from "e2e-test/fakes/aws-connection-fns";+import { fakeParameterStore } from "e2e-test/fakes/aws-parameter-store-sync-fns";++// The fakes are module singletons shared with the server booted in this same process, and the+// suite runs in a single fork with fileParallelism disabled. So a spec that seeds a+// destination, or makes credential validation fail, would otherwise leak that state into every+// file that runs after it — and into files that never mention secret syncs at all.+//+// Resetting at the start of every file makes each one self-healing regardless of how its+// predecessor ended, including a hard death that skips its own afterAll. Same reasoning as+// reset-shared-org-flags.ts, which this sits alongside.+//+// A spec still resets between its own tests; that is its own beforeEach, not this hook.+beforeAll(() => {+ fakeParameterStore.reset();+ fakeAwsConnection.reset();+});diff --git a/backend/e2e-test/testUtils/secret-syncs.ts b/backend/e2e-test/testUtils/secret-syncs.tsnew file mode 100644index 0000000000..31221c0809--- /dev/null+++ b/backend/e2e-test/testUtils/secret-syncs.ts@@ -0,0 +1,240 @@+import { fakeParameterStore } from "e2e-test/fakes/aws-parameter-store-sync-fns";++import { SecretSyncInitialSyncBehavior } from "@app/services/secret-sync/secret-sync-enums";+import { SecretSyncStatus } from "@app/services/secret-sync/secret-sync-types";++// Every spec drives AWS Parameter Store, which is faked for the whole e2e run. See+// e2e-test/fakes/ and the alias block in vitest.e2e.config.mts.+const DESTINATION = "aws-parameter-store";++const SYNC_TIMEOUT_MS = 20_000;+const SYNC_POLL_MS = 100;++type TSecretSyncRecord = {+ id: string;+ name: string;+ syncStatus: string | null;+ importStatus: string | null;+ removeStatus: string | null;+ lastSyncMessage: string | null;+ lastImportMessage: string | null;+ lastRemoveMessage: string | null;+ lastSyncedAt: string | null;+};++const TERMINAL_STATUSES: string[] = [SecretSyncStatus.Succeeded, SecretSyncStatus.Failed];++export const createAwsAppConnection = async (dto: { name: string; authToken: string }) => {+ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/app-connections/aws`,+ headers: { authorization: `Bearer ${dto.authToken}` },+ body: {+ name: dto.name,+ method: "access-key",+ credentials: {+ accessKeyId: "AKIAFAKEACCESSKEYID",+ secretAccessKey: "fake-secret-access-key"+ }+ }+ });++ expect(res.statusCode).toBe(200);+ return res.json().appConnection.id as string;+};++export const deleteAppConnection = async (dto: { connectionId: string; authToken: string }) => {+ const res = await testServer.inject({+ method: "DELETE",+ url: `/api/v1/app-connections/aws/${dto.connectionId}`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ });++ expect(res.statusCode).toBe(200);+};++export const createSecretSync = async (dto: {+ name: string;+ projectId: string;+ connectionId: string;+ environmentSlug: string;+ secretPath: string;+ // The region and path address the fake destination, so a spec can seed it before the sync+ // exists. Creating a sync with auto sync on runs it immediately.+ region: string;+ destinationPath: string;+ initialSyncBehavior?: SecretSyncInitialSyncBehavior;+ keySchema?: string;+ disableSecretDeletion?: boolean;+ isAutoSyncEnabled?: boolean;+ authToken: string;+ expectStatusCode?: number;+}) => {+ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/secret-syncs/${DESTINATION}`,+ headers: { authorization: `Bearer ${dto.authToken}` },+ body: {+ name: dto.name,+ projectId: dto.projectId,+ connectionId: dto.connectionId,+ environment: dto.environmentSlug,+ secretPath: dto.secretPath,+ isAutoSyncEnabled: dto.isAutoSyncEnabled ?? false,+ syncOptions: {+ initialSyncBehavior: dto.initialSyncBehavior ?? SecretSyncInitialSyncBehavior.OverwriteDestination,+ ...(dto.keySchema ? { keySchema: dto.keySchema } : {}),+ ...(dto.disableSecretDeletion === undefined ? {} : { disableSecretDeletion: dto.disableSecretDeletion })+ },+ destinationConfig: { region: dto.region, path: dto.destinationPath }+ }+ });++ expect(res.statusCode).toBe(dto.expectStatusCode ?? 200);++ // A spec asserting a rejection wants the body, not an id.+ if ((dto.expectStatusCode ?? 200) !== 200) return { error: res.json() };++ return { secretSync: res.json().secretSync as TSecretSyncRecord };+};++export const getSecretSync = async (dto: { syncId: string; authToken: string }) => {+ const res = await testServer.inject({+ method: "GET",+ url: `/api/v1/secret-syncs/${DESTINATION}/${dto.syncId}`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ });++ expect(res.statusCode).toBe(200);+ return res.json().secretSync as TSecretSyncRecord;+};++export const deleteSecretSync = async (dto: { syncId: string; authToken: string }) => {+ const res = await testServer.inject({+ method: "DELETE",+ url: `/api/v1/secret-syncs/${DESTINATION}/${dto.syncId}`,+ headers: { authorization: `Bearer ${dto.authToken}` },+ body: { removeSecrets: false }+ });++ expect(res.statusCode).toBe(200);+};++const pollUntil = async <T>(dto: { describe: string; read: () => Promise<T> | T; done: (value: T) => boolean }) => {+ const deadline = Date.now() + SYNC_TIMEOUT_MS;++ for (;;) {+ // eslint-disable-next-line no-await-in-loop+ const value = await dto.read();+ if (dto.done(value)) return value;++ if (Date.now() >= deadline) {+ throw new Error(`Timed out after ${SYNC_TIMEOUT_MS}ms waiting for ${dto.describe}`);+ }++ // eslint-disable-next-line no-await-in-loop+ await new Promise((resolve) => {+ setTimeout(resolve, SYNC_POLL_MS);+ });+ }+};++// Waits on the fake's own run counter before reading the record, rather than on the record+// alone. triggerSecretSyncSyncSecretsById writes syncStatus "pending" *after* enqueuing the job+// (secret-sync-service.ts:800), so a status-only wait races that write and can sit on a stale+// "succeeded" from an earlier run.+export const waitForSyncRun = async (dto: {+ syncId: string;+ region: string;+ destinationPath: string;+ runCountBefore: number;+ authToken: string;+}) => {+ await pollUntil({+ describe: `a sync run to reach the destination at ${dto.region}${dto.destinationPath}`,+ read: () => fakeParameterStore.at(dto.region, dto.destinationPath).runCount(),+ done: (runCount) => runCount > dto.runCountBefore+ });++ return pollUntil({+ describe: `secret sync "${dto.syncId}" to report a terminal sync status`,+ read: () => getSecretSync({ syncId: dto.syncId, authToken: dto.authToken }),+ done: (sync) => TERMINAL_STATUSES.includes(sync.syncStatus ?? "")+ });+};++export const triggerSecretSync = async (dto: {+ syncId: string;+ region: string;+ destinationPath: string;+ authToken: string;+}) => {+ const runCountBefore = fakeParameterStore.at(dto.region, dto.destinationPath).runCount();++ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/secret-syncs/${DESTINATION}/${dto.syncId}/sync-secrets`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ });++ expect(res.statusCode).toBe(200);++ return waitForSyncRun({ ...dto, runCountBefore });+};++export const importSecretsForSync = async (dto: {+ syncId: string;+ importBehavior: "prioritize-source" | "prioritize-destination";+ authToken: string;+ expectStatusCode?: number;+}) => {+ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/secret-syncs/${DESTINATION}/${dto.syncId}/import-secrets`,+ headers: { authorization: `Bearer ${dto.authToken}` },+ body: { importBehavior: dto.importBehavior }+ });++ expect(res.statusCode).toBe(dto.expectStatusCode ?? 200);++ if ((dto.expectStatusCode ?? 200) !== 200) return { error: res.json() };++ const sync = await pollUntil({+ describe: `secret sync "${dto.syncId}" to report a terminal import status`,+ read: () => getSecretSync({ syncId: dto.syncId, authToken: dto.authToken }),+ done: (record) => TERMINAL_STATUSES.includes(record.importStatus ?? "")+ });++ return { secretSync: sync };+};++export const removeSecretsForSync = async (dto: { syncId: string; authToken: string }) => {+ const res = await testServer.inject({+ method: "POST",+ url: `/api/v1/secret-syncs/${DESTINATION}/${dto.syncId}/remove-secrets`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ });++ expect(res.statusCode).toBe(200);++ return pollUntil({+ describe: `secret sync "${dto.syncId}" to report a terminal remove status`,+ read: () => getSecretSync({ syncId: dto.syncId, authToken: dto.authToken }),+ done: (record) => TERMINAL_STATUSES.includes(record.removeStatus ?? "")+ });+};++// A spec that expects no sync run has to wait out a window in which one could have happened;+// asserting an absence immediately would pass simply because nothing had run yet.+export const expectNoSyncRun = async (dto: {+ region: string;+ destinationPath: string;+ runCountBefore: number;+ windowMs?: number;+}) => {+ await new Promise((resolve) => {+ setTimeout(resolve, dto.windowMs ?? 2_000);+ });++ expect(fakeParameterStore.at(dto.region, dto.destinationPath).runCount()).toBe(dto.runCountBefore);+};diff --git a/backend/vitest.e2e.config.mts b/backend/vitest.e2e.config.mtsindex 6534ea285f..02d3c0fedf 100644--- a/backend/vitest.e2e.config.mts+++ b/backend/vitest.e2e.config.mts@@ -36,8 +36,8 @@ export default defineConfig({},environment: "./e2e-test/vitest-environment-knex.ts",include: ["./e2e-test/**/*.spec.ts"],- // Runs per test file, after the environment is up — see the file for why.- setupFiles: ["./e2e-test/setup/reset-shared-org-flags.ts"],+ // Runs per test file, after the environment is up — see each file for why.+ setupFiles: ["./e2e-test/setup/reset-shared-org-flags.ts", "./e2e-test/setup/reset-fakes.ts"],sequence: { sequencer: PathSequencer },pool: "forks",poolOptions: {@@ -49,9 +49,37 @@ export default defineConfig({},fileParallelism: false,- alias: {- "./license-fns": path.resolve(__dirname, "./src/ee/services/license/__mocks__/license-fns")- }+ // AWS Parameter Store and the AWS app connection are replaced by fakes for the whole e2e+ // run, so the secret sync specs can assert what Infisical hands a destination without+ // reaching AWS. Nothing under src/ knows the fakes exist — see e2e-test/fakes/.+ //+ // Entries match the *import specifier*, which is what keeps this surgical rather than+ // sweeping: "./aws-parameter-store-sync-fns" is imported only by its own barrel, and+ // "./aws-connection-fns" only by aws/index.ts. The full-path entry covers the twelve+ // modules that import the connection functions directly, of which secret-sync-maps.ts+ // matters here: it calls getAwsAccountId on every sync creation, which would otherwise be+ // a real STS request that fails slowly and silently.+ //+ // An ordered array rather than an object so the exact @app/… entry is matched before the+ // generic "@app" prefix alias in resolve.alias below.+ alias: [+ {+ find: "./license-fns",+ replacement: path.resolve(__dirname, "./src/ee/services/license/__mocks__/license-fns")+ },+ {+ find: "./aws-parameter-store-sync-fns",+ replacement: path.resolve(__dirname, "./e2e-test/fakes/aws-parameter-store-sync-fns")+ },+ {+ find: /^@app\/services\/app-connection\/aws\/aws-connection-fns$/,+ replacement: path.resolve(__dirname, "./e2e-test/fakes/aws-connection-fns")+ },+ {+ find: "./aws-connection-fns",+ replacement: path.resolve(__dirname, "./e2e-test/fakes/aws-connection-fns")+ }+ ]},resolve: {alias: {diff --git a/docker-compose.dev-read-replica.yml b/docker-compose.dev-read-replica.ymlindex dcb537c7c6..e25be82d17 100644--- a/docker-compose.dev-read-replica.yml+++ b/docker-compose.dev-read-replica.yml@@ -67,16 +67,6 @@ services:ports:- "8085:8081"- db-test:- profiles: ["test"]- image: postgres:14-alpine- ports:- - "5430:5432"- environment:- POSTGRES_PASSWORD: infisical- POSTGRES_USER: infisical- POSTGRES_DB: infisical-test-db-migration:container_name: infisical-db-migrationdepends_on:diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex bf11e8f9d1..26867a7af2 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -81,17 +81,6 @@ services:- "3008:3000"profiles: [queue]- db-test:- profiles: ["test"]- image: postgres:14-alpine- ports:- - "5430:5432"- environment:- POSTGRES_PASSWORD: infisical- POSTGRES_USER: infisical- POSTGRES_DB: infisical-test- command: postgres -c max_locks_per_transaction=512-backend:container_name: infisical-dev-apibuild:diff --git a/docker-compose.test.yml b/docker-compose.test.ymlnew file mode 100644index 0000000000..9610d6f08a--- /dev/null+++ b/docker-compose.test.yml@@ -0,0 +1,86 @@+# Backing services for the backend test suites, deliberately separate from+# docker-compose.dev.yml so a test run cannot reach the data you develop against.+#+# That separation is not tidiness. The e2e harness (backend/e2e-test/vitest-environment-knex.ts)+# runs `DROP SCHEMA public CASCADE` on whatever database it is pointed at, before every run.+#+# Started by `make test-api-services`; torn down by `make test-api-down`. There are no volumes,+# so nothing here outlives the containers.++# Fixed so the project, and therefore the network name the test container joins, does not+# depend on the checkout directory.+name: infisical-test++services:+ db:+ image: postgres:14-alpine+ # A full suite run brings this stack up alongside the dev stack and the rotation databases+ # in docker-compose.e2e-dbs.yml, so host ports here must not clash with either.+ ports:+ - "5436:5432"+ environment:+ POSTGRES_PASSWORD: infisical+ POSTGRES_USER: infisical+ POSTGRES_DB: infisical-test+ # Matches the dev database. The suite holds enough locks in one transaction to need it.+ command: postgres -c max_locks_per_transaction=512+ # `up --wait` treats a container with no healthcheck as ready once it is running, which for+ # Postgres is before it accepts connections, so the suite would fail on connect instead of+ # waiting for it.+ healthcheck:+ test: ["CMD-SHELL", "pg_isready -U infisical -d infisical-test"]+ interval: 2s+ timeout: 3s+ retries: 30++ redis:+ image: redis+ environment:+ - ALLOW_EMPTY_PASSWORD=yes+ ports:+ - "6380:6379"+ healthcheck:+ test: ["CMD", "redis-cli", "ping"]+ interval: 2s+ timeout: 3s+ retries: 30++ # The suites themselves. Runs the same FIPS image as the dev stack, which is where the+ # native dependencies the suites need live (SoftHSM2, the Oracle client, the FIPS OpenSSL+ # build), and which pins the Node version so the host's does not matter.+ #+ # Behind a profile so `up` brings up only the backing services. `make test-api-e2e` runs it+ # with `compose run`, which starts its dependencies and waits for them to report healthy.+ api-tests:+ profiles: ["runner"]+ build:+ context: ./backend+ dockerfile: Dockerfile.dev.fips+ args:+ TOOLCHAIN_IMAGE: ${TOOLCHAIN_IMAGE:-ghcr.io/infisical/backend-fips-toolchain:main}+ depends_on:+ db:+ condition: service_healthy+ redis:+ condition: service_healthy+ environment:+ DB_CONNECTION_URI: postgres://infisical:infisical@db:5432/infisical-test?sslmode=disable+ REDIS_URL: redis://redis:6379+ AUTH_SECRET: something-random+ ENCRYPTION_KEY: p5e5k2j3+HIErjm02dzSrlhXc1xhdgoWvC6pox410rE=+ NODE_ENV: test+ NODE_OPTIONS: --force-fips+ TELEMETRY_ENABLED: "false"+ # The secret rotation specs need these plus `docker compose -f docker-compose.e2e-dbs.yml+ # up -d`. Left empty otherwise, which is how a run without them behaves anyway.+ E2E_TEST_ORACLE_DB_19_HOST: ${E2E_TEST_ORACLE_DB_19_HOST:-}+ E2E_TEST_ORACLE_DB_19_USERNAME: ${E2E_TEST_ORACLE_DB_19_USERNAME:-}+ E2E_TEST_ORACLE_DB_19_PASSWORD: ${E2E_TEST_ORACLE_DB_19_PASSWORD:-}+ E2E_TEST_ORACLE_DB_19_DATABASE: ${E2E_TEST_ORACLE_DB_19_DATABASE:-}+ # The image bakes a copy of the source; these shadow it so a run uses the working tree and+ # editing a test needs no rebuild. Anything outside them (package.json, tsconfig.json) does.+ volumes:+ - ./backend/src:/app/src+ - ./backend/e2e-test:/app/e2e-test+ - ./backend/vitest.e2e.config.mts:/app/vitest.e2e.config.mts+ - ./backend/vitest.unit.config.mts:/app/vitest.unit.config.mts