Skip to content

Commit

Permalink
add test for signerRepo and tenant
Browse files Browse the repository at this point in the history
Signed-off-by: Meredith Lancaster <[email protected]>
  • Loading branch information
malancas committed Dec 18, 2024
1 parent 86b815e commit 4431fa9
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pkg/cmd/attestation/verify/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func TestNewEnforcementCriteria(t *testing.T) {
t.Run("sets SANRegex using SignerRepo", func(t *testing.T) {
opts := &Options{
ArtifactPath: artifactPath,
Owner: "foo",
Repo: "foo/bar",
Owner: "wrong",
Repo: "wrong/value",
SignerRepo: "foo/bar",
SignerWorkflow: "wrong/value/.github/workflows/attest.yml",
}
Expand All @@ -44,11 +44,27 @@ func TestNewEnforcementCriteria(t *testing.T) {
require.Zero(t, c.SAN)
})

t.Run("sets SANRegex using SignerRepo and Tenant", func(t *testing.T) {
opts := &Options{
ArtifactPath: artifactPath,
Owner: "wrong",
Repo: "wrong/value",
SignerRepo: "foo/bar",
SignerWorkflow: "wrong/value/.github/workflows/attest.yml",
Tenant: "baz",
}

c, err := newEnforcementCriteria(opts)
require.NoError(t, err)
require.Equal(t, "(?i)^https://baz.ghe.com/foo/bar/", c.SANRegex)
require.Zero(t, c.SAN)
})

t.Run("sets SANRegex using SignerWorkflow matching host regex", func(t *testing.T) {
opts := &Options{
ArtifactPath: artifactPath,
Owner: "foo",
Repo: "foo/bar",
Owner: "wrong",
Repo: "wrong/value",
SignerWorkflow: "foo/bar/.github/workflows/attest.yml",
Hostname: "github.com",
}
Expand All @@ -62,7 +78,7 @@ func TestNewEnforcementCriteria(t *testing.T) {
t.Run("sets SANRegex using opts.Repo", func(t *testing.T) {
opts := &Options{
ArtifactPath: artifactPath,
Owner: "foo",
Owner: "wrong",
Repo: "foo/bar",
}

Expand Down

0 comments on commit 4431fa9

Please sign in to comment.