mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 13:41:14 +00:00
[AZ-223] [AZ-224] [AZ-225] [AZ-227] Add runtime gateways
Implement the first runtime component boundaries around the shared contracts so downstream batches can consume typed frame, MAVLink, tile, and FDR behavior with focused tests and batch evidence. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from tile_manager import LocalTileManager, TileManifestEntry
|
||||
|
||||
NOW = datetime(2026, 5, 3, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
def _entry(**overrides: object) -> TileManifestEntry:
|
||||
payload: dict[str, object] = {
|
||||
"tile_id": "tile-1",
|
||||
"chunk_id": "chunk-1",
|
||||
"crs": "EPSG:3857",
|
||||
"meters_per_pixel": 0.3,
|
||||
"capture_date": "2026-05-01",
|
||||
"expires_at": "2026-06-01T00:00:00+00:00",
|
||||
"content_hash": "sha256:tile",
|
||||
"expected_content_hash": "sha256:tile",
|
||||
"sidecar_hash": "sha256:sidecar",
|
||||
"expected_sidecar_hash": "sha256:sidecar",
|
||||
"signature_hash": "sig:trusted",
|
||||
"provenance": "suite-satellite-service",
|
||||
"footprint": {"min_lat": 49.0, "max_lat": 50.0},
|
||||
"descriptor_ref": "descriptors/chunk-1.vlad",
|
||||
}
|
||||
payload.update(overrides)
|
||||
return TileManifestEntry.model_validate(payload)
|
||||
|
||||
|
||||
def test_valid_cache_manifest_activates_trusted_records() -> None:
|
||||
# Arrange
|
||||
manager = LocalTileManager(trusted_signature_hashes={"sig:trusted"}, now=NOW)
|
||||
|
||||
# Act
|
||||
report = manager.validate_cache([_entry()])
|
||||
|
||||
# Assert
|
||||
assert report.activated is True
|
||||
assert report.decisions[0].accepted is True
|
||||
assert report.trusted_records[0].trust_level == "trusted"
|
||||
|
||||
|
||||
def test_tampered_or_stale_tile_is_rejected_with_auditable_reason() -> None:
|
||||
# Arrange
|
||||
manager = LocalTileManager(trusted_signature_hashes={"sig:trusted"}, now=NOW)
|
||||
tampered = _entry(tile_id="tile-tampered", content_hash="sha256:bad")
|
||||
stale = _entry(
|
||||
tile_id="tile-stale",
|
||||
chunk_id="chunk-stale",
|
||||
expires_at="2026-05-01T00:00:00+00:00",
|
||||
)
|
||||
|
||||
# Act
|
||||
report = manager.validate_cache([tampered, stale])
|
||||
|
||||
# Assert
|
||||
assert report.activated is False
|
||||
assert [decision.reason for decision in report.decisions] == [
|
||||
"content_hash_mismatch",
|
||||
"stale",
|
||||
]
|
||||
|
||||
|
||||
def test_tile_metadata_lookup_returns_record_or_explicit_rejection() -> None:
|
||||
# Arrange
|
||||
manager = LocalTileManager(trusted_signature_hashes={"sig:trusted"}, now=NOW)
|
||||
manager.validate_cache([_entry()])
|
||||
|
||||
# Act
|
||||
found = manager.get_tile_metadata("chunk-1")
|
||||
missing = manager.get_tile_metadata("missing")
|
||||
|
||||
# Assert
|
||||
assert found.found is True
|
||||
assert found.record is not None
|
||||
assert found.descriptor_ref == "descriptors/chunk-1.vlad"
|
||||
assert missing.found is False
|
||||
assert missing.error is not None
|
||||
assert missing.error.category == "validation"
|
||||
Reference in New Issue
Block a user