|
| 1 | +from sourceos_boot.adapter import BootAuthorization, DeviceClaim, SourceOSBootAdapter |
| 2 | + |
| 3 | + |
| 4 | +def test_adapter_builds_announce_fetch_and_evidence() -> None: |
| 5 | + adapter = SourceOSBootAdapter() |
| 6 | + claim = DeviceClaim( |
| 7 | + device_id="demo-device", |
| 8 | + public_key_fingerprint="sha256:demo", |
| 9 | + platform="apple-silicon", |
| 10 | + nonce="nonce-1", |
| 11 | + ) |
| 12 | + authorization = BootAuthorization( |
| 13 | + correlation_id="corr-1", |
| 14 | + boot_release_set_ref="boot-release-set/demo/0.1.0", |
| 15 | + token_id="token-1", |
| 16 | + expires_at="2026-04-26T01:00:00Z", |
| 17 | + ) |
| 18 | + |
| 19 | + announce = adapter.build_announce_payload(claim) |
| 20 | + fetch = adapter.build_fetch_request(authorization) |
| 21 | + evidence = adapter.build_evidence( |
| 22 | + claim=claim, |
| 23 | + authorization=authorization, |
| 24 | + selected_channel="recovery", |
| 25 | + boot_mode="installer", |
| 26 | + manifest_hash="sha256:abc", |
| 27 | + verification_result="pass", |
| 28 | + ) |
| 29 | + |
| 30 | + assert announce["kind"] == "SourceOSBootAnnounce" |
| 31 | + assert announce["claim"]["deviceId"] == "demo-device" |
| 32 | + assert fetch["authorization"]["correlationId"] == "corr-1" |
| 33 | + assert evidence.to_dict()["reports"] == [ |
| 34 | + "device-claim", |
| 35 | + "manifest-hash", |
| 36 | + "verification-result", |
| 37 | + "selected-channel", |
| 38 | + "boot-mode", |
| 39 | + ] |
0 commit comments