mirror of
https://github.com/slsa-framework/slsa-verifier.git
synced 2026-08-19 03:26:20 +00:00
fix: handle workflow input flag parsing (#379)
* fix: handle workflow input flag parsing Signed-off-by: Asra Ali <asraa@google.com> * add smoke tests Signed-off-by: Asra Ali <asraa@google.com> Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -487,7 +488,7 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
|
||||
// Avoid rate limiting by not running the tests in parallel.
|
||||
// t.Parallel()
|
||||
|
||||
checkVersions := getBuildersAndVersions(t, tt.minversion, tt.builders, GHA_ARTIFACT_PATH_BUILDERS)
|
||||
checkVersions := getBuildersAndVersions(t, "v1.2.2", tt.builders, GHA_ARTIFACT_PATH_BUILDERS)
|
||||
if tt.noversion {
|
||||
checkVersions = []string{""}
|
||||
}
|
||||
@@ -576,6 +577,37 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
|
||||
if err := outBuilderID.Matches(*bid, false); err != nil {
|
||||
t.Errorf(fmt.Sprintf("matches failed (2): %v", err))
|
||||
}
|
||||
|
||||
// Smoke test against the CLI command
|
||||
cliCmd := verifyArtifactCmd()
|
||||
args := []string{
|
||||
artifactPath,
|
||||
"--source-uri", tt.source,
|
||||
"--provenance-path", provenancePath}
|
||||
if bid != nil {
|
||||
args = append(args, "--builder-id", *bid)
|
||||
}
|
||||
if tt.pbranch != nil {
|
||||
args = append(args, "--source-branch", *tt.pbranch)
|
||||
}
|
||||
if tt.ptag != nil {
|
||||
args = append(args, "--source-tag", *tt.ptag)
|
||||
}
|
||||
if tt.pversiontag != nil {
|
||||
args = append(args, "--source-versioned-tag", *tt.pversiontag)
|
||||
}
|
||||
if tt.inputs != nil {
|
||||
for k, v := range tt.inputs {
|
||||
args = append(args, "--build-workflow-input", fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
}
|
||||
b := bytes.NewBufferString("")
|
||||
cliCmd.SetOut(b)
|
||||
cliCmd.SetArgs(args)
|
||||
cliErr := cliCmd.Execute()
|
||||
if !errCmp(cliErr, tt.err) {
|
||||
t.Errorf("%v: %v", v, cmp.Diff(cliErr, tt.err, cmpopts.EquateErrors()))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -91,6 +91,9 @@ func (i *workflowInputs) Set(value string) error {
|
||||
if len(l) != 2 {
|
||||
return fmt.Errorf("%w: expected 'key=value' format, got '%s'", serrors.ErrorInvalidFormat, value)
|
||||
}
|
||||
if i.kv == nil {
|
||||
i.kv = make(map[string]string)
|
||||
}
|
||||
i.kv[l[0]] = l[1]
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user