[BE-08] AlertWebhookApiController (webhook·내부 raise 수신)
작업 내용 (설계 의도)
변경 사항
규칙 엔진 webhook과 내부 raise(③⑧)를 수신하는 진입점을 작성한다. 근거 TDD: ../TDD.md §인터페이스 계약·§실패경로.
presentation/alerting/controller/AlertWebhookApiController.kt—POST /internal/alerts/grafana(Grafana 표준 페이로드, 헤더Authorization: Bearer <secret>— Grafana는 커스텀 헤더 발신 불가, INFRA-02 실측),POST /internal/alerts(내부 raise ③⑧, 헤더X-Alert-Token). 시크릿 불일치 시 401, Request→Command 변환 후 UseCase 호출, 즉시 202 Accepted(처리는 비동기).presentation/alerting/dto/request/GrafanaWebhookRequest.kt·RaiseAlertRequest.kt,dto/response/*.- Grafana 페이로드의
alerts[].labels(alertname/endpoint/source/severity/env)를 Command로 매핑. - 컨트롤러는 비즈니스 로직 없음 — 검증·변환·위임만.
롤백: alerting.enabled=false(BE-10 플래그) 시 202만 반환하고 처리 스킵.
의존
- BE-07 (ReceiveGrafanaAlertUseCase, RaiseAlertUseCase)
다이어그램
처리 흐름
sequenceDiagram participant GA as Grafana/③⑧ participant C as AlertWebhookApiController participant U as UseCase GA->>C: POST /internal/alerts[/grafana] (X-Alert-Token) C->>C: 시크릿 검증 C->>U: execute(command) C-->>GA: 202 Accepted
테스트 케이스
- 유효한 Authorization: Bearer + Grafana 페이로드는 202를 반환하고 ReceiveGrafanaAlertUseCase를 호출한다.
- grafana 경로 Bearer 토큰 누락/불일치, 내부 raise 경로 X-Alert-Token 누락/불일치 시 401을 반환하고 UseCase를 호출하지 않는다.
- 내부 raise(source=deployment)가 RaiseAlertUseCase로 매핑된다.
- Grafana labels(endpoint/source/severity/env)가 Command 필드로 정확히 변환된다.
- 잘못된 본문(깨진 JSON·무효 enum)은 400을 반환한다.