mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 18:41:14 +00:00
34ee1e0b83
AZ-808: FluentValidation for POST /api/satellite/request - RegionRequestValidator: id non-empty, lat/lon/sizeMeters/zoomLevel ranges - RequestRegionRequest: [JsonRequired] on every property, no implicit defaults - Wired via .WithValidation<RequestRegionRequest>() in MapPost chain - Unit + integration tests + curl probe script - New contract: contracts/api/region-request.md v1.0.0 AZ-811: FluentValidation + envelope filter for GET /api/satellite/tiles/latlon - GetTileByLatLonQuery: nullable record (double?/int?) so the minimal-API binder never short-circuits with BadHttpRequestException before filters - GetTileByLatLonQueryValidator: Cascade(Stop) + NotNull + InclusiveBetween per param; missing surfaces as `\`<name>\` is required.` - RejectUnknownQueryParamsEndpointFilter: reusable IEndpointFilter that rejects any query key outside the allowed set with errors[<key>] map; catches legacy `?Latitude=` typos and hostile probes (`?debug=1&admin=1`) - Handler: [AsParameters] GetTileByLatLonQuery + .Value deref post-validator - Unit (validator + filter) + integration tests + curl probe script - New contract: contracts/api/tile-latlon.md v1.0.0 Shared hygiene - Promote AssertErrorsContainsMention from per-test-file private helpers to ProblemDetailsAssertions (closes batch-1 Low-severity DRY warning) - Sync Swagger param descriptions, README, blackbox/security/perf scripts, uuidv5 doc with the new lat/lon/zoom query-param names Docs - system-flows.md F1/F2 reference the new contracts + validation layers - modules/api_program.md adds Api/Validators + Api/DTOs sections - _autodev_state.md: batch 2 of 4 complete; next batch = AZ-809 All smoke tests green (mode=smoke, exit 0). AZ-808 + AZ-811 transitioned to In Testing on Jira. Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
3.2 KiB
C#
75 lines
3.2 KiB
C#
using System.Text;
|
|
|
|
namespace SatelliteProvider.IntegrationTests;
|
|
|
|
// AZ-812: wire-format rename for POST /api/satellite/request.
|
|
// `RequestRegionRequest` now uses `lat`/`lon` (OSM convention) on the wire,
|
|
// replacing the previous verbose `latitude`/`longitude`. The strict-parsing
|
|
// infrastructure landed by AZ-795 (UnmappedMemberHandling.Disallow +
|
|
// GlobalExceptionHandler) means the old wire format must now be rejected
|
|
// explicitly, not silently coerced. AC-4 from the AZ-812 task spec.
|
|
public static class RegionFieldRenameTests
|
|
{
|
|
private const string RegionPath = "/api/satellite/request";
|
|
|
|
public static async Task RunAll(HttpClient httpClient)
|
|
{
|
|
RouteTestHelpers.PrintTestHeader("Test: Region endpoint OSM field-name rename (AZ-812)");
|
|
|
|
await NewLatLonFormat_Returns200(httpClient);
|
|
await OldLatitudeLongitudeFormat_Returns400(httpClient);
|
|
|
|
Console.WriteLine("✓ Region field-rename tests: PASSED");
|
|
}
|
|
|
|
private static async Task NewLatLonFormat_Returns200(HttpClient httpClient)
|
|
{
|
|
Console.WriteLine();
|
|
Console.WriteLine("AZ-812 AC-4 (positive): new {lat,lon} wire format → HTTP 200");
|
|
|
|
// Arrange
|
|
var regionId = Guid.NewGuid();
|
|
var body = $"{{\"id\":\"{regionId}\",\"lat\":47.461747,\"lon\":37.647063,\"sizeMeters\":200,\"zoomLevel\":18,\"stitchTiles\":false}}";
|
|
|
|
// Act
|
|
var response = await PostJsonAsync(httpClient, body);
|
|
var status = (int)response.StatusCode;
|
|
var responseBody = await response.Content.ReadAsStringAsync();
|
|
|
|
// Assert
|
|
if (status != 200)
|
|
{
|
|
throw new Exception($"AZ-812 AC-4 positive: expected HTTP 200 for {{lat,lon}} body, got {status}. Body: {responseBody}");
|
|
}
|
|
|
|
Console.WriteLine(" ✓ {lat,lon} body accepted with HTTP 200");
|
|
}
|
|
|
|
private static async Task OldLatitudeLongitudeFormat_Returns400(HttpClient httpClient)
|
|
{
|
|
Console.WriteLine();
|
|
Console.WriteLine("AZ-812 AC-4 (negative): legacy {latitude,longitude} wire format → HTTP 400 (UnmappedMemberHandling.Disallow)");
|
|
|
|
// Arrange — exact pre-AZ-812 wire format; must now fail explicitly instead
|
|
// of silently mapping to the renamed Lat/Lon properties.
|
|
var regionId = Guid.NewGuid();
|
|
var body = $"{{\"id\":\"{regionId}\",\"latitude\":47.461747,\"longitude\":37.647063,\"sizeMeters\":200,\"zoomLevel\":18,\"stitchTiles\":false}}";
|
|
|
|
// Act
|
|
var response = await PostJsonAsync(httpClient, body);
|
|
var problem = await ProblemDetailsAssertions.ReadProblemDetailsAsync(response, "AZ-812 legacy field names");
|
|
|
|
// Assert
|
|
ProblemDetailsAssertions.AssertValidationProblem(problem, expectedStatus: 400, label: "AZ-812 legacy field names");
|
|
ProblemDetailsAssertions.AssertErrorsContainsMention(problem, expectedMention: "latitude", label: "AZ-812 legacy field names");
|
|
|
|
Console.WriteLine(" ✓ Legacy {latitude,longitude} body rejected with HTTP 400; errors map names the unknown field");
|
|
}
|
|
|
|
private static Task<HttpResponseMessage> PostJsonAsync(HttpClient httpClient, string body)
|
|
{
|
|
var content = new StringContent(body, Encoding.UTF8, "application/json");
|
|
return httpClient.PostAsync(RegionPath, content);
|
|
}
|
|
}
|