Skip to content

Commit

Permalink
test: resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
  • Loading branch information
JeyJeyGao committed Jan 28, 2023
1 parent 4e0fcbd commit 76ba572
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
18 changes: 3 additions & 15 deletions test/e2e/plugin/verify_signature.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package main

import (
"fmt"

"github.com/notaryproject/notation-go/plugin/proto"
"github.com/notaryproject/notation-go/verifier"
"github.com/notaryproject/notation/test/e2e/plugin/internal/io"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -36,21 +33,12 @@ func validateVerifySignatureRequest(req proto.VerifySignatureRequest) error {
if err := validateRequiredField(req.Signature.CriticalAttributes, fieldSet(
"ContentType",
"SigningScheme",
"Expiry",
"AuthenticSigningTime",
"ExtendedAttributes")); err != nil {
"Expiry")); err != nil {
return err
}

// check required extended attributes
if _, ok := req.Signature.CriticalAttributes.ExtendedAttributes[verifier.HeaderVerificationPlugin]; !ok {
return fmt.Errorf("missing extended attribute: %s", verifier.HeaderVerificationPlugin)
}

// check req.Signature
if err := validateRequiredField(req.Signature, fieldSet(
"UnprocessedAttributes",
"CertificateChain")); err != nil {
if err := validateRequiredField(req.Signature, fieldSet("CertificateChain")); err != nil {
return err
}

Expand All @@ -66,7 +54,7 @@ func validateVerifySignatureRequest(req proto.VerifySignatureRequest) error {

func extractVerificationResult(req *proto.VerifySignatureRequest) *proto.VerifySignatureResponse {
resp := &proto.VerifySignatureResponse{
ProcessedAttributes: []any{verifier.HeaderVerificationPlugin, verifier.HeaderVerificationPluginMinVersion},
VerificationResults: make(map[proto.Capability]*proto.VerificationResult),
}

// set verification result based on req.PluginConfig
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/suite/plugin/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import (

var _ = Describe("notation plugin verify", func() {
It("with basic case", func() {
Skip("notation plugin version verification is not correct.")
Host(BaseOptions(), func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost) {
// setup plugin and plugin-key
vhost.SetOption(AddPlugin(NotationE2EPluginPath))
notation.Exec("key", "add", "plugin-key", "--id", "key1", "--plugin", "e2e-plugin",
// add pluginConfig to enable generating envelope capability and update extended attribute
"-c", fmt.Sprintf("%s=true", CapabilityEnvelopeGenerator),
"-c", fmt.Sprintf("%s=e2e-plugin", HeaderVerificationPlugin),
"-c", fmt.Sprintf("%s=1.0.0", HeaderVerificationPluginMinVersion)).
"-c", fmt.Sprintf("%s=e2e-plugin", HeaderVerificationPlugin)).
MatchKeyWords("plugin-key")

// run signing
Expand Down

0 comments on commit 76ba572

Please sign in to comment.