Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Priya Wadhwa <priya@chainguard.dev>
  • Loading branch information
priyawadhwa committed Oct 26, 2022
1 parent b4e6fce commit 4a8c396
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
4 changes: 4 additions & 0 deletions cmd/cosign/cli/sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, regOpts options.Regist
ctx, cancel := context.WithTimeout(context.Background(), ro.Timeout)
defer cancel()

if options.NOf(ko.KeyRef, ko.Sk) > 1 {
return &options.KeyParseError{}
}

sv, err := SignerFromKeyOpts(ctx, certPath, certChainPath, ko)
if err != nil {
return fmt.Errorf("getting signer: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions doc/cosign_sign.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions doc/cosign_verify.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,16 +1146,13 @@ func TestTlog(t *testing.T) {
// Now verify should work!
must(verify(pubKeyPath, imgName, true, nil, ""), t)

// Now we turn on the tlog!
defer setenv(t, env.VariableExperimental.String(), "1")()

// Verify shouldn't work since we haven't put anything in it yet.
mustErr(verify(pubKeyPath, imgName, true, nil, ""), t)
// TODO: priyawadhwa@ to figure out how to add an entry to the tlog without using keyless signing
// We could add an --upload-tlog flag, but it's a bit weird since we have a --no-upload-tlog flag too right now.

// Sign again with the tlog env var on
must(sign.SignCmd(ro, ko, options.RegistryOptions{}, nil, []string{imgName}, "", "", true, "", "", "", false, false, "", false), t)
// And now verify works!
must(verify(pubKeyPath, imgName, true, nil, ""), t)
// // Sign again with the tlog env var on
// must(sign.SignCmd(ro, ko, options.RegistryOptions{}, nil, []string{imgName}, "", "", true, "", "", "", false, false, "", false), t)
// // And now verify works!
// must(verify(pubKeyPath, imgName, true, nil, ""), t)
}

func TestNoTlog(t *testing.T) {
Expand Down Expand Up @@ -1184,16 +1181,19 @@ func TestNoTlog(t *testing.T) {
// Now verify should work!
must(verify(pubKeyPath, imgName, true, nil, ""), t)

// Now we turn on the tlog!
defer setenv(t, env.VariableExperimental.String(), "1")()
// TODO: priyawadhwa@ to figure out how to add an entry to the tlog without using keyless signing
// We could add an --upload-tlog flag, but it's a bit weird since we have a --no-upload-tlog flag too right now.

// Verify shouldn't work since we haven't put anything in it yet.
mustErr(verify(pubKeyPath, imgName, true, nil, ""), t)
// // Now we turn on the tlog!
// defer setenv(t, env.VariableExperimental.String(), "1")()

// Sign again with the tlog env var on with option to not upload tlog
must(sign.SignCmd(ro, ko, options.RegistryOptions{}, nil, []string{imgName}, "", "", true, "", "", "", false, false, "", true), t)
// And verify it still fails.
mustErr(verify(pubKeyPath, imgName, true, nil, ""), t)
// // Verify shouldn't work since we haven't put anything in it yet.
// mustErr(verify(pubKeyPath, imgName, true, nil, ""), t)

// // Sign again with the tlog env var on with option to not upload tlog
// must(sign.SignCmd(ro, ko, options.RegistryOptions{}, nil, []string{imgName}, "", "", true, "", "", "", false, false, "", true), t)
// // And verify it still fails.
// mustErr(verify(pubKeyPath, imgName, true, nil, ""), t)
}

func TestGetPublicKeyCustomOut(t *testing.T) {
Expand Down

0 comments on commit 4a8c396

Please sign in to comment.