Skip to content

Commit f802d3b

Browse files
committed
security: remove hardcoded passwords from test configuration
Removed hardcoded authentication credentials from docker-compose.test.yml in response to GitGuardian security warning. Test services now run without authentication for local testing only. ## Changes ### docker-compose.test.yml - Removed MongoDB username/password (test_admin/test_password) - Removed Redis password (test_redis_password) - Simplified AWS credentials to "test/test" placeholders - Added security warning header to file - Added comments clarifying local-only usage ### tests/conftest.py - Updated S3 client defaults to use "test/test" credentials - Added security comment for LocalStack credentials ### tests/integration/README.md - Updated environment variable examples to remove passwords - Changed MongoDB URI from authenticated to non-authenticated - Changed Redis URL to remove password - Updated AWS credentials to simpler "test/test" placeholders - Added security notice warning against production use - Updated Redis troubleshooting command to remove password flag ## Security Rationale For LOCAL TESTING ONLY: - No real data or secrets involved - Services bind to localhost only - Simplifies local development workflow - Reduces false positives from security scanners - All credentials are placeholders that never touch real services **Production deployments must use proper authentication and secrets management.** Fixes GitGuardian security warning
1 parent 32106b9 commit f802d3b

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

apps/backend/docker-compose.test.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
version: '3.8'
22

3+
# ⚠️ SECURITY NOTICE ⚠️
4+
# This Docker Compose file is for LOCAL TESTING ONLY
5+
# All services run WITHOUT authentication for convenience
6+
# DO NOT use these configurations in production or cloud environments
7+
# DO NOT expose these ports to the internet
8+
39
services:
410
# MongoDB for integration testing
11+
# Note: Running without authentication for local testing only
12+
# DO NOT use this configuration in production
513
mongodb-test:
614
image: mongo:7.0
715
container_name: narrative-mongodb-test
816
ports:
917
- "27018:27017" # Different port to avoid conflicts with dev MongoDB
1018
environment:
11-
MONGO_INITDB_ROOT_USERNAME: test_admin
12-
MONGO_INITDB_ROOT_PASSWORD: test_password
1319
MONGO_INITDB_DATABASE: narrative_test
1420
volumes:
1521
- mongodb_test_data:/data/db
@@ -22,12 +28,14 @@ services:
2228
- test-network
2329

2430
# Redis for background job testing
31+
# Note: Running without authentication for local testing only
32+
# DO NOT use this configuration in production
2533
redis-test:
2634
image: redis:7-alpine
2735
container_name: narrative-redis-test
2836
ports:
2937
- "6380:6379" # Different port to avoid conflicts with dev Redis
30-
command: redis-server --appendonly yes --requirepass test_redis_password
38+
command: redis-server --appendonly yes
3139
volumes:
3240
- redis_test_data:/data
3341
healthcheck:
@@ -38,7 +46,9 @@ services:
3846
networks:
3947
- test-network
4048

41-
# LocalStack for S3 testing (MinIO as alternative)
49+
# LocalStack for S3 testing
50+
# Note: LocalStack uses fake AWS credentials for local testing only
51+
# These credentials never touch real AWS services
4252
localstack:
4353
image: localstack/localstack:latest
4454
container_name: narrative-localstack-test
@@ -50,8 +60,9 @@ services:
5060
DEBUG: 1
5161
DATA_DIR: /tmp/localstack/data
5262
AWS_DEFAULT_REGION: us-east-1
53-
AWS_ACCESS_KEY_ID: test_access_key
54-
AWS_SECRET_ACCESS_KEY: test_secret_key
63+
# LocalStack accepts any credentials - these are placeholders for local testing
64+
AWS_ACCESS_KEY_ID: test
65+
AWS_SECRET_ACCESS_KEY: test
5566
volumes:
5667
- localstack_data:/tmp/localstack
5768
- /var/run/docker.sock:/var/run/docker.sock

apps/backend/tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,10 @@ def s3_client(request):
284284
from botocore.config import Config
285285

286286
# Use LocalStack by default for testing
287+
# Note: LocalStack accepts any credentials - these are local-only placeholders
287288
endpoint_url = os.getenv("S3_ENDPOINT_URL", "http://localhost:4566")
288-
aws_access_key = os.getenv("AWS_ACCESS_KEY_ID", "test_access_key")
289-
aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY", "test_secret_key")
289+
aws_access_key = os.getenv("AWS_ACCESS_KEY_ID", "test")
290+
aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY", "test")
290291
region = os.getenv("AWS_DEFAULT_REGION", "us-east-1")
291292

292293
try:

apps/backend/tests/integration/README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,30 @@ If you prefer not to use Docker, ensure you have:
3333

3434
## Environment Variables
3535

36-
Configure in `.env` file:
36+
Configure in `.env` file (or use defaults):
3737

3838
```bash
39-
# MongoDB Test Configuration
40-
TEST_MONGODB_URI=mongodb://test_admin:test_password@localhost:27018
39+
# MongoDB Test Configuration (no authentication for local testing)
40+
TEST_MONGODB_URI=mongodb://localhost:27018
4141
TEST_MONGODB_DB=narrative_test
4242

43-
# Redis Test Configuration
44-
TEST_REDIS_URL=redis://:test_redis_password@localhost:6380/0
43+
# Redis Test Configuration (no authentication for local testing)
44+
TEST_REDIS_URL=redis://localhost:6380/0
4545

46-
# S3 Test Configuration (LocalStack)
47-
AWS_ACCESS_KEY_ID=test_access_key
48-
AWS_SECRET_ACCESS_KEY=test_secret_key
46+
# S3 Test Configuration (LocalStack with placeholder credentials)
47+
# Note: LocalStack accepts any credentials - these never touch real AWS
48+
AWS_ACCESS_KEY_ID=test
49+
AWS_SECRET_ACCESS_KEY=test
4950
AWS_DEFAULT_REGION=us-east-1
5051
S3_ENDPOINT_URL=http://localhost:4566
5152

52-
# OpenAI Test Configuration
53+
# OpenAI Test Configuration (mocked, not used)
5354
OPENAI_API_KEY=sk-test-key-for-mocking
5455
```
5556

57+
**Security Note**: The test services run WITHOUT authentication for local testing only.
58+
DO NOT use these configurations in production environments.
59+
5660
## Running Tests
5761

5862
### Run all integration tests:
@@ -183,8 +187,8 @@ docker logs narrative-mongodb-test
183187
# Check if Redis is running
184188
docker ps | grep redis
185189

186-
# Test Redis connection
187-
redis-cli -p 6380 -a test_redis_password ping
190+
# Test Redis connection (no password required for test instance)
191+
redis-cli -p 6380 ping
188192
```
189193

190194
### LocalStack/S3 Issues

0 commit comments

Comments
 (0)