Skip to content

Commit

Permalink
Merge pull request #44 from interlynk-io/spdx-cpetype-test
Browse files Browse the repository at this point in the history
Test case for CPE type on SPDX file
  • Loading branch information
kchetans authored Feb 17, 2023
2 parents a4fddb2 + 23d2102 commit 2f57b83
Show file tree
Hide file tree
Showing 9 changed files with 1,985 additions and 22 deletions.
30 changes: 10 additions & 20 deletions pkg/sbom/cdx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func cdxBOM() *cydx.BOM {
Name: "go-testlib",
Version: "v0.0.3",
PackageURL: "pkg:golang/github.com/interlynk-io/[email protected]",
CPE: "cpe:2:a:golang:go-testlib:v0.0.3:*:*:*:*:*:*:*",
CPE: "cpe:2:a:golang:go-testlib:v0.0.3:*:*:*:*:*:*:*",
},
{
BOMRef: "pkg:golang/github.com/dummy/[email protected]",
Expand All @@ -60,7 +60,7 @@ func cdxBOM() *cydx.BOM {
Name: "dummyArrayLib",
Version: "v2.4.1",
PackageURL: "pkg:golang/github.com/dummy/[email protected]",
CPE: "cpe:/o:dummy:dummyArrayLib:2.4.1:update4",
CPE: "cpe:/o:dummy:dummyArrayLib:2.4.1:update4",
Supplier: &cydx.OrganizationalEntity{
Name: "",
},
Expand Down Expand Up @@ -138,8 +138,8 @@ func Test_cdxDoc_addSupplierName(t *testing.T) {

func Test_cdxDoc_parseComps_Cpes(t *testing.T) {
type fields struct {
doc *cydx.BOM
comps []Component
doc *cydx.BOM
comps []Component
}
type args struct {
index int
Expand All @@ -157,7 +157,8 @@ func Test_cdxDoc_parseComps_Cpes(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &cdxDoc{
doc: tt.fields.doc,
doc: tt.fields.doc,
comps: tt.fields.comps,
}
c.parseComps()
if got := c.comps[tt.args.index].Cpes(); len(got) != tt.want {
Expand All @@ -168,16 +169,10 @@ func Test_cdxDoc_parseComps_Cpes(t *testing.T) {

}


func Test_cdxDoc_parseComps_purl(t *testing.T) {
type fields struct {
doc *cydx.BOM
spec *spec
comps []Component
authors []Author
tools []Tool
rels []Relation
logs []string
doc *cydx.BOM
comps []Component
}
type args struct {
index int
Expand All @@ -195,13 +190,8 @@ func Test_cdxDoc_parseComps_purl(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &cdxDoc{
doc: tt.fields.doc,
spec: tt.fields.spec,
comps: tt.fields.comps,
authors: tt.fields.authors,
tools: tt.fields.tools,
rels: tt.fields.rels,
logs: tt.fields.logs,
doc: tt.fields.doc,
comps: tt.fields.comps,
}
c.parseComps()
if got := c.comps[tt.args.index].Purls(); len(got) != tt.want {
Expand Down
167 changes: 167 additions & 0 deletions pkg/sbom/sbomfakes/fake_author.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f57b83

Please sign in to comment.