[AZ-576] Add e2e test infrastructure (xUnit + jwks-mock + reporting)
ci/woodpecker/push/build-arm Pipeline failed

Scaffold the blackbox test project the rest of epic AZ-575 (AZ-577..AZ-586)
will build on. Two new csprojs under tests/, plus the TLS materials and
TRX->CSV reporting hand-off the existing docker-compose.test.yml already
calls for.

JWKS mock (tests/Azaion.Missions.JwksMock/):
- ASP.NET Core minimal API on .NET 10, no NuGet deps; JWS is hand-rolled
  to keep the surface tight and avoid version drift with the SUT
- KeyStore with one in-memory ECDSA P-256 keypair + retired-key grace
  window for NFT-RES-07 / NFT-SEC-11 rotation observability
- Endpoints: GET /.well-known/jwks.json, POST /sign, POST /rotate-key
- Mock-only alg_override / kid_override switches drive NFT-SEC-09/10/11
- TLS keypair committed under tls/; tests/jwks-mock-ca.crt is a copy
  mounted into both missions and e2e-consumer per docker-compose.test.yml

E2E consumer (tests/Azaion.Missions.E2E.Tests/):
- xUnit 2.9.2 + Bogus 35.6.1 + Npgsql 10.0.2 + Xunit.SkippableFact 1.4.13
- TestBase / TokenMinter scaffolding for downstream tasks
- Fixtures/ for DbReset, DbSeed, ComposeRestart, JwksRotate, JwksMockReverse
- Helpers/ for DbAssertions (side-channel), HttpAssertions, FixtureSql
- 8 Tests/<category>/Sanity.cs discovery smoke tests (AC-3)
- Tests/InfrastructureSanity.cs SkippableFacts for AC-1/2/5/6
- Tests/AaaPatternEnforcement.cs greps source files for AC-7
- Tests/Reporting/TrxToCsvPostProcessorTests.cs covers AC-4
- Reporting/TrxToCsvPostProcessor.cs handles VSTest TRX -> environment.md
  CSV; xUnit traits are not propagated by the TRX logger so the converter
  reflects them out of the test DLL via GetCustomAttributesData
- Reporting.Cli/ is a separate console csproj that links the converter
  source files (test project excludes Reporting.Cli/** from compile)
- Dockerfile + entrypoint.sh wire dotnet test -> trx -> csv inside the
  e2e-consumer container the compose file already references

Local verification: 13 pass, 3 skip (with explicit reasons), 0 fail.
End-to-end TRX->CSV manually verified against environment.md header spec.
Docker stack build is handed off to autodev Step 7 (test-run skill).

Reports under _docs/03_implementation/.
AZ-576 task spec moved to _docs/tasks/done/.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-15 06:57:40 +03:00
parent b0c7132889
commit ccd85a09df
48 changed files with 2030 additions and 4 deletions
@@ -0,0 +1,84 @@
# Batch Report
**Batch**: 1
**Tasks**: AZ-576 (test_infrastructure)
**Date**: 2026-05-15
**Run mode**: Test implementation (existing-code Step 6)
## Task Results
| Task | Status | Files Modified | Tests | AC Coverage | Issues |
|------|--------|----------------|-------|-------------|--------|
| AZ-576_test_infrastructure | Done | 31 added | 13 pass / 3 skip / 0 fail | 7/7 ACs covered | 2 Low (see review) |
## AC Test Coverage: All 7 covered
- AC-1, AC-2, AC-5, AC-6 — covered by `Tests/InfrastructureSanity.cs` (3 SkippableFacts; skip when stack env not reachable)
- AC-3 — 8 `Tests/<folder>/Sanity.cs` discovery tests
- AC-4 — 4 `Tests/Reporting/TrxToCsvPostProcessorTests.cs` regression tests + manual end-to-end verification (TRX produced by `dotnet test` was converted to CSV with the documented 7-column header and 9 rows)
- AC-7 — `Tests/AaaPatternEnforcement.cs` regex enforcement passing across all 16 test methods
## Code Review Verdict: PASS_WITH_WARNINGS
Report: `_docs/03_implementation/reviews/batch_01_review.md`. 0 Critical, 0 High, 0 Medium, 2 Low.
## Auto-Fix Attempts: 0
## Stuck Agents: None
## Files Created (31)
### `tests/Azaion.Missions.JwksMock/` — JWKS mock service (12 files)
- `Azaion.Missions.JwksMock.csproj` (.NET 10 web project; no NuGet deps — JWS is hand-rolled)
- `appsettings.json`
- `Program.cs` (Kestrel HTTPS bind, DI wiring)
- `Dockerfile` (multi-arch via `--platform=$BUILDPLATFORM`)
- `Endpoints/JwksEndpoint.cs``GET /.well-known/jwks.json`
- `Endpoints/SignEndpoint.cs``POST /sign`
- `Endpoints/RotateKeyEndpoint.cs``POST /rotate-key`
- `Services/KeyStore.cs` — in-memory ECDSA P-256 keypair + retired-key grace window
- `Services/TokenSigner.cs` — JWS-compact ES256 with mock-only alg / kid overrides
- `Services/Base64Url.cs`
- `tls/jwks-mock.crt` + `tls/jwks-mock.key` (committed test artifacts; ECDSA P-256, 100 y, SAN=`DNS:jwks-mock,DNS:localhost,IP:127.0.0.1`)
- `regen-cert.sh` (regenerates both copies of the cert deterministically)
### `tests/Azaion.Missions.E2E.Tests/` — xUnit consumer (18 files)
- `Azaion.Missions.E2E.Tests.csproj` (xunit 2.9.2, runner.visualstudio 2.8.2, Bogus 35.6.1, Npgsql 10.0.2, Xunit.SkippableFact 1.4.13, Microsoft.NET.Test.Sdk 17.12.0)
- `Dockerfile` + `entrypoint.sh` (runs dotnet test → trx, then trx→csv via Reporting.Cli)
- `xunit.runner.json` (parallelization disabled to keep blackbox runs deterministic)
- `TestBase.cs`, `TokenMinter.cs`, `TestEnvironment.cs`
- `Fixtures/{DbReset, DbSeed, ComposeRestart, JwksRotate, JwksMockReverse}Fixture.cs`
- `Helpers/{DbAssertions, HttpAssertions, FixtureSql}.cs`
- `Reporting/{TrxToCsvPostProcessor, ResultRow}.cs`
- `Reporting.Cli/Program.cs` + `Reporting.Cli.csproj` (separate console app linking the post-processor source files)
- `Tests/{Vehicles, Missions, Waypoints, Health, Security, Resilience, ResourceLimits, Performance}/Sanity.cs` (8 discovery smoke tests)
- `Tests/InfrastructureSanity.cs` (3 SkippableFact integration tests for AC-1/2/5/6)
- `Tests/AaaPatternEnforcement.cs` (AC-7 regex enforcement)
- `Tests/Reporting/TrxToCsvPostProcessorTests.cs` (AC-4 regression suite)
### `tests/jwks-mock-ca.crt`
Copy of the JwksMock TLS cert; mounted into both `missions` and `e2e-consumer` per `docker-compose.test.yml`.
## Local Verification
`dotnet test -c Release` — 13 pass, 3 skip (with explicit reasons), 0 fail.
End-to-end TRX→CSV manually verified:
```
TestId,TestName,Category,Traces,ExecutionTimeMs,Result,ErrorMessage
... 16 rows ...
```
Category and Traces columns populate correctly when the `--testAssemblyPath` argument is supplied to the converter (xUnit 2.x `[Trait]` attributes are not propagated by the VSTest TRX logger, so the converter reflects them out of the test DLL via `MetadataLoadContext`-style `GetCustomAttributesData`).
## Docker Stack Validation
Not run as part of this batch — the documented hand-off is to autodev Step 7 (`test-run/SKILL.md`), which owns the `docker compose -f docker-compose.test.yml up --build --abort-on-container-exit e2e-consumer` gate. AC-1, AC-2, AC-5, AC-6 light up as `pass` (rather than `skip`) once that gate runs.
## Next Batch
Batch 2: AZ-577..AZ-586 (10 tasks, fan-out from AZ-576). The dependencies table flagged this as a parallel-friendly batch within a single xUnit assembly. The implement skill will sequence them in topological order across one or more batches respecting the default 4-task batch cap.