Download this file
| 1 | package team |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestOwnerPublicationLabels(t *testing.T) { |
| 10 | iso := IsolationSnapshot{Mode: "owner mode", Status: "confined", ObservedTuples: []IsolationTuple{{Provider: "claude", ProviderVersion: "v", LauncherVersion: "v", BwrapVersion: "v", PolicyVersion: "v", IsolationConfigHash: strings.Repeat("a", 64)}}} |
| 11 | original := PublicationDescription{Label: "owner mode", Isolation: iso, Evidence: []PublicationEvidence{{Label: "owner mode", Provenance: Provenance{Isolation: iso}}}} |
| 12 | need, _ := json.Marshal(original) |
| 13 | for _, field := range []string{"publication", "evidence"} { |
| 14 | t.Run(field, func(t *testing.T) { |
| 15 | have := original |
| 16 | have.Evidence = append([]PublicationEvidence(nil), original.Evidence...) |
| 17 | if field == "publication" { |
| 18 | have.Label = "confined" |
| 19 | } else { |
| 20 | have.Evidence[0].Label = "confined" |
| 21 | } |
| 22 | raw, _ := json.Marshal(have) |
| 23 | if publicationDescriptionContains(string(raw), string(need)) { |
| 24 | t.Fatal("owner label erased", field) |
| 25 | } |
| 26 | }) |
| 27 | } |
| 28 | } |
| 29 | |