|
1 | 1 | // |
2 | | -// Copyright 2023-2025 The Chainloop Authors. |
| 2 | +// Copyright 2023-2026 The Chainloop Authors. |
3 | 3 | // |
4 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | // you may not use this file except in compliance with the License. |
@@ -74,6 +74,7 @@ func TestCyclonedxJSONCraft(t *testing.T) { |
74 | 74 | wantMainComponentKind string |
75 | 75 | wantMainComponentVersion string |
76 | 76 | annotations map[string]string |
| 77 | + absentAnnotations []string |
77 | 78 | }{ |
78 | 79 | { |
79 | 80 | name: "invalid path", |
@@ -156,6 +157,34 @@ func TestCyclonedxJSONCraft(t *testing.T) { |
156 | 157 | "chainloop.material.sbom.vulnerabilities_report": "true", |
157 | 158 | }, |
158 | 159 | }, |
| 160 | + { |
| 161 | + name: "1.4 version with empty tool version", |
| 162 | + filePath: "./testdata/sbom.cyclonedx-1.4-empty-tool-version.json", |
| 163 | + wantDigest: "sha256:f0b15f1ae6cadb9f14e0071f14888bcbae03686580f8fc8dc0c838e6e96aaf0e", |
| 164 | + wantFilename: "sbom.cyclonedx-1.4-empty-tool-version.json", |
| 165 | + wantMainComponent: "test-app", |
| 166 | + wantMainComponentKind: "application", |
| 167 | + wantMainComponentVersion: "1.0.0", |
| 168 | + annotations: map[string]string{ |
| 169 | + "chainloop.material.tool.name": "Hub", |
| 170 | + "chainloop.material.tools": `["Hub"]`, |
| 171 | + }, |
| 172 | + absentAnnotations: []string{"chainloop.material.tool.version"}, |
| 173 | + }, |
| 174 | + { |
| 175 | + name: "1.5 version with empty tool version", |
| 176 | + filePath: "./testdata/sbom.cyclonedx-1.5-empty-tool-version.json", |
| 177 | + wantDigest: "sha256:4091c3b42ec5d368365f5b6fba80dd30cc3ddf84f795096e738b02f8e2716ce1", |
| 178 | + wantFilename: "sbom.cyclonedx-1.5-empty-tool-version.json", |
| 179 | + wantMainComponent: "test-app", |
| 180 | + wantMainComponentKind: "application", |
| 181 | + wantMainComponentVersion: "1.0.0", |
| 182 | + annotations: map[string]string{ |
| 183 | + "chainloop.material.tool.name": "Hub", |
| 184 | + "chainloop.material.tools": `["Hub"]`, |
| 185 | + }, |
| 186 | + absentAnnotations: []string{"chainloop.material.tool.version"}, |
| 187 | + }, |
159 | 188 | { |
160 | 189 | name: "1.5 version with multiple tools", |
161 | 190 | filePath: "./testdata/sbom.cyclonedx-1.5-multiple-tools.json", |
@@ -221,6 +250,11 @@ func TestCyclonedxJSONCraft(t *testing.T) { |
221 | 250 | ast.Equal(v, got.Annotations[k]) |
222 | 251 | } |
223 | 252 | } |
| 253 | + |
| 254 | + for _, k := range tc.absentAnnotations { |
| 255 | + _, exists := got.Annotations[k] |
| 256 | + ast.False(exists, "annotation %q should not be present", k) |
| 257 | + } |
224 | 258 | }) |
225 | 259 | } |
226 | 260 | } |
|
0 commit comments