oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package chat
2
3import (
4 "testing"
5 "time"
6
7 "amadan.net/oficina/equipo/internal/wire"
8)
9
10// A person's choice to run outside the sandbox holds for the one attempt
11// on the one Mac it names, and only once recorded with who and when. A
12// Mac's sandbox counts only when its hello says seatbelt and the
13// instance holds it untainted; a runner that is not a Mac is unaffected.
14func TestUnsandboxedChoiceIsPerAttemptAndMac(t *testing.T) {
15 at := time.Now()
16 s := stepRecord{Attempt: 2, UnsandboxedBy: "owner@example.com", UnsandboxedAt: &at, UnsandboxedAttempt: 2, UnsandboxedRunner: "MAC"}
17 if !unsandboxedChosen(s, "MAC") {
18 t.Fatal("the recorded choice does not hold")
19 }
20 if unsandboxedChosen(s, "OTHER") || unsandboxedChosen(s, "") {
21 t.Fatal("a choice carried to another Mac")
22 }
23 next := s
24 next.Attempt = 3
25 if unsandboxedChosen(next, "MAC") {
26 t.Fatal("a choice carried to the next attempt")
27 }
28 unrecorded := s
29 unrecorded.UnsandboxedAt = nil
30 if unsandboxedChosen(unrecorded, "MAC") || unsandboxedChosen(stepRecord{Attempt: 2}, "MAC") {
31 t.Fatal("a choice without who and when")
32 }
33 mac := func(sandbox string, tainted bool) runnerInfo {
34 return runnerInfo{Protocol: wire.Protocol7, Tainted: tainted, Hello: wire.Hello{Sandbox: sandbox, Capabilities: &wire.Capabilities{Tags: []string{wire.TagMacOS, wire.TagXcode}}}}
35 }
36 if !mac(wire.SandboxSeatbelt, false).sandboxProven() || mac(wire.SandboxNone, false).sandboxProven() || mac("", false).sandboxProven() || mac(wire.SandboxSeatbelt, true).sandboxProven() {
37 t.Fatal("a Mac's sandbox judged wrongly")
38 }
39 linux := runnerInfo{Protocol: wire.Protocol7, Hello: wire.Hello{Sandbox: wire.SandboxBubblewrap, Capabilities: &wire.Capabilities{Tags: []string{wire.TagLinux}}}}
40 if !linux.sandboxProven() {
41 t.Fatal("a runner that is not a Mac held back")
42 }
43}
44