Files
missions/tests/Azaion.Missions.JwksMock/regen-cert.sh
T
Oleksandr Bezdieniezhnykh ccd85a09df
ci/woodpecker/push/build-arm Pipeline failed
[AZ-576] Add e2e test infrastructure (xUnit + jwks-mock + reporting)
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>
2026-05-15 06:57:40 +03:00

39 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
## Regenerate the jwks-mock TLS keypair + the trust-anchor copy mounted into
## consumers. Both files are committed test artifacts (the test runs are
## deterministic, so the cert is reused across CI runs unless the keypair is
## intentionally rotated).
##
## Outputs:
## tests/Azaion.Missions.JwksMock/tls/jwks-mock.key (private, 0600)
## tests/Azaion.Missions.JwksMock/tls/jwks-mock.crt (public, ECDSA P-256, 100y)
## tests/jwks-mock-ca.crt (copy of jwks-mock.crt)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TLS_DIR="$SCRIPT_DIR/tls"
TESTS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
mkdir -p "$TLS_DIR"
cd "$TLS_DIR"
openssl ecparam -name prime256v1 -genkey -noout -out jwks-mock.key
openssl req -new -x509 \
-key jwks-mock.key \
-out jwks-mock.crt \
-days 36500 \
-sha256 \
-subj "/CN=jwks-mock" \
-addext "subjectAltName=DNS:jwks-mock,DNS:localhost,IP:127.0.0.1" \
-addext "basicConstraints=critical,CA:TRUE" \
-addext "keyUsage=critical,digitalSignature,keyEncipherment,keyCertSign" \
-addext "extendedKeyUsage=serverAuth"
chmod 600 jwks-mock.key
cp jwks-mock.crt "$TESTS_DIR/jwks-mock-ca.crt"
echo "[regen-cert] regenerated:"
echo " $TLS_DIR/jwks-mock.key"
echo " $TLS_DIR/jwks-mock.crt"
echo " $TESTS_DIR/jwks-mock-ca.crt"