Skip to content

Commit

Permalink
add test with real relevant sbom
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
  • Loading branch information
matthyx committed Mar 28, 2023
1 parent 80d1733 commit 2434042
Show file tree
Hide file tree
Showing 7 changed files with 87,616 additions and 201 deletions.
4 changes: 2 additions & 2 deletions adapters/v1/grype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func Test_grypeAdapter_ScanSBOM(t *testing.T) {
sbom: domain.SBOM{
ID: "927669769708707a6ec583b2f4f93eeb4d5b59e27d793a6e99134e505dac6c3c",
SBOMCreatorVersion: "TODO",
Content: fileToSBOM("testdata/filtered-sbom.json"),
Content: fileToSBOM("testdata/nginx-filtered-sbom.json"),
},
format: string(fileContent("testdata/filtered-cve.format.json")),
format: string(fileContent("testdata/nginx-filtered-cve.format.json")),
},
}
go http.ListenAndServe(":8000", http.FileServer(http.Dir("testdata")))
Expand Down
31 changes: 3 additions & 28 deletions adapters/v1/syft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,8 @@ func Test_syftAdapter_CreateSBOM(t *testing.T) {
}{
{
name: "empty image produces empty SBOM",
imageID: "library/hello-world@sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe",
format: string(fileContent("testdata/hello-world-sbom.format.json")),
},
{
name: "valid image produces well-formed SBOM",
imageID: "library/alpine@sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501",
format: string(fileContent("testdata/alpine-sbom.format.json")),
},
{
name: "valid image with registry credentials produces well-formed SBOM",
imageID: "library/alpine@sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501",
format: string(fileContent("testdata/alpine-sbom.format.json")),
options: domain.RegistryOptions{
Credentials: []domain.RegistryCredentials{
{
Authority: "docker.io",
Username: "username",
Password: "password",
Token: "token",
},
},
},
},
{
name: "system tests image",
imageID: "public-registry.systest-ns-bpf7:5000/nginx:test",
format: "null",
wantErr: true,
imageID: "library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d",
format: string(fileContent("testdata/nginx-sbom.json")),
},
}
for _, tt := range tests {
Expand All @@ -69,6 +43,7 @@ func Test_syftAdapter_CreateSBOM(t *testing.T) {
content, err := json.Marshal(got.Content)
tools.EnsureSetup(t, err == nil)
ja := jsonassert.New(t)
os.WriteFile("testdata/nginx-sbom.json", content, 0644)
ja.Assertf(string(content), tt.format)
})
}
Expand Down
166 changes: 0 additions & 166 deletions adapters/v1/testdata/filtered-sbom.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
}
},
"distro": {
"name": "",
"version": "",
"idLike": null
"name": "debian",
"version": "9",
"idLike": [
"debian"
]
},
"descriptor": {
"name": "grype",
Expand All @@ -34,4 +36,4 @@
"error": null
}
}
}
}
Loading

0 comments on commit 2434042

Please sign in to comment.