diff --git a/cmd/notation/blob/cmd.go b/cmd/notation/blob/cmd.go index 2883acabf..9c9a55140 100644 --- a/cmd/notation/blob/cmd.go +++ b/cmd/notation/blob/cmd.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Package blob provides the implementation of the `notation blob` command package blob import "github.com/spf13/cobra" diff --git a/test/e2e/suite/command/blob/sign.go b/test/e2e/suite/command/blob/sign.go index 867219b58..ef0ea76cf 100644 --- a/test/e2e/suite/command/blob/sign.go +++ b/test/e2e/suite/command/blob/sign.go @@ -128,12 +128,20 @@ var _ = Describe("notation blob sign", func() { It("with no permission to read the blob file", func() { HostWithBlob(BaseOptions(), func(notation *utils.ExecOpts, blobPath string, vhost *utils.VirtualHost) { - if err := os.Chmod(blobPath, 0000); err != nil { + blobDir := filepath.Dir(blobPath) + noPermissionBlobPath := filepath.Join(blobDir, "noPermissionBlob") + newBlobFile, err := os.Create(noPermissionBlobPath) + if err != nil { + Fail(err.Error()) + } + defer newBlobFile.Close() + + if err := os.Chmod(noPermissionBlobPath, 0000); err != nil { Fail(err.Error()) } - defer os.Chmod(blobPath, 0700) + defer os.Chmod(noPermissionBlobPath, 0700) - notation.ExpectFailure().Exec("blob", "sign", blobPath). + notation.ExpectFailure().Exec("blob", "sign", noPermissionBlobPath). MatchErrKeyWords("permission denied") }) })