Skip to content
quarry Artifact [5f76a65b2e]
Login

Artifact [5f76a65b2e]

Artifact 5f76a65b2e8a337e27d6bf0c69b58dea56b2a49f51ff2279afc9888bb1c01c95:


package web

import (
	"strings"
	"testing"
)

// RFC 0030, Several repositories: the approval page lists every
// repository with the role it is granted there, and the token reaches
// exactly those.
func TestAPushSetupRequestListsEachRepositoryWithItsRole(t *testing.T) {
	page := renderSetup(t, meSignOff{ID: "abc", Agent: "zeitgeist", State: "pending", Requested: "2026-11-13T10:00:00Z",
		Setup: &meSetupView{Agent: "multi-push", Kind: "push", Belongs: "person", Owner: "dmestas",
			Repos: []string{"dmestas/suit", "dmestas/context", "dmestas/ctx"}, Role: "maintainer", RoleSentence: "Checks in.",
			Scopes: []string{"sync"}, TokenRepos: []string{"dmestas/suit", "dmestas/context", "dmestas/ctx"}, Ceiling: "uv3bBC78"}})
	rows := hookAttrs(page, "setup-repo")
	var got []string
	for _, r := range rows {
		if r["data-role"] != "maintainer" {
			t.Errorf("FAIL: a repository row carries role %q", r["data-role"])
		}
		got = append(got, r["data-repo"])
	}
	if strings.Join(got, ",") != "dmestas/suit,dmestas/context,dmestas/ctx" {
		t.Errorf("FAIL: the rows are %v", got)
	}
	if v, _ := hookAttr(t, page, "setup-reach", "data-repos"); v != "dmestas/suit,dmestas/context,dmestas/ctx" {
		t.Errorf("FAIL: the token reaches %q", v)
	}
	if v, _ := hookAttr(t, page, "setup-agent", "data-belongs"); v != "person" {
		t.Errorf("FAIL: belongs %q", v)
	}
	if !t.Failed() {
		t.Log("ok")
	}
}