Files
FarmaFinder/apps/backend/__tests__/required-env.test.js
T
Antoni Nuñez Romeu 849763896d
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Frontend Tests (push) Successful in 2m12s
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
Run Tests on Branches / Parapharmacy API Tests (push) Successful in 2m2s
Run Tests on Branches / PIP Platform Tests (push) Has been skipped
Run Tests on Branches / Backend Tests (push) Successful in 2m8s
security: harden production configuration and routes
2026-07-22 17:24:54 +02:00

31 lines
1.1 KiB
JavaScript

import { describe, expect, test } from '@jest/globals'
import { validateProductionEnv } from '../src/config/required-env.js'
describe('validateProductionEnv', () => {
test('rejects a missing production session secret', () => {
expect(() => validateProductionEnv({
NODE_ENV: 'production',
CORS_ORIGIN: 'https://app.example.com',
PG_URL: 'postgres://app:password@db/app',
})).toThrow(/SESSION_SECRET/i)
})
test('rejects placeholder production configuration', () => {
expect(() => validateProductionEnv({
NODE_ENV: 'production',
SESSION_SECRET: 'farma-clic-secret-key-change-in-production',
CORS_ORIGIN: 'http://localhost:3000',
PG_URL: 'postgres://app:password@db/app',
})).toThrow(/placeholder|production/i)
})
test('accepts complete non-placeholder production configuration', () => {
expect(() => validateProductionEnv({
NODE_ENV: 'production',
SESSION_SECRET: 'a-test-only-long-session-secret',
CORS_ORIGIN: 'https://app.example.com',
PG_URL: 'postgres://app:password@db/app',
})).not.toThrow()
})
})