Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zheng <patrickzheng@microsoft.com>
  • Loading branch information
Two-Hearts committed Jan 10, 2025
1 parent ce63a53 commit 3602591
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/e2e/suite/command/blob/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package blob

import (
"fmt"
"os"
"path/filepath"

. "github.com/notaryproject/notation/test/e2e/internal/notation"
Expand All @@ -37,6 +38,31 @@ var _ = Describe("notation blob verify", func() {
MatchKeyWords(VerifySuccessfully)
})
})

// Failure cases
It("with blob verify no permission to read blob", func() {
HostWithBlob(BaseBlobOptions(), func(notation *utils.ExecOpts, blobPath string, vhost *utils.VirtualHost) {
noPermissionBlobPath := filepath.Join(vhost.AbsolutePath(), "noPermissionBlob")
newBlobFile, err := os.Create(noPermissionBlobPath)
if err != nil {
Fail(err.Error())
}
defer newBlobFile.Close()

blobDir := filepath.Dir(noPermissionBlobPath)
notation.Exec("blob", "sign", "--force", "--signature-directory", blobDir, blobPath).
MatchKeyWords(SignSuccessfully).
MatchKeyWords("Signature file written to")
if err := os.Chmod(noPermissionBlobPath, 0000); err != nil {
Fail(err.Error())
}
defer os.Chmod(noPermissionBlobPath, 0700)

signaturePath := signatureFilepath(blobDir, blobPath, "jws")
notation.ExpectFailure().Exec("blob", "verify", "--signature", signaturePath, blobPath).
MatchErrKeyWords("permission denied")
})
})
})

func signatureFilepath(signatureDirectory, blobPath, signatureFormat string) string {
Expand Down

0 comments on commit 3602591

Please sign in to comment.