Skip to content

Commit db0698e

Browse files
committed
Don't allow both --fingerprint and --artifact-type flags to be used
1 parent 38dd82c commit db0698e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

cmd/kosli/assertApproval.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ func newAssertApprovalCmd(out io.Writer) *cobra.Command {
5757
if err != nil {
5858
return ErrorBeforePrintingUsage(cmd, err.Error())
5959
}
60+
61+
err = MuXRequiredFlags(cmd, []string{"fingerprint", "artifact-type"}, true)
62+
if err != nil {
63+
return err
64+
}
65+
6066
return ValidateRegistryFlags(cmd, o.fingerprintOptions)
6167

6268
},

cmd/kosli/assertApproval_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ func (suite *AssertApprovalCommandTestSuite) TestAssertApprovalCmd() {
9393
cmd: fmt.Sprintf(`assert approval --flow %s %s`, suite.flowName, suite.defaultKosliArguments),
9494
golden: "Error: docker image name or file/dir path is required when --fingerprint is not provided\nUsage: kosli assert approval [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]\n",
9595
},
96-
// TODO: this test case does not pass as the validation does not check for it
97-
// {
98-
// wantError: true,
99-
// name: "providing both --fingerprint and --artifact-type fails",
100-
// cmd: fmt.Sprintf(`assert approval --artifact-type file --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
101-
// golden: "COMPLIANT\n",
102-
// },
96+
{
97+
wantError: true,
98+
name: "providing both --fingerprint and --artifact-type fails",
99+
cmd: fmt.Sprintf(`assert approval --artifact-type file --fingerprint %s --flow %s %s`, suite.fingerprint, suite.flowName, suite.defaultKosliArguments),
100+
golden: "Error: only one of --fingerprint, --artifact-type is allowed\n",
101+
},
103102
{
104103
wantError: true,
105104
name: "8 missing --flow fails",

0 commit comments

Comments
 (0)