Skip to content

Commit 23d2102

Browse files
Added test case for validate cpe type with spdx
1 parent a4fddb2 commit 23d2102

File tree

9 files changed

+1985
-22
lines changed

9 files changed

+1985
-22
lines changed

pkg/sbom/cdx_test.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func cdxBOM() *cydx.BOM {
3939
Name: "go-testlib",
4040
Version: "v0.0.3",
4141
PackageURL: "pkg:golang/github.com/interlynk-io/go-testlib@v0.0.3",
42-
CPE: "cpe:2:a:golang:go-testlib:v0.0.3:*:*:*:*:*:*:*",
42+
CPE: "cpe:2:a:golang:go-testlib:v0.0.3:*:*:*:*:*:*:*",
4343
},
4444
{
4545
BOMRef: "pkg:golang/github.com/dummy/dummyLib@v3.0.0",
@@ -60,7 +60,7 @@ func cdxBOM() *cydx.BOM {
6060
Name: "dummyArrayLib",
6161
Version: "v2.4.1",
6262
PackageURL: "pkg:golang/github.com/dummy/dummyArrayLib@v2.4.1",
63-
CPE: "cpe:/o:dummy:dummyArrayLib:2.4.1:update4",
63+
CPE: "cpe:/o:dummy:dummyArrayLib:2.4.1:update4",
6464
Supplier: &cydx.OrganizationalEntity{
6565
Name: "",
6666
},
@@ -138,8 +138,8 @@ func Test_cdxDoc_addSupplierName(t *testing.T) {
138138

139139
func Test_cdxDoc_parseComps_Cpes(t *testing.T) {
140140
type fields struct {
141-
doc *cydx.BOM
142-
comps []Component
141+
doc *cydx.BOM
142+
comps []Component
143143
}
144144
type args struct {
145145
index int
@@ -157,7 +157,8 @@ func Test_cdxDoc_parseComps_Cpes(t *testing.T) {
157157
for _, tt := range tests {
158158
t.Run(tt.name, func(t *testing.T) {
159159
c := &cdxDoc{
160-
doc: tt.fields.doc,
160+
doc: tt.fields.doc,
161+
comps: tt.fields.comps,
161162
}
162163
c.parseComps()
163164
if got := c.comps[tt.args.index].Cpes(); len(got) != tt.want {
@@ -168,16 +169,10 @@ func Test_cdxDoc_parseComps_Cpes(t *testing.T) {
168169

169170
}
170171

171-
172172
func Test_cdxDoc_parseComps_purl(t *testing.T) {
173173
type fields struct {
174-
doc *cydx.BOM
175-
spec *spec
176-
comps []Component
177-
authors []Author
178-
tools []Tool
179-
rels []Relation
180-
logs []string
174+
doc *cydx.BOM
175+
comps []Component
181176
}
182177
type args struct {
183178
index int
@@ -195,13 +190,8 @@ func Test_cdxDoc_parseComps_purl(t *testing.T) {
195190
for _, tt := range tests {
196191
t.Run(tt.name, func(t *testing.T) {
197192
c := &cdxDoc{
198-
doc: tt.fields.doc,
199-
spec: tt.fields.spec,
200-
comps: tt.fields.comps,
201-
authors: tt.fields.authors,
202-
tools: tt.fields.tools,
203-
rels: tt.fields.rels,
204-
logs: tt.fields.logs,
193+
doc: tt.fields.doc,
194+
comps: tt.fields.comps,
205195
}
206196
c.parseComps()
207197
if got := c.comps[tt.args.index].Purls(); len(got) != tt.want {

pkg/sbom/sbomfakes/fake_author.go

Lines changed: 167 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)