mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 18:31:14 +00:00
[AZ-794] [AZ-795] [AZ-796] Strict input validation + z/x/y rename
AZ-794: rename inventory wire fields tileZoom/tileX/tileY -> z/x/y to match the slippy-map URL convention. Contract bumped to v2.0.0. AZ-795: shared validation infrastructure -- FluentValidation + ValidationEndpointFilter + GlobalValidatorConfig (camelCase paths). GlobalExceptionHandler now converts JsonException (UnmappedMember + JsonRequired) into RFC 7807 ValidationProblemDetails. JSON layer hardened with UnmappedMemberHandling.Disallow + camelCase naming policy. New error-shape.md contract. AZ-796: InventoryRequestValidator covers 9 rules (XOR tiles vs locationHashes, cap 1000, z 0..22, x/y in slippy bounds, hash length/charset). 16 unit tests + 16 integration tests + a manual curl probe script. Adjacent fixes uncovered by the new strict layer: - IdempotentPostTests RoutePoint payload corrected to lat/lon (the DTO has used JsonPropertyName for ages; previously silently ignored under PascalCase fallback). - TileInventoryTests slippy x/y reduced to fit z=18 bounds. - docker-compose.yml host port for Postgres moved 5432 -> 5433 to avoid sibling-project conflict; appsettings.Development + README + AGENTS + architecture + containerization docs aligned. New coderule (suite + repo): API consumer-facing OpenAPI descriptions must not contain task IDs, contract filenames, or version-bump history -- internal change tracking belongs in commits/contract docs/changelogs. Existing offending descriptions in Program.cs cleaned up. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -60,10 +60,10 @@ public static class TileInventoryTests
|
||||
var seed = (int)(DateTime.UtcNow.Ticks % int.MaxValue);
|
||||
var random = new Random(seed);
|
||||
var presentCoords = Enumerable.Range(0, 12)
|
||||
.Select(i => new TileCoord { TileZoom = zoom, TileX = 600_000 + (seed % 1000) * 100 + i, TileY = 700_000 + (seed % 1000) * 100 + i })
|
||||
.Select(i => new TileCoord { Z = zoom, X = 50_000 + (seed % 1000) * 100 + i, Y = 60_000 + (seed % 1000) * 100 + i })
|
||||
.ToArray();
|
||||
var absentCoords = Enumerable.Range(0, 13)
|
||||
.Select(i => new TileCoord { TileZoom = zoom, TileX = 800_000 + (seed % 1000) * 100 + i, TileY = 900_000 + (seed % 1000) * 100 + i })
|
||||
.Select(i => new TileCoord { Z = zoom, X = 80_000 + (seed % 1000) * 100 + i, Y = 100_000 + (seed % 1000) * 100 + i })
|
||||
.ToArray();
|
||||
|
||||
// Pre-seed the present cells. Mix sources / flights to exercise the
|
||||
@@ -74,7 +74,7 @@ public static class TileInventoryTests
|
||||
for (var i = 0; i < presentCoords.Length; i++)
|
||||
{
|
||||
var coord = presentCoords[i];
|
||||
var locationHash = Uuidv5.LocationHashForTile(coord.TileZoom, coord.TileX, coord.TileY);
|
||||
var locationHash = Uuidv5.LocationHashForTile(coord.Z, coord.X, coord.Y);
|
||||
|
||||
// Seed at least one google_maps row for every present cell.
|
||||
var googleId = Guid.NewGuid();
|
||||
@@ -119,7 +119,7 @@ public static class TileInventoryTests
|
||||
}
|
||||
|
||||
var presentHashes = presentCoords
|
||||
.Select(c => Uuidv5.LocationHashForTile(c.TileZoom, c.TileX, c.TileY))
|
||||
.Select(c => Uuidv5.LocationHashForTile(c.Z, c.X, c.Y))
|
||||
.ToHashSet();
|
||||
|
||||
for (var i = 0; i < allCoords.Length; i++)
|
||||
@@ -127,14 +127,14 @@ public static class TileInventoryTests
|
||||
var requestedCoord = allCoords[i];
|
||||
var entry = body.Results[i];
|
||||
|
||||
if (entry.TileZoom != requestedCoord.TileZoom || entry.TileX != requestedCoord.TileX || entry.TileY != requestedCoord.TileY)
|
||||
if (entry.Z != requestedCoord.Z || entry.X != requestedCoord.X || entry.Y != requestedCoord.Y)
|
||||
{
|
||||
throw new Exception(
|
||||
$"AC-1: entry {i} coords mismatch — request was ({requestedCoord.TileZoom},{requestedCoord.TileX},{requestedCoord.TileY}), " +
|
||||
$"response is ({entry.TileZoom},{entry.TileX},{entry.TileY})");
|
||||
$"AC-1: entry {i} coords mismatch — request was ({requestedCoord.Z},{requestedCoord.X},{requestedCoord.Y}), " +
|
||||
$"response is ({entry.Z},{entry.X},{entry.Y})");
|
||||
}
|
||||
|
||||
var expectedHash = Uuidv5.LocationHashForTile(requestedCoord.TileZoom, requestedCoord.TileX, requestedCoord.TileY);
|
||||
var expectedHash = Uuidv5.LocationHashForTile(requestedCoord.Z, requestedCoord.X, requestedCoord.Y);
|
||||
if (entry.LocationHash != expectedHash)
|
||||
{
|
||||
throw new Exception($"AC-1: entry {i} location_hash mismatch — expected {expectedHash}, got {entry.LocationHash}");
|
||||
@@ -195,11 +195,11 @@ public static class TileInventoryTests
|
||||
var seed = (int)(DateTime.UtcNow.Ticks % int.MaxValue);
|
||||
var coord = new TileCoord
|
||||
{
|
||||
TileZoom = zoom,
|
||||
TileX = 1_200_000 + (seed % 1000),
|
||||
TileY = 1_300_000 + (seed % 1000)
|
||||
Z = zoom,
|
||||
X = 130_000 + (seed % 1000),
|
||||
Y = 150_000 + (seed % 1000)
|
||||
};
|
||||
var locationHash = Uuidv5.LocationHashForTile(coord.TileZoom, coord.TileX, coord.TileY);
|
||||
var locationHash = Uuidv5.LocationHashForTile(coord.Z, coord.X, coord.Y);
|
||||
|
||||
var googleId = Guid.NewGuid();
|
||||
var googleCapturedAt = DateTime.UtcNow.AddHours(-2);
|
||||
@@ -252,7 +252,7 @@ public static class TileInventoryTests
|
||||
// Arrange
|
||||
var request = new TileInventoryRequest
|
||||
{
|
||||
Tiles = new[] { new TileCoord { TileZoom = 18, TileX = 1, TileY = 1 } },
|
||||
Tiles = new[] { new TileCoord { Z = 18, X = 1, Y = 1 } },
|
||||
LocationHashes = new[] { Guid.NewGuid() }
|
||||
};
|
||||
|
||||
@@ -309,7 +309,7 @@ public static class TileInventoryTests
|
||||
using var anonymous = new HttpClient { BaseAddress = baseAddress, Timeout = TimeSpan.FromSeconds(30) };
|
||||
var request = new TileInventoryRequest
|
||||
{
|
||||
Tiles = new[] { new TileCoord { TileZoom = 18, TileX = 1, TileY = 1 } }
|
||||
Tiles = new[] { new TileCoord { Z = 18, X = 1, Y = 1 } }
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -361,7 +361,7 @@ public static class TileInventoryTests
|
||||
{
|
||||
var x = 100_000 + random.Next(0, 65_536);
|
||||
var y = 100_000 + random.Next(0, 65_536);
|
||||
coords[i] = new TileCoord { TileZoom = zoom, TileX = x, TileY = y };
|
||||
coords[i] = new TileCoord { Z = zoom, X = x, Y = y };
|
||||
var hash = Uuidv5.LocationHashForTile(zoom, x, y);
|
||||
idP.Value = Guid.NewGuid();
|
||||
zP.Value = zoom;
|
||||
@@ -429,12 +429,12 @@ public static class TileInventoryTests
|
||||
VALUES (@id, @z, @x, @y, @lat, @lon, 200.0, 256, 'jpg', @fp, @src, @t, @t, @t, @flight, @loc)
|
||||
ON CONFLICT DO NOTHING;", conn);
|
||||
cmd.Parameters.AddWithValue("id", id);
|
||||
cmd.Parameters.AddWithValue("z", coord.TileZoom);
|
||||
cmd.Parameters.AddWithValue("x", coord.TileX);
|
||||
cmd.Parameters.AddWithValue("y", coord.TileY);
|
||||
cmd.Parameters.AddWithValue("lat", 60.0 + coord.TileX * 1e-9);
|
||||
cmd.Parameters.AddWithValue("lon", 30.0 + coord.TileY * 1e-9);
|
||||
cmd.Parameters.AddWithValue("fp", $"tiles/seed/{coord.TileZoom}/{coord.TileX}/{coord.TileY}.jpg");
|
||||
cmd.Parameters.AddWithValue("z", coord.Z);
|
||||
cmd.Parameters.AddWithValue("x", coord.X);
|
||||
cmd.Parameters.AddWithValue("y", coord.Y);
|
||||
cmd.Parameters.AddWithValue("lat", 60.0 + coord.X * 1e-9);
|
||||
cmd.Parameters.AddWithValue("lon", 30.0 + coord.Y * 1e-9);
|
||||
cmd.Parameters.AddWithValue("fp", $"tiles/seed/{coord.Z}/{coord.X}/{coord.Y}.jpg");
|
||||
cmd.Parameters.AddWithValue("src", source);
|
||||
// schema column is TIMESTAMP (no tz); Npgsql v6+ refuses to bind a
|
||||
// Kind=Utc DateTime into a plain timestamp column. Callers pass UTC
|
||||
|
||||
Reference in New Issue
Block a user