forked from notaryproject/notation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: e2e quickstart test case (notaryproject#494)
Signed-off-by: Junjie Gao <[email protected]>
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package scenario_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/notaryproject/notation/test/e2e/internal/notation" | ||
"github.com/notaryproject/notation/test/e2e/internal/utils" | ||
"github.com/notaryproject/notation/test/e2e/internal/utils/validator" | ||
. "github.com/onsi/ginkgo/v2" | ||
) | ||
|
||
// quickstart doc: https://notaryproject.dev/docs/quickstart/ | ||
var _ = Describe("notation quickstart E2E test", Ordered, func() { | ||
var vhost *utils.VirtualHost | ||
var artifact *Artifact | ||
var artifact2 *Artifact | ||
var notation *utils.ExecOpts | ||
BeforeAll(func() { | ||
var err error | ||
// setup host | ||
vhost, err = utils.NewVirtualHost(NotationBinPath, CreateNotationDirOption()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
vhost.SetOption(AuthOption("", "")) | ||
notation = vhost.Executor | ||
|
||
// add an image to the OCI-compatible registry | ||
artifact = GenerateArtifact("", "") | ||
artifact2 = GenerateArtifact("", "") | ||
}) | ||
|
||
It("list the signatures associated with the container image", func() { | ||
notation.Exec("ls", artifact.ReferenceWithTag()). | ||
MatchContent("") | ||
}) | ||
|
||
It("generate a test key and self-signed certificate", func() { | ||
notation.Exec("cert", "generate-test", "--default", "wabbit-networks.io"). | ||
MatchKeyWords( | ||
"Successfully added wabbit-networks.io.crt", | ||
"wabbit-networks.io: added to the key list", | ||
"wabbit-networks.io: mark as default signing key") | ||
|
||
notation.Exec("key", "ls"). | ||
MatchKeyWords( | ||
"notation/localkeys/wabbit-networks.io.key", | ||
"notation/localkeys/wabbit-networks.io.crt", | ||
) | ||
|
||
notation.Exec("cert", "ls"). | ||
MatchKeyWords("notation/truststore/x509/ca/wabbit-networks.io/wabbit-networks.io.crt") | ||
}) | ||
|
||
It("sign the container image with jws format (by default)", func() { | ||
notation.Exec("sign", artifact.ReferenceWithDigest()). | ||
MatchContent(fmt.Sprintf("Successfully signed %s\n", artifact.ReferenceWithDigest())) | ||
|
||
notation.Exec("ls", artifact.ReferenceWithDigest()). | ||
MatchKeyWords(fmt.Sprintf("%s\n└── application/vnd.cncf.notary.signature\n └── sha256:", artifact.ReferenceWithDigest())) | ||
}) | ||
It("sign the container image with cose format", func() { | ||
notation.Exec("sign", "--signature-format", "cose", artifact2.ReferenceWithDigest()). | ||
MatchContent(fmt.Sprintf("Successfully signed %s\n", artifact2.ReferenceWithDigest())) | ||
|
||
notation.Exec("ls", artifact2.ReferenceWithDigest()). | ||
MatchKeyWords(fmt.Sprintf("%s\n└── application/vnd.cncf.notary.signature\n └── sha256:", artifact2.ReferenceWithDigest())) | ||
}) | ||
|
||
It("Create a trust policy", func() { | ||
vhost.SetOption(AddTrustPolicyOption("quickstart_trustpolicy.json")) | ||
validator.CheckFileExist(vhost.AbsolutePath(NotationDirName, TrustPolicyName)) | ||
}) | ||
|
||
It("Verify the container image with jws format", func() { | ||
notation.Exec("verify", artifact.ReferenceWithDigest()). | ||
MatchContent(fmt.Sprintf("Successfully verified signature for %s\n", artifact.ReferenceWithDigest())) | ||
}) | ||
|
||
It("Verify the container image with cose format", func() { | ||
notation.Exec("verify", artifact2.ReferenceWithDigest()). | ||
MatchContent(fmt.Sprintf("Successfully verified signature for %s\n", artifact2.ReferenceWithDigest())) | ||
}) | ||
}) |
16 changes: 16 additions & 0 deletions
16
test/e2e/testdata/config/trustpolicys/quickstart_trustpolicy.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": "1.0", | ||
"trustPolicies": [ | ||
{ | ||
"name": "wabbit-networks-images", | ||
"registryScopes": [ "*" ], | ||
"signatureVerification": { | ||
"level" : "strict" | ||
}, | ||
"trustStores": [ "ca:wabbit-networks.io" ], | ||
"trustedIdentities": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} |