@@ -40,18 +40,17 @@ import (
4040)
4141
4242// Binary scan tests
43-
4443func TestXrayBinaryScanJson (t * testing.T ) {
4544 integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
46- output := testXrayBinaryScan (t , string (format .Json ), "" , "" )
45+ output := testXrayBinaryScan (t , string (format .Json ), "" , "" , false )
4746 validations .VerifyJsonResults (t , output , validations.ValidationParams {
4847 Total : & validations.TotalCount {Licenses : 1 , Vulnerabilities : 1 },
4948 })
5049}
5150
5251func TestXrayBinaryScanSimpleJson (t * testing.T ) {
5352 integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
54- output := testXrayBinaryScan (t , string (format .SimpleJson ), "xray-scan-binary-policy" , "scan-binary-watch" )
53+ output := testXrayBinaryScan (t , string (format .SimpleJson ), "xray-scan-binary-policy" , "scan-binary-watch" , true )
5554 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
5655 Total : & validations.TotalCount {Licenses : 1 , Vulnerabilities : 1 , Violations : 1 },
5756 })
@@ -61,7 +60,7 @@ func TestXrayBinaryScanJsonWithProgress(t *testing.T) {
6160 integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
6261 callback := commonTests .MockProgressInitialization ()
6362 defer callback ()
64- output := testXrayBinaryScan (t , string (format .Json ), "" , "" )
63+ output := testXrayBinaryScan (t , string (format .Json ), "" , "" , false )
6564 validations .VerifyJsonResults (t , output , validations.ValidationParams {
6665 Total : & validations.TotalCount {Licenses : 1 , Vulnerabilities : 1 },
6766 })
@@ -71,13 +70,13 @@ func TestXrayBinaryScanSimpleJsonWithProgress(t *testing.T) {
7170 integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
7271 callback := commonTests .MockProgressInitialization ()
7372 defer callback ()
74- output := testXrayBinaryScan (t , string (format .SimpleJson ), "xray-scan-binary-progress-policy" , "scan-binary-progress-watch" )
73+ output := testXrayBinaryScan (t , string (format .SimpleJson ), "xray-scan-binary-progress-policy" , "scan-binary-progress-watch" , true )
7574 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
7675 Total : & validations.TotalCount {Licenses : 1 , Vulnerabilities : 1 , Violations : 1 },
7776 })
7877}
7978
80- func testXrayBinaryScan (t * testing.T , format , policyName , watchName string ) string {
79+ func testXrayBinaryScan (t * testing.T , format , policyName , watchName string , errorExpected bool ) string {
8180 binariesPath := filepath .Join (filepath .FromSlash (securityTests .GetTestResourcesPath ()), "projects" , "binaries" , "*" )
8281 args := []string {"scan" , binariesPath , "--licenses" , "--format=" + format }
8382 if policyName != "" && watchName != "" {
@@ -86,7 +85,13 @@ func testXrayBinaryScan(t *testing.T, format, policyName, watchName string) stri
8685 // Include violations and vulnerabilities
8786 args = append (args , "--watches=" + watchName , "--vuln" )
8887 }
89- return securityTests .PlatformCli .RunCliCmdWithOutput (t , args ... )
88+ output , err := securityTests .PlatformCli .RunCliCmdWithOutputs (t , args ... )
89+ if errorExpected {
90+ assert .Error (t , err )
91+ } else {
92+ assert .NoError (t , err )
93+ }
94+ return output
9095}
9196
9297func TestXrayBinaryScanWithBypassArchiveLimits (t * testing.T ) {
0 commit comments