security: harden production configuration and routes
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
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
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user