@@ -65,9 +65,11 @@ func TestNewCyclonedxJSONCrafter(t *testing.T) {
6565
6666func TestCyclonedxJSONCraft (t * testing.T ) {
6767 testCases := []struct {
68- name string
69- filePath string
70- wantErr string
68+ name string
69+ filePath string
70+ wantErr string
71+ wantFilename string
72+ wantDigest string
7173 }{
7274 {
7375 name : "invalid path" ,
@@ -85,8 +87,16 @@ func TestCyclonedxJSONCraft(t *testing.T) {
8587 wantErr : "unexpected material type" ,
8688 },
8789 {
88- name : "valid artifact type" ,
89- filePath : "./testdata/sbom.cyclonedx.json" ,
90+ name : "1.4 version" ,
91+ filePath : "./testdata/sbom.cyclonedx.json" ,
92+ wantDigest : "sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c" ,
93+ wantFilename : "sbom.cyclonedx.json" ,
94+ },
95+ {
96+ name : "1.5 version" ,
97+ filePath : "./testdata/sbom.cyclonedx-1.5.json" ,
98+ wantDigest : "sha256:5ca3508f02893b0419b266927f66c7b9dd8b11dbea7faf7cdb9169df8f69d8e3" ,
99+ wantFilename : "sbom.cyclonedx-1.5.json" ,
90100 },
91101 }
92102
@@ -102,10 +112,7 @@ func TestCyclonedxJSONCraft(t *testing.T) {
102112 uploader := mUploader .NewUploader (t )
103113 if tc .wantErr == "" {
104114 uploader .On ("UploadFile" , context .TODO (), tc .filePath ).
105- Return (& casclient.UpDownStatus {
106- Digest : "deadbeef" ,
107- Filename : "sbom.cyclonedx.json" ,
108- }, nil )
115+ Return (& casclient.UpDownStatus {}, nil )
109116 }
110117
111118 backend := & casclient.CASBackend {Uploader : uploader }
@@ -123,9 +130,9 @@ func TestCyclonedxJSONCraft(t *testing.T) {
123130 assert .True (got .UploadedToCas )
124131
125132 // The result includes the digest reference
126- assert .Equal (got . GetArtifact (), & attestationApi.Attestation_Material_Artifact {
127- Id : "test" , Digest : "sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c" , Name : "sbom.cyclonedx.json" ,
128- })
133+ assert .Equal (& attestationApi.Attestation_Material_Artifact {
134+ Id : "test" , Digest : tc . wantDigest , Name : tc . wantFilename ,
135+ }, got . GetArtifact () )
129136 })
130137 }
131138}
0 commit comments