Skip to content

Commit 3587a76

Browse files
committed
feat(database): add DATABASE_SSL environment variable for conditional SSL configuration
feat(tests): insert uploader-validator and validator-approver assignments in E2E tests
1 parent 4677235 commit 3587a76

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ jobs:
334334
env:
335335
NODE_ENV: production
336336
DATABASE_URL: postgresql://user:pass@localhost:5432/invoicescan_playwright
337+
DATABASE_SSL: 'false'
337338
REDIS_URL: redis://localhost:6379
338339
JWT_SECRET: ${{ secrets.CI_JWT_SECRET }}
339340
JWT_REFRESH_SECRET: ${{ secrets.CI_JWT_REFRESH_SECRET }}

packages/backend/src/infrastructure/db/database.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import { INVOICE_NOTE_REPOSITORY } from '../../domain/repositories/invoice-note.
3838
type: 'postgres' as const,
3939
url: process.env.DATABASE_URL,
4040
ssl:
41-
process.env.NODE_ENV === 'production'
41+
process.env.NODE_ENV === 'production' &&
42+
process.env.DATABASE_SSL !== 'false'
4243
? { rejectUnauthorized: false }
4344
: false,
4445
entities: [

packages/backend/test/helpers/seed-e2e.helper.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ export async function seedE2EData(
103103
[TEST_PROVIDER_ID, 'Generic (E2E)', 'generic', now],
104104
);
105105

106+
// Assignments: uploader→validator, uploaderB→validator, validator→approver
107+
// Required so the upload enforcement check passes in E2E tests
108+
const [adminUser, approverUser, validatorUser, uploaderUser, uploaderBUser] =
109+
users as typeof users;
110+
await ds.query(
111+
`INSERT INTO uploader_validator_assignments (id, uploader_id, validator_id, created_by, created_at) VALUES ($1, $2, $3, $4, $5)`,
112+
[randomUUID(), uploaderUser.id, validatorUser.id, adminUser.id, now],
113+
);
114+
await ds.query(
115+
`INSERT INTO uploader_validator_assignments (id, uploader_id, validator_id, created_by, created_at) VALUES ($1, $2, $3, $4, $5)`,
116+
[randomUUID(), uploaderBUser.id, validatorUser.id, adminUser.id, now],
117+
);
118+
await ds.query(
119+
`INSERT INTO validator_approver_assignments (id, validator_id, approver_id, created_by, created_at) VALUES ($1, $2, $3, $4, $5)`,
120+
[randomUUID(), validatorUser.id, approverUser.id, adminUser.id, now],
121+
);
122+
106123
const [admin, approver, validator, uploader, uploaderB] = users as [
107124
(typeof users)[0],
108125
(typeof users)[0],

0 commit comments

Comments
 (0)