mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 10:01: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>
99 lines
3.6 KiB
C#
99 lines
3.6 KiB
C#
using System.Net.Http.Json;
|
|
using System.Text.Json;
|
|
|
|
namespace SatelliteProvider.IntegrationTests;
|
|
|
|
public static class TileTests
|
|
{
|
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true
|
|
};
|
|
|
|
public static async Task RunGetTileByLatLonTest(HttpClient httpClient)
|
|
{
|
|
Console.WriteLine("Test: Get Tile by Lat/Lon at Coordinates 47.461747, 37.647063");
|
|
Console.WriteLine("------------------------------------------------------------------");
|
|
|
|
const double latitude = 47.461747;
|
|
const double longitude = 37.647063;
|
|
const int zoomLevel = 18;
|
|
|
|
Console.WriteLine($"Getting tile at coordinates ({latitude}, {longitude}) with zoom level {zoomLevel}");
|
|
|
|
var response = await httpClient.GetAsync($"/api/satellite/tiles/latlon?lat={latitude}&lon={longitude}&zoom={zoomLevel}");
|
|
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
var errorContent = await response.Content.ReadAsStringAsync();
|
|
throw new Exception($"API returned error status {response.StatusCode}: {errorContent}");
|
|
}
|
|
|
|
var tile = await response.Content.ReadFromJsonAsync<DownloadTileResponse>(JsonOptions);
|
|
|
|
if (tile == null)
|
|
{
|
|
throw new Exception("No tile data returned from API");
|
|
}
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("Tile Details:");
|
|
Console.WriteLine($" ID: {tile.Id}");
|
|
Console.WriteLine($" Zoom Level: {tile.ZoomLevel}");
|
|
Console.WriteLine($" Latitude: {tile.Latitude}");
|
|
Console.WriteLine($" Longitude: {tile.Longitude}");
|
|
Console.WriteLine($" Tile Size (meters): {tile.TileSizeMeters:F2}");
|
|
Console.WriteLine($" Tile Size (pixels): {tile.TileSizePixels}");
|
|
Console.WriteLine($" Image Type: {tile.ImageType}");
|
|
Console.WriteLine($" File Path: {tile.FilePath}");
|
|
Console.WriteLine($" Created At: {tile.CreatedAt:yyyy-MM-dd HH:mm:ss}");
|
|
|
|
if (tile.ZoomLevel != zoomLevel)
|
|
{
|
|
throw new Exception($"Expected zoom level {zoomLevel}, got {tile.ZoomLevel}");
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(tile.FilePath))
|
|
{
|
|
throw new Exception("File path is empty");
|
|
}
|
|
|
|
if (tile.TileSizePixels != 256)
|
|
{
|
|
throw new Exception($"Expected tile size 256 pixels, got {tile.TileSizePixels}");
|
|
}
|
|
|
|
if (tile.ImageType != "jpg")
|
|
{
|
|
throw new Exception($"Expected image type 'jpg', got '{tile.ImageType}'");
|
|
}
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("✓ Tile retrieved successfully");
|
|
Console.WriteLine("✓ Tile metadata validated");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Testing tile reuse (getting same tile again)...");
|
|
|
|
var response2 = await httpClient.GetAsync($"/api/satellite/tiles/latlon?lat={latitude}&lon={longitude}&zoom={zoomLevel}");
|
|
|
|
if (!response2.IsSuccessStatusCode)
|
|
{
|
|
var errorContent = await response2.Content.ReadAsStringAsync();
|
|
throw new Exception($"Second request failed with status {response2.StatusCode}: {errorContent}");
|
|
}
|
|
|
|
var tile2 = await response2.Content.ReadFromJsonAsync<DownloadTileResponse>(JsonOptions);
|
|
|
|
if (tile2 == null)
|
|
{
|
|
throw new Exception("No tile data returned from second request");
|
|
}
|
|
|
|
Console.WriteLine($"✓ Second request returned tile ID: {tile2.Id}");
|
|
Console.WriteLine("✓ Tile reuse functionality working");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Get Tile by Lat/Lon Test: PASSED");
|
|
}
|
|
}
|
|
|