Skip to content

Commit 0d5422e

Browse files
committed
Added test
1 parent 6447fb0 commit 0d5422e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cmd/kosli/assertArtifact_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ type AssertArtifactCommandTestSuite struct {
1515
suite.Suite
1616
defaultKosliArguments string
1717
flowName string
18+
envName string
1819
artifactName string
1920
artifactPath string
2021
fingerprint string
2122
}
2223

2324
func (suite *AssertArtifactCommandTestSuite) SetupTest() {
2425
suite.flowName = "assert-artifact"
26+
suite.envName = "assert-artifact-environment"
2527
suite.artifactName = "arti"
2628
suite.artifactPath = "testdata/folder1/hello.txt"
2729
global = &GlobalOpts{
@@ -35,6 +37,7 @@ func (suite *AssertArtifactCommandTestSuite) SetupTest() {
3537
fingerprintOptions := &fingerprintOptions{
3638
artifactType: "file",
3739
}
40+
CreateEnv(global.Org, suite.envName, "server", suite.Suite.T())
3841
var err error
3942
suite.fingerprint, err = GetSha256Digest(suite.artifactPath, fingerprintOptions, logger)
4043
require.NoError(suite.Suite.T(), err)
@@ -58,7 +61,12 @@ func (suite *AssertArtifactCommandTestSuite) TestAssertArtifactCmd() {
5861
{
5962
name: "asserting an existing compliant artifact (using --fingerprint) results in OK and zero exit",
6063
cmd: fmt.Sprintf(`assert artifact --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
61-
goldenRegex: "(?s)^COMPLIANT\n.*See more details at http://localhost(:8001)?/docs-cmd-test-user/flows/assert-artifact/artifacts/fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02(?:\\?artifact_id=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{8})?\n",
64+
goldenRegex: "(?s)^COMPLIANT\n.*Attestation-name.*See more details at http://localhost(:8001)?/docs-cmd-test-user/flows/assert-artifact/artifacts/fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02(?:\\?artifact_id=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{8})?\n",
65+
},
66+
{
67+
name: "asserting an existing compliant artifact (using --fingerprint) for an environment results in OK and zero exit",
68+
cmd: fmt.Sprintf(`assert artifact --fingerprint %s --flow %s --environment %s %s`, suite.fingerprint, suite.flowName, suite.envName, suite.defaultKosliArguments),
69+
goldenRegex: "(?s)^COMPLIANT\n.*Attestation-name.*Policy-name.*See more details at http://localhost(:8001)?/docs-cmd-test-user/flows/assert-artifact/artifacts/fcf33337634c2577a5d86fd7ecb0a25a7c1bb5d89c14fd236f546a5759252c02(?:\\?artifact_id=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{8})?\n",
6270
},
6371
{
6472
name: "asserting an existing compliant artifact (using --artifact-type) results in OK and zero exit",

0 commit comments

Comments
 (0)