Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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

server/hook/hook_test.go +56−2

@@ -227,7 +227,7 @@ func TestInstanceRoleAppliesOnlyToPublicReposAndAdminEverywhere(t *testing.T) {
227 227 f.setACL(func(a *access.ACL) { a.Default = "none" })
228 228 if code, out := f.run("invited", own, 0); code == 0 {
229 229 t.Fatal("instance contributor pushed to a private repo")
230 } else if !strings.Contains(out, "does not have maintain or contribute access") {
230 } else if !strings.Contains(out, "does not have maintain, runner, or contribute access") {
231 231 t.Fatalf("unclear private-repo rejection: %s", out)
232 232 }
233 233
@@ -246,7 +246,7 @@ func TestReadOnlyCannotPush(t *testing.T) {
246 246 if code == 0 {
247 247 t.Fatal("read-only user was allowed to push")
248 248 }
249 if !strings.Contains(out, "does not have maintain or contribute access") {
249 if !strings.Contains(out, "does not have maintain, runner, or contribute access") {
250 250 t.Fatalf("message should name the reason, got: %s", out)
251 251 }
252 252 if !strings.Contains(out, "reader") {
@@ -254,6 +254,60 @@ func TestReadOnlyCannotPush(t *testing.T) {
254 254 }
255 255 }
256 256
257 // A runner publishes the one branch the instance calls the site. It may also use
258 // its contributor namespace and the issues branch, because the role implies
259 // contribute; every shared branch and tag is still a maintainer's write.
260 func TestRunnerPublishesTheSiteRefOnly(t *testing.T) {
261 t.Parallel()
262 f := newFixture(t, "hello\n")
263 f.setACL(func(a *access.ACL) { a.Entries["runner"] = "runner" })
264
265 if code, out := f.run("runner", "refs/heads/pages", 0); code != 0 {
266 t.Fatalf("runner could not publish the site: %s", out)
267 }
268 if code, out := f.run("runner", "refs/heads/contrib/runner/topic", 0); code != 0 {
269 t.Fatalf("runner could not use its contributor namespace: %s", out)
270 }
271 for _, ref := range []string{"refs/heads/main", "refs/tags/v1"} {
272 code, out := f.run("runner", ref, 0)
273 if code == 0 {
274 t.Fatalf("runner was allowed to push %s", ref)
275 }
276 if !strings.Contains(out, "the runner role may push its contrib branches") ||
277 !strings.Contains(out, "refs/heads/pages") {
278 t.Fatalf("%s: unclear rejection: %s", ref, out)
279 }
280 }
281 }
282
283 // The site branch is whatever the instance configured, not the literal "pages".
284 func TestRunnerPublishesTheConfiguredSiteRef(t *testing.T) {
285 t.Parallel()
286 f := newFixture(t, "hello\n")
287 f.setACL(func(a *access.ACL) { a.Entries["runner"] = "runner" })
288 if code, out := f.runWith(Config{Actor: "runner", PagesRef: "site"}, "refs/heads/site"); code != 0 {
289 t.Fatalf("runner could not publish the configured site ref: %s", out)
290 }
291 if code, out := f.runWith(Config{Actor: "runner", PagesRef: "site"}, "refs/heads/pages"); code == 0 {
292 t.Fatalf("runner published a branch that is not the site: %s", out)
293 } else if !strings.Contains(out, "refs/heads/site") {
294 t.Fatalf("the refusal does not name the configured site ref: %s", out)
295 }
296 }
297
298 // A read account that is not a runner is told which role to grant.
299 func TestReadOnlySitePublishNamesTheRunnerRole(t *testing.T) {
300 t.Parallel()
301 f := newFixture(t, "hello\n")
302 code, out := f.run("reader", "refs/heads/pages", 0)
303 if code == 0 {
304 t.Fatal("a read-only account published the site")
305 }
306 if !strings.Contains(out, "runner role") || !strings.Contains(out, "set-role") {
307 t.Fatalf("the refusal does not name the fix: %s", out)
308 }
309 }
310
257 311 func TestAnonymousCannotPush(t *testing.T) {
258 312 t.Parallel()
259 313 f := newFixture(t, "hello\n")