-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7ce72e
commit da814d7
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,50 @@ func TestValidInventory(t *testing.T) { | |
} | ||
} | ||
|
||
func TestValidSBOM(t *testing.T) { | ||
actual := lint("sbom", []byte(`{ | ||
"success": true, | ||
"truncated": false, | ||
"details": [ | ||
[ | ||
{"sbom": "foo"} | ||
], | ||
[ | ||
{ | ||
"bom-ref": "pkg:golang/cloud.google.com/go/[email protected]", | ||
"type": "gomod", | ||
"name": "cloud.google.com/go/datastore", | ||
"version": "1.1.0", | ||
"licenses": [ | ||
{ | ||
"id": "Apache-2.0", | ||
"name": "Apache-2.0" | ||
} | ||
] | ||
} | ||
] | ||
], | ||
"errors": ["failed to scan"] | ||
}`)) | ||
if actual != nil { | ||
t.Fatalf("expected no errors, got %v", actual) | ||
} | ||
} | ||
|
||
func TestSBOMMissingValue(t *testing.T) { | ||
actual := lint("sbom", []byte(`{ | ||
"success": true, | ||
"truncated": false, | ||
"details": [ | ||
[] | ||
], | ||
"errors": ["failed to scan"] | ||
}`)) | ||
if !containsValidationError(actual, "/details", "minItems: got 1, want 2") { | ||
t.Fatalf("expected required error, got %v", actual) | ||
} | ||
} | ||
|
||
func TestUnknownType(t *testing.T) { | ||
actual := lint("foo", []byte("{}")) | ||
if actual == nil || !strings.Contains(actual.Error(), "unknown plugin type") { | ||
|