test: harden result annotation reconciliation

This commit is contained in:
Josh Creek
2026-08-31 20:34:50 +01:00
parent 864e4e8aaf
commit 637b522486
3 changed files with 36 additions and 1 deletions
+17
View File
@@ -61,6 +61,23 @@ func TestConflictingResultIsInertAndIntegritySuppressesRating(t *testing.T) {
}
}
func TestAnnotationReconcileChecksSignatureAndDigest(t *testing.T) {
now := time.Unix(1000, 0)
binding := testBinding()
store, _ := NewResultStore(binding)
result := testResult()
annotation := ResultAnnotation{ResultID: "result-1", Result: result, PayloadDigest: resultDigest(result), Signature: []byte("sig")}
verify := func(candidate ResultAnnotation) bool { return string(candidate.Signature) == "sig" }
if _, created, err := store.Reconcile(annotation, verify, binding, now); err != nil || !created {
t.Fatalf("valid annotation = created=%v err=%v", created, err)
}
forged := annotation
forged.Result.Team0Score = 99
if _, _, err := store.Reconcile(forged, verify, binding, now); !errors.Is(err, ErrResultBinding) {
t.Fatalf("forged annotation accepted: %v", err)
}
}
func TestResultDeliveryHealthSeparatesOutageFromIntegrity(t *testing.T) {
now := time.Unix(1000, 0)
binding := testBinding()