oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package wire_test
2
3import (
4 "amadan.net/oficina/equipo/internal/wire"
5 "testing"
6)
7
8func TestAccessProtocol(t *testing.T) {
9 if wire.ProtocolAccess != 26 {
10 t.Fatal("access must follow main protocol 25")
11 }
12 for kind, body := range map[string]any{wire.FrameRequestAccess: wire.AccessCommand{CardID: "c", Person: "p", Target: "ns/repo", Role: "agent", Reason: "Fix it", Confirmed: true}, wire.FrameAccess: wire.AccessReport{CardID: "c", Person: "p", RequestID: "ar", State: "pending"}} {
13 f, err := wire.NewFrame("id", kind, body)
14 if err != nil {
15 t.Fatal(err)
16 }
17 if !f.Durable() {
18 t.Fatal("access frame not durable")
19 }
20 if _, err := wire.Encode(f, wire.Protocol25); err == nil {
21 t.Fatal("access sent to old peer")
22 }
23 if _, err := wire.Encode(f, wire.ProtocolAccess); err != nil {
24 t.Fatal(err)
25 }
26 }
27}
28
29func TestAccessLeaseDowngrade(t *testing.T) {
30 f, err := wire.NewFrame("lease", wire.FrameLease, wire.LeaseCheck{AccessCard: "card"})
31 if err != nil {
32 t.Fatal(err)
33 }
34 if _, err := wire.Encode(f, wire.Protocol25); err == nil {
35 t.Fatal("access lease sent to old instance")
36 }
37 if _, err := wire.Encode(f, wire.ProtocolAccess); err != nil {
38 t.Fatal(err)
39 }
40}
41