final fixes

This commit is contained in:
Daniel Hougaard
2025-08-12 00:56:11 +04:00
parent e13fc93bac
commit e173ff3828
3 changed files with 62 additions and 42 deletions

View File

@@ -44,9 +44,6 @@ jobs:
working-directory: backend working-directory: backend
- name: Start postgres and redis - name: Start postgres and redis
run: touch .env && docker compose -f docker-compose.dev.yml up -d db 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 - name: Start Secret Rotation testing databases
run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300 run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300
- name: Run unit test - name: Run unit test
@@ -56,6 +53,9 @@ jobs:
run: npm run test:e2e run: npm run test:e2e
working-directory: backend working-directory: backend
env: 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 REDIS_URL: redis://172.17.0.1:6379
DB_CONNECTION_URI: postgres://infisical:infisical@172.17.0.1:5432/infisical?sslmode=disable DB_CONNECTION_URI: postgres://infisical:infisical@172.17.0.1:5432/infisical?sslmode=disable
AUTH_SECRET: something-random AUTH_SECRET: something-random

View File

@@ -538,6 +538,7 @@ describe("Secret Rotations", async () => {
{ {
type: SecretRotationType.OracleDb, type: SecretRotationType.OracleDb,
name: "OracleDB (19.3) Secret Rotation", name: "OracleDB (19.3) Secret Rotation",
skippable: true,
dbCredentials: { dbCredentials: {
password: process.env.E2E_TEST_ORACLE_DB_PASSWORD!, password: process.env.E2E_TEST_ORACLE_DB_PASSWORD!,
host: process.env.E2E_TEST_ORACLE_DB_HOST!, host: process.env.E2E_TEST_ORACLE_DB_HOST!,
@@ -628,6 +629,7 @@ describe("Secret Rotations", async () => {
] ]
} }
] as { ] as {
skippable?: boolean;
type: SecretRotationType; type: SecretRotationType;
name: string; name: string;
dbCredentials: TGenericSqlCredentials; dbCredentials: TGenericSqlCredentials;
@@ -660,47 +662,65 @@ describe("Secret Rotations", async () => {
} }
}); });
test.concurrent.each(testCases)( testCases.forEach(({ skippable, dbCredentials, secretMapping, userCredentials, type, name }) => {
"Create secret rotation for $name", const shouldSkip = () => {
async ({ dbCredentials, secretMapping, userCredentials, type }) => { if (skippable) {
const appConnectionId = await createAppConnectionMap[type](dbCredentials); if (type === SecretRotationType.OracleDb) {
if (!process.env.E2E_TEST_ORACLE_DB_HOST) {
if (appConnectionId) { return true;
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) { return false;
throw new Error("Secret rotation failed to rotate after 60 attempts"); };
}
const finalSecretValue = await getSecretValue(secretMapping.password); if (shouldSkip()) {
expect(finalSecretValue).not.toBe(startSecretValue); test.skip(`Skipping Secret Rotation for ${type} (${name}) because E2E_TEST_ORACLE_DB_HOST is not set`);
}, } else {
{ test.concurrent(
timeout: 300_000 `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
}
);
} }
); });
}); });

View File

@@ -11,7 +11,7 @@ export default defineConfig({
E2E_TEST_ORACLE_DB_PASSWORD: process.env.E2E_TEST_ORACLE_DB_PASSWORD! E2E_TEST_ORACLE_DB_PASSWORD: process.env.E2E_TEST_ORACLE_DB_PASSWORD!
}, },
environment: "./e2e-test/vitest-environment-knex.ts", environment: "./e2e-test/vitest-environment-knex.ts",
include: ["./e2e-test/**/secret-rotations.spec.ts"], include: ["./e2e-test/**/*.spec.ts"],
poolOptions: { poolOptions: {
threads: { threads: {
singleThread: true, singleThread: true,