Skip to content

Commit

Permalink
Evidence CLI - update fields names
Browse files Browse the repository at this point in the history
  • Loading branch information
osaidwtd committed Aug 4, 2024
1 parent dcfacf1 commit 709f5be
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
12 changes: 0 additions & 12 deletions evidence/cli/command_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/jfrog/jfrog-cli-artifactory/evidence"
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

type evidenceCustomCommand struct {
Expand All @@ -19,10 +18,6 @@ func NewEvidenceCustomCommand(ctx *components.Context, execute execCommandFunc)
}
}
func (ecc *evidenceCustomCommand) CreateEvidence(ctx *components.Context, serverDetails *coreConfig.ServerDetails) error {
err := ecc.validateEvidenceCustomContext(ctx)
if err != nil {
return err
}
createCmd := evidence.NewCreateEvidenceCustom(
serverDetails,
ecc.ctx.GetStringFlagValue(predicate),
Expand All @@ -33,10 +28,3 @@ func (ecc *evidenceCustomCommand) CreateEvidence(ctx *components.Context, server
ecc.ctx.GetStringFlagValue(subjectSha256))
return ecc.execute(createCmd)
}

func (ecc *evidenceCustomCommand) validateEvidenceCustomContext(c *components.Context) error {
if !c.IsFlagSet(subjectSha256) || assertValueProvided(c, subjectSha256) != nil {
return errorutils.CheckErrorf("'subject-sha256' is a mandatory field for creating a custom evidence: --%s", subjectSha256)
}
return nil
}
4 changes: 2 additions & 2 deletions evidence/create_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestBuildInfo(t *testing.T) {
project: "myProject",
buildName: "buildName",
buildNumber: "1",
expectedPath: "myProject-buildName-info/buildName/1-1705529045000.json",
expectedPath: "myProject-build-info/buildName/1-1705529045000.json",
expectedChecksum: "dummy_sha256",
expectError: false,
},
Expand All @@ -62,7 +62,7 @@ func TestBuildInfo(t *testing.T) {
project: "default",
buildName: "buildName",
buildNumber: "1",
expectedPath: "artifactory-buildName-info/buildName/1-1705529045000.json",
expectedPath: "artifactory-build-info/buildName/1-1705529045000.json",
expectedChecksum: "dummy_sha256",
expectError: false,
},
Expand Down
2 changes: 1 addition & 1 deletion evidence/intoto/intoto_statement_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *Statement) SetSubject(servicesManager artifactory.ArtifactoryServicesMa
if err != nil {
return err
}
if res.Checksums.Sha256 != subjectSha256 {
if subjectSha256 != "" && res.Checksums.Sha256 != subjectSha256 {
return errorutils.CheckErrorf("provided sha256 does not match the file's sha256")
}
s.Subject[0].Digest.Sha256 = res.Checksums.Sha256
Expand Down
4 changes: 2 additions & 2 deletions evidence/intoto/intoto_statement_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestSetSubjectSha256NotEqual(t *testing.T) {
st := NewStatement([]byte(predicate), predicateType, "")
assert.NotNil(t, st)
aa := &mockArtifactoryServicesManager{}
err := st.SetSubject(aa, "path/to/file.txt@e77779f5a976c7f4a5406907790bb8cad6148406282f07cd143fd1de64ca169d")
err := st.SetSubject(aa, "path/to/file.txt", "e77779f5a976c7f4a5406907790bb8cad6148406282f07cd143fd1de64ca169d")
assert.Error(t, err)
}

Expand All @@ -57,7 +57,7 @@ func TestSetSubjectSha256Equal(t *testing.T) {
st := NewStatement([]byte(predicate), predicateType, "")
assert.NotNil(t, st)
aa := &mockArtifactoryServicesManager{}
err := st.SetSubject(aa, "path/to/file.txt@e06f59f5a976c7f4a5406907790bb8cad6148406282f07cd143fd1de64ca169d")
err := st.SetSubject(aa, "path/to/file.txt", "e06f59f5a976c7f4a5406907790bb8cad6148406282f07cd143fd1de64ca169d")
assert.NoError(t, err)
}

Expand Down

0 comments on commit 709f5be

Please sign in to comment.