mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 06:56:40 +01:00
feat: 3626 add option enable license content; disable by default (#3631)
--------- Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package cli
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_Licenses(t *testing.T) {
|
||||
testImage := getFixtureImage(t, "image-unknown-licenses")
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
env map[string]string
|
||||
assertions []traitAssertion
|
||||
}{
|
||||
{
|
||||
name: "licenses default with no content",
|
||||
args: []string{"scan", "-o", "json", testImage, "--from", "docker-archive"},
|
||||
env: map[string]string{"SYFT_FORMAT_PRETTY": "true"},
|
||||
assertions: []traitAssertion{
|
||||
assertJsonReport,
|
||||
assertUnknownLicenseContent(false),
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "licenses with content",
|
||||
args: []string{"scan", "-o", "json", testImage, "--from", "docker-archive"},
|
||||
env: map[string]string{"SYFT_FORMAT_PRETTY": "true", "SYFT_LICENSE_INCLUDE_UNKNOWN_LICENSE_CONTENT": "true"},
|
||||
assertions: []traitAssertion{
|
||||
assertJsonReport,
|
||||
assertUnknownLicenseContent(true),
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cmd, stdout, stderr := runSyft(t, test.env, test.args...)
|
||||
for _, traitFn := range test.assertions {
|
||||
traitFn(t, stdout, stderr, cmd.ProcessState.ExitCode())
|
||||
}
|
||||
logOutputOnFailure(t, cmd, stdout, stderr)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user