Skip to content

Commit

Permalink
fix: add E2E test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Dec 30, 2024
1 parent cf1fc19 commit 8ecf320
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/e2e/suite/command/blob/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ var _ = Describe("blob trust policy maintainer", func() {
notation.Exec("blob", "policy", "import", filepath.Join(NotationE2ETrustPolicyDir, validBlobTrustPolicyName), "--force")
})
})

It("should failed if without permission to write policy", func() {
Host(opts, func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost) {
notation.
Exec("blob", "policy", "import", filepath.Join(NotationE2ETrustPolicyDir, validBlobTrustPolicyName))

trustPolicyPath := vhost.AbsolutePath(NotationDirName)
os.Chmod(trustPolicyPath, 0000)
defer os.Chmod(trustPolicyPath, 0755)

notation.ExpectFailure().
Exec("blob", "policy", "import", filepath.Join(NotationE2ETrustPolicyDir, validBlobTrustPolicyName), "--force").
MatchErrKeyWords("failed to write blob trust policy file")
})
})

It("should failed if provide file is malformed json", func() {
Host(opts, func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost) {
notation.ExpectFailure().
Exec("blob", "policy", "import", filepath.Join(NotationE2ETrustPolicyDir, "invalid_format_trustpolicy.json"))
})
})
})

When("importing configuration with existing trust policy configuration", func() {
Expand Down

0 comments on commit 8ecf320

Please sign in to comment.