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,41 @@
|
||||
import pytest
|
||||
|
||||
from src.infrastructure.config.settings import Settings
|
||||
|
||||
|
||||
def test_production_rejects_placeholder_jwt_secret():
|
||||
with pytest.raises(ValueError, match="JWT_SECRET_KEY"):
|
||||
Settings(
|
||||
NODE_ENV="production",
|
||||
JWT_SECRET_KEY="change-me-in-production",
|
||||
_env_file=None,
|
||||
)
|
||||
|
||||
|
||||
def test_production_rejects_default_database_and_broker_credentials():
|
||||
with pytest.raises(ValueError, match="credentials"):
|
||||
Settings(
|
||||
NODE_ENV="production",
|
||||
JWT_SECRET_KEY="a-real-test-secret",
|
||||
DATABASE_URL="postgresql+asyncpg://pip:pip@localhost:5432/pip",
|
||||
RABBITMQ_URL="amqp://pip:pip@localhost:5672/pip",
|
||||
_env_file=None,
|
||||
)
|
||||
|
||||
|
||||
def test_production_rejects_wildcard_credentialed_cors():
|
||||
with pytest.raises(ValueError, match="CORS"):
|
||||
Settings(
|
||||
NODE_ENV="production",
|
||||
JWT_SECRET_KEY="a-real-test-secret",
|
||||
DATABASE_URL="postgresql+asyncpg://pip:real-password@db:5432/pip",
|
||||
RABBITMQ_URL="amqp://pip:real-password@rabbitmq:5672/pip",
|
||||
CORS_ORIGINS=["*"],
|
||||
CORS_ALLOW_CREDENTIALS=True,
|
||||
_env_file=None,
|
||||
)
|
||||
|
||||
|
||||
def test_development_keeps_local_defaults_usable():
|
||||
settings = Settings(_env_file=None)
|
||||
assert settings.NODE_ENV == "development"
|
||||
Reference in New Issue
Block a user