mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
final fixes
This commit is contained in:
6
.github/workflows/run-backend-tests.yml
vendored
6
.github/workflows/run-backend-tests.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user