vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Replace the runner allowlist with a runner role
648cd81bde97042f682a528ebb9ce6353b95bf3f · Keenan Nemetz · 1d ago · parent ea92d754
forge/access/acl_test.go +17−2
| @@ -7,8 +7,9 @@ import ( | |||
| 7 | 7 | ||
| 8 | 8 | func TestRoleOrdering(t *testing.T) { | |
| 9 | 9 | t.Parallel() | |
| 10 | if !Admin.AtLeast(Maintain) || !Maintain.AtLeast(Contribute) || !Contribute.AtLeast(Read) || | ||
| 11 | Read.AtLeast(Contribute) || Contribute.AtLeast(Maintain) || Maintain != Write { | ||
| 10 | if !Admin.AtLeast(Maintain) || !Maintain.AtLeast(Runner) || !Runner.AtLeast(Contribute) || | ||
| 11 | !Contribute.AtLeast(Read) || Read.AtLeast(Contribute) || Contribute.AtLeast(Runner) || | ||
| 12 | Runner.AtLeast(Maintain) || Maintain != Write { | ||
| 12 | 13 | t.Fatal("role ordering is wrong") | |
| 13 | 14 | } | |
| 14 | 15 | for _, c := range []struct { | |
| @@ -22,6 +23,7 @@ func TestRoleOrdering(t *testing.T) { | |||
| 22 | 23 | {"contributor", Contribute, true}, | |
| 23 | 24 | {"contribute", Contribute, true}, | |
| 24 | 25 | {"contrib", Contribute, true}, | |
| 26 | {"runner", Runner, true}, | ||
| 25 | 27 | {"maintain", Maintain, true}, | |
| 26 | 28 | {"maintainer", Maintain, true}, | |
| 27 | 29 | {"write", Maintain, true}, | |
| @@ -71,6 +73,7 @@ func TestRoleFor(t *testing.T) { | |||
| 71 | 73 | t.Parallel() | |
| 72 | 74 | a := &ACL{Default: "none", Entries: map[string]string{ | |
| 73 | 75 | "owner": "admin", "dev": "write", "guest": "read", "contributor": "contribute", | |
| 76 | "runner": "runner", | ||
| 74 | 77 | }} | |
| 75 | 78 | cases := []struct { | |
| 76 | 79 | user string | |
| @@ -113,6 +116,7 @@ func TestInstanceRolesApplyToPublicReposOnly(t *testing.T) { | |||
| 113 | 116 | t.Parallel() | |
| 114 | 117 | roles := map[string]Role{ | |
| 115 | 118 | "contributor": Contribute, | |
| 119 | "runner": Runner, | ||
| 116 | 120 | "maintainer": Maintain, | |
| 117 | 121 | "admin": Admin, | |
| 118 | 122 | } | |
| @@ -130,6 +134,9 @@ func TestInstanceRolesApplyToPublicReposOnly(t *testing.T) { | |||
| 130 | 134 | if got := private.RoleFor("reader"); got != Read { | |
| 131 | 135 | t.Fatalf("explicit repo read = %v, want read", got) | |
| 132 | 136 | } | |
| 137 | if got := private.RoleFor("runner"); got != None { | ||
| 138 | t.Fatalf("instance runner got %v on a private repo, want none", got) | ||
| 139 | } | ||
| 133 | 140 | if got := private.RoleFor("admin"); got != Admin { | |
| 134 | 141 | t.Fatalf("instance admin got %v on a private repo, want admin", got) | |
| 135 | 142 | } | |
| @@ -138,9 +145,15 @@ func TestInstanceRolesApplyToPublicReposOnly(t *testing.T) { | |||
| 138 | 145 | if got := public.RoleFor("contributor"); got != Contribute { | |
| 139 | 146 | t.Fatalf("instance contributor on a public repo = %v", got) | |
| 140 | 147 | } | |
| 148 | if got := public.RoleFor("runner"); got != Runner { | ||
| 149 | t.Fatalf("instance runner on a public repo = %v", got) | ||
| 150 | } | ||
| 141 | 151 | if got := public.RoleFor("maintainer"); got != Maintain { | |
| 142 | 152 | t.Fatalf("instance maintainer on a public repo = %v", got) | |
| 143 | 153 | } | |
| 154 | if !public.CanReport("maintainer") { | ||
| 155 | t.Fatal("a maintainer is not a trusted runner on a public repo") | ||
| 156 | } | ||
| 144 | 157 | if got := public.RoleFor("stranger"); got != Read { | |
| 145 | 158 | t.Fatalf("repository default on a public repo = %v", got) | |
| 146 | 159 | } | |
| @@ -158,6 +171,7 @@ func TestCapabilitiesFollowTheRole(t *testing.T) { | |||
| 158 | 171 | t.Parallel() | |
| 159 | 172 | a := &ACL{Default: "read", Entries: map[string]string{ | |
| 160 | 173 | "owner": "admin", "dev": "write", "guest": "read", "contributor": "contribute", | |
| 174 | "runner": "runner", | ||
| 161 | 175 | }} | |
| 162 | 176 | for _, c := range []struct { | |
| 163 | 177 | user string | |
| @@ -166,6 +180,7 @@ func TestCapabilitiesFollowTheRole(t *testing.T) { | |||
| 166 | 180 | {"owner", true, true, true, true}, | |
| 167 | 181 | {"dev", true, true, true, true}, | |
| 168 | 182 | {"contributor", true, true, false, false}, | |
| 183 | {"runner", true, true, false, false}, | ||
| 169 | 184 | {"guest", false, false, false, false}, | |
| 170 | 185 | {"stranger", false, false, false, false}, | |
| 171 | 186 | } { | |