tinyrelayfile
tinyrelay/tinygit/capabilities_test.go/

tinygit/capabilities_test.go raw
1package tinygit
2
3import (
4 "context"
5 "reflect"
6 "testing"
7
8 "github.com/FelineStateMachine/tinyrelay/internal/policy"
9)
10
11func TestCapabilitiesRequireEventSyncTransport(t *testing.T) {
12 p := policy.Policy{Features: policy.Features{Grasp: true, Grasp02: true, Grasp03: true, Grasp06: true}}
13 g := &GitRelay{policy: func() Policy { return fromInternalPolicy(p) }}
14 if got := g.Capabilities(); !reflect.DeepEqual(got, []string{"GRASP-01", "GRASP-06"}) {
15 t.Fatalf("without event transport: %v", got)
16 }
17 g.eventSync = func(context.Context, Repository) error { return nil }
18 if got := g.Capabilities(); !reflect.DeepEqual(got, []string{"GRASP-01", "GRASP-02", "GRASP-03", "GRASP-06"}) {
19 t.Fatalf("with event transport: %v", got)
20 }
21 p.Features.Grasp02 = false
22 if got := g.Capabilities(); !reflect.DeepEqual(got, []string{"GRASP-01", "GRASP-06"}) {
23 t.Fatalf("without base sync: %v", got)
24 }
25}
26
27func TestCapabilitiesPreservePrivateProfiles(t *testing.T) {
28 p := policy.Policy{Reads: "members", Features: policy.Features{Grasp: true, Grasp02: true, Grasp03: true, Grasp06: true, Grasp08: true}}
29 g := &GitRelay{policy: func() Policy { return fromInternalPolicy(p) }, eventSync: func(context.Context, Repository) error { return nil }}
30 want := []string{"GRASP-01", "GRASP-02", "GRASP-03", "GRASP-06", "GRASP-08"}
31 if got := g.SupportedGRASPs(); !reflect.DeepEqual(got, want) {
32 t.Fatalf("private profiles: %v", got)
33 }
34}
35
36func TestPolicyPrivateServiceRequiresGRASP(t *testing.T) {
37 p := Policy{Reads: "members", Features: PolicyFeatures{Grasp08: true}}
38 if p.PrivateServiceEnabled() {
39 t.Fatal("private service enabled without GRASP")
40 }
41 p.Features.Grasp = true
42 if !p.PrivateServiceEnabled() {
43 t.Fatal("private service not enabled with complete profile")
44 }
45}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs