mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 09:51:14 +00:00
[AZ-353][AZ-354][AZ-356] Refactor 03 batch 2: harden API surface
AZ-353: Centralize 500 handling via GlobalExceptionHandler / AddProblemDetails / UseExceptionHandler. Sanitized ProblemDetails body carries a generic title, RFC9110 type link, and the request's TraceIdentifier as correlationId; the leaky exception message stays server-side in the ERR log entry. Strip per-endpoint try/catch (Exception) wrappers and the unused ILogger<Program> parameters they served. Preserve the typed ArgumentException catch in CreateRoute (AC-3). The handler maps BadHttpRequestException back to its framework-supplied StatusCode so model-binding / malformed-body failures stay 4xx instead of being promoted to 500. AZ-354: Extract CorsConfigurationValidator (pure static helpers) and wire it into Program.cs. Production with empty CorsConfig:AllowedOrigins and no CorsConfig:AllowAnyOrigin opt-in now throws InvalidOperationException at host startup. Development keeps the permissive default but logs a warning post-build. Adds the explicit CorsConfig:AllowAnyOrigin escape hatch. AZ-356: GetSatelliteTilesByMgrs and UploadImage now return Results.Problem(StatusCode 501) with ProblemDetails. Added .ProducesProblem(501) so swagger.json documents the not-implemented status. Tests: SatelliteProvider.Tests now references SatelliteProvider.Api (downward, idiomatic) so unit tests can reach the new helpers. +9 CorsConfigurationValidator unit tests, +3 GlobalExceptionHandler unit tests, +3 StubAndErrorContractTests integration tests (added to smoke + full suites). 58/58 unit + 5/5 smoke + 3/3 stub-contract pass. Code review verdict: PASS. Batch report: _docs/03_implementation/batch_08_report.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -67,6 +67,7 @@ class Program
|
||||
await BasicRouteTests.RunSimpleRouteTest(httpClient);
|
||||
await ExtendedRouteTests.RunRouteWithTilesZipTest(httpClient);
|
||||
await SecurityTests.RunAll(httpClient);
|
||||
await StubAndErrorContractTests.RunAll(httpClient);
|
||||
}
|
||||
|
||||
static async Task RunFullSuite(HttpClient httpClient)
|
||||
@@ -85,6 +86,7 @@ class Program
|
||||
await ExtendedRouteTests.RunExtendedRouteEast(httpClient);
|
||||
|
||||
await SecurityTests.RunAll(httpClient);
|
||||
await StubAndErrorContractTests.RunAll(httpClient);
|
||||
}
|
||||
|
||||
static async Task WaitForApiReady(HttpClient httpClient, int maxRetries = 30)
|
||||
|
||||
Reference in New Issue
Block a user