feat(phase-34): resolve blocking tech debt — Redis, domain exceptions, indexes, CI
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Foundational changes required before any new feature work can begin. - 0.1 Redis infrastructure: add redis:7-alpine to docker-compose dev and prod, REDIS_URL config, singleton client in app/infrastructure/redis_client.py - 0.2 Token blacklist on Redis SEC-001: replace in-memory dict with Redis SETEX keyed by jti, auto-expiring TTL derived from token exp - 0.3 Database indexes SR-006: Alembic migration b019 with 5 composite indexes for scoring, MTTD/MTTR, remediation, and notification queries - 0.4 Domain exceptions TD-003: app/domain/exceptions.py with typed errors, error_handler middleware mapping them to HTTP, services decoupled from FastAPI - 0.5 Fix silenced exceptions TD-007: replace 4 bare except-pass blocks in test_workflow_service with logger.warning with exc_info - 0.6 CI pipeline TD-009: GitHub Actions workflow with Postgres and Redis service containers, ruff lint, pytest; ruff.toml for baseline config
This commit is contained in:
@@ -43,10 +43,19 @@ class _FakeSettings:
|
||||
SECRET_KEY = "test"
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES = 60
|
||||
REDIS_URL = "redis://localhost:6379/0"
|
||||
MINIO_ENDPOINT = "localhost:9000"
|
||||
MINIO_ACCESS_KEY = "test"
|
||||
MINIO_SECRET_KEY = "test"
|
||||
MINIO_BUCKET = "test"
|
||||
MINIO_SECURE = False
|
||||
MAX_RETEST_COUNT = 3
|
||||
CORS_ORIGINS = "http://localhost:3000"
|
||||
SCORING_WEIGHT_TESTS = 40
|
||||
SCORING_WEIGHT_DETECTION_RULES = 20
|
||||
SCORING_WEIGHT_D3FEND = 15
|
||||
SCORING_WEIGHT_FRESHNESS = 15
|
||||
SCORING_WEIGHT_PLATFORM_DIVERSITY = 10
|
||||
|
||||
|
||||
config_mod.settings = _FakeSettings()
|
||||
@@ -105,8 +114,8 @@ from app.services.test_workflow_service import (
|
||||
reopen_test,
|
||||
)
|
||||
|
||||
# We also need HTTPException for assertions
|
||||
from fastapi import HTTPException
|
||||
# We need the domain exceptions for assertions
|
||||
from app.domain.exceptions import InvalidTransitionError
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
@@ -175,9 +184,11 @@ def test_draft_to_validated_fails(mock_log):
|
||||
|
||||
try:
|
||||
transition_state(db, test, TestState.validated, user)
|
||||
assert False, "Should have raised HTTPException"
|
||||
except HTTPException as exc:
|
||||
assert exc.status_code == 400
|
||||
assert False, "Should have raised InvalidTransitionError"
|
||||
except InvalidTransitionError as exc:
|
||||
assert exc.code == "INVALID_TRANSITION"
|
||||
assert exc.current_state == "draft"
|
||||
assert exc.target_state == "validated"
|
||||
print(" [PASS] Transition draft -> validated correctly fails")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user