oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package checks
2
3import (
4 "context"
5 "testing"
6
7 "amadan.net/oficina/equipo/internal/equipo/team"
8)
9
10type durableFixture map[string]team.Provenance
11
12func (d durableFixture) SaveAttestation(_ context.Context, k string, p team.Provenance) error {
13 d[k] = p
14 return nil
15}
16func (d durableFixture) LoadAttestation(_ context.Context, k string) (team.Provenance, error) {
17 return d[k], nil
18}
19func TestExecutorAttestationSurvivesReconstruction(t *testing.T) {
20 f := newFixture(t)
21 ctx := context.Background()
22 store := durableFixture{}
23 f.e.SetAttestationStore(store)
24 result, err := f.e.Reproduce(ctx, f.d, f.r, baseID, "")
25 must(t, err)
26 fresh, err := newExecutor(f.e.cfg, localSandbox{})
27 must(t, err)
28 fresh.SetAttestationStore(store)
29 spec := team.ArtifactSpec{Role: team.RoleBaseResult, Payload: raw(result)}
30 if _, err = fresh.ValidateEvidence(ctx, nil, f.e.cfg.Scope, f.e.cfg.Handle, spec); err != nil {
31 t.Fatal("durable attestation lost", err)
32 }
33 spec.Payload = append(spec.Payload, ' ')
34 if _, err = fresh.ValidateEvidence(ctx, nil, f.e.cfg.Scope, f.e.cfg.Handle, spec); err == nil {
35 t.Fatal("changed payload accepted")
36 }
37}
38
39func TestExecutorRequiresAttestationStore(t *testing.T) {
40 f := newFixture(t)
41 f.e.SetAttestationStore(nil)
42 if _, err := f.e.Reproduce(context.Background(), f.d, f.r, baseID, ""); err == nil {
43 t.Fatal("executor returned unattested result without durable store")
44 }
45}
46