Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Priya Wadhwa <priyawadhwa@google.com>
  • Loading branch information
Priya Wadhwa committed Apr 28, 2021
1 parent b1fd4ad commit 53dd343
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,44 @@ func TestSignVerify(t *testing.T) {
// It should match this time.
must(verify(pubKeyPath, imgName, true, map[string]interface{}{"foo": "bar"}), t)

// Make sure offline verification works with bundling
original := os.Getenv(cosign.ServerEnv)
os.Setenv(cosign.ServerEnv, "notreal")
must(verify(pubKeyPath, imgName, true, map[string]interface{}{"foo": "bar"}), t)
os.Setenv(cosign.ServerEnv, original)

// But two doesn't work
mustErr(verify(pubKeyPath, imgName, true, map[string]interface{}{"foo": "bar", "baz": "bat"}), t)
}

func TestBundle(t *testing.T) {
// use rekor prod since we have hardcoded the public key
defer setenv(t, cosign.ServerEnv, "https://api.rekor.dev")()
// turn on the tlog
defer setenv(t, cosign.ExperimentalEnv, "1")()

repo, stop := reg(t)
defer stop()
td := t.TempDir()

imgName := path.Join(repo, "cosign-e2e")

_, _, cleanup := mkimage(t, imgName)
defer cleanup()

_, privKeyPath, pubKeyPath := keypair(t, td)

ctx := context.Background()

so := cli.SignOpts{
KeyRef: privKeyPath,
Pf: passFunc,
}

// Sign the image
must(cli.SignCmd(ctx, so, imgName, true, "", false), t)
// Make sure verify works
must(verify(pubKeyPath, imgName, true, nil), t)

// Make sure offline verification works with bundling
os.Setenv(cosign.ServerEnv, "notreal")
must(verify(pubKeyPath, imgName, true, nil), t)
}

func TestDuplicateSign(t *testing.T) {
repo, stop := reg(t)
defer stop()
Expand Down

0 comments on commit 53dd343

Please sign in to comment.