diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.yml index 413ed0ebf..afa87a6cb 100644 --- a/.github/workflows/run-backend-tests.yml +++ b/.github/workflows/run-backend-tests.yml @@ -44,9 +44,6 @@ jobs: working-directory: backend - name: Start postgres and redis run: touch .env && docker compose -f docker-compose.dev.yml up -d db redis - - name: Login to Oracle Container Registry - run: echo "${{ secrets.ORACLE_DOCKER_REGISTRY_PASSWORD }}" | docker login container-registry.oracle.com -u "${{ secrets.ORACLE_DOCKER_REGISTRY_USERNAME }}" --password-stdin - - name: Start Secret Rotation testing databases run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300 - name: Run unit test @@ -56,6 +53,9 @@ jobs: run: npm run test:e2e working-directory: backend env: + E2E_TEST_ORACLE_DB_HOST: ${{ secrets.E2E_TEST_ORACLE_DB_HOST }} + E2E_TEST_ORACLE_DB_USERNAME: ${{ secrets.E2E_TEST_ORACLE_DB_USERNAME }} + E2E_TEST_ORACLE_DB_PASSWORD: ${{ secrets.E2E_TEST_ORACLE_DB_PASSWORD }} REDIS_URL: redis://172.17.0.1:6379 DB_CONNECTION_URI: postgres://infisical:infisical@172.17.0.1:5432/infisical?sslmode=disable AUTH_SECRET: something-random diff --git a/backend/e2e-test/routes/v3/secret-rotations.spec.ts b/backend/e2e-test/routes/v3/secret-rotations.spec.ts index f053eae70..0dc9a4b13 100644 --- a/backend/e2e-test/routes/v3/secret-rotations.spec.ts +++ b/backend/e2e-test/routes/v3/secret-rotations.spec.ts @@ -538,6 +538,7 @@ describe("Secret Rotations", async () => { { type: SecretRotationType.OracleDb, name: "OracleDB (19.3) Secret Rotation", + skippable: true, dbCredentials: { password: process.env.E2E_TEST_ORACLE_DB_PASSWORD!, host: process.env.E2E_TEST_ORACLE_DB_HOST!, @@ -628,6 +629,7 @@ describe("Secret Rotations", async () => { ] } ] as { + skippable?: boolean; type: SecretRotationType; name: string; dbCredentials: TGenericSqlCredentials; @@ -660,47 +662,65 @@ describe("Secret Rotations", async () => { } }); - test.concurrent.each(testCases)( - "Create secret rotation for $name", - async ({ dbCredentials, secretMapping, userCredentials, type }) => { - const appConnectionId = await createAppConnectionMap[type](dbCredentials); - - if (appConnectionId) { - appConnectionIds.push({ id: appConnectionId, type }); - } - - const res = await createRotationMap[type](appConnectionId, dbCredentials, userCredentials, secretMapping); - - const resJson = JSON.parse(res.payload); - - if (resJson.secretRotation) { - secretRotationIds.push({ id: resJson.secretRotation.id, type }); - } - - const startSecretValue = await getSecretValue(secretMapping.password); - expect(startSecretValue).toBeDefined(); - - let attempts = 0; - while (attempts < 60) { - const currentSecretValue = await getSecretValue(secretMapping.password); - - if (currentSecretValue !== startSecretValue) { - break; + testCases.forEach(({ skippable, dbCredentials, secretMapping, userCredentials, type, name }) => { + const shouldSkip = () => { + if (skippable) { + if (type === SecretRotationType.OracleDb) { + if (!process.env.E2E_TEST_ORACLE_DB_HOST) { + return true; + } } - - attempts += 1; - await new Promise((resolve) => setTimeout(resolve, 2_500)); } - if (attempts >= 60) { - throw new Error("Secret rotation failed to rotate after 60 attempts"); - } + return false; + }; - const finalSecretValue = await getSecretValue(secretMapping.password); - expect(finalSecretValue).not.toBe(startSecretValue); - }, - { - timeout: 300_000 + if (shouldSkip()) { + test.skip(`Skipping Secret Rotation for ${type} (${name}) because E2E_TEST_ORACLE_DB_HOST is not set`); + } else { + test.concurrent( + `Create secret rotation for ${name}`, + async () => { + const appConnectionId = await createAppConnectionMap[type](dbCredentials); + + if (appConnectionId) { + appConnectionIds.push({ id: appConnectionId, type }); + } + + const res = await createRotationMap[type](appConnectionId, dbCredentials, userCredentials, secretMapping); + + const resJson = JSON.parse(res.payload); + + if (resJson.secretRotation) { + secretRotationIds.push({ id: resJson.secretRotation.id, type }); + } + + const startSecretValue = await getSecretValue(secretMapping.password); + expect(startSecretValue).toBeDefined(); + + let attempts = 0; + while (attempts < 60) { + const currentSecretValue = await getSecretValue(secretMapping.password); + + if (currentSecretValue !== startSecretValue) { + break; + } + + attempts += 1; + await new Promise((resolve) => setTimeout(resolve, 2_500)); + } + + if (attempts >= 60) { + throw new Error("Secret rotation failed to rotate after 60 attempts"); + } + + const finalSecretValue = await getSecretValue(secretMapping.password); + expect(finalSecretValue).not.toBe(startSecretValue); + }, + { + timeout: 300_000 + } + ); } - ); + }); }); diff --git a/backend/vitest.e2e.config.ts b/backend/vitest.e2e.config.ts index 4c4680cb0..7584e6c9c 100644 --- a/backend/vitest.e2e.config.ts +++ b/backend/vitest.e2e.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ E2E_TEST_ORACLE_DB_PASSWORD: process.env.E2E_TEST_ORACLE_DB_PASSWORD! }, environment: "./e2e-test/vitest-environment-knex.ts", - include: ["./e2e-test/**/secret-rotations.spec.ts"], + include: ["./e2e-test/**/*.spec.ts"], poolOptions: { threads: { singleThread: true,