Skip to content

Commit e16b867

Browse files
committed
Add CreateJfrogHomeConfig to all binary scan tests to fix authentication
Binary scan tests were failing because they were missing server configuration. The scan command was trying to use --server-id logic but couldn't find any configured servers, leading to 'JFrog Xray URL must be provided' errors. This fix adds CreateJfrogHomeConfig(t, "", true) to all binary scan tests to create the 'default' server configuration from test credentials, matching how Docker scan tests work with InitNativeDockerTest. Tests fixed: - TestXrayBinaryScanJson - TestXrayBinaryScanSimpleJson - TestXrayBinaryScanCycloneDx - TestXrayBinaryScanJsonDocker - TestXrayBinaryScanJsonGeneric - TestXrayBinaryScanJsonJar - TestXrayBinaryScanJsonWithProgress - TestXrayBinaryScanSimpleJsonWithProgress - TestXrayBinaryScanWithBypassArchiveLimits
1 parent 4e8f8cf commit e16b867

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scans_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func runXrayBinaryScan(t *testing.T, params binaryScanParams) (string, error) {
9898
// Binary scan tests
9999
func TestXrayBinaryScanJson(t *testing.T) {
100100
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
101+
integration.CreateJfrogHomeConfig(t, "", true)
101102
output := testXrayMultipleBinariesScan(t, binaryScanParams{Format: format.Json, WithLicense: true}, false)
102103
validations.VerifyJsonResults(t, output, validations.ValidationParams{
103104
Total: &validations.TotalCount{Licenses: 1, Vulnerabilities: 1},
@@ -106,6 +107,7 @@ func TestXrayBinaryScanJson(t *testing.T) {
106107

107108
func TestXrayBinaryScanSimpleJson(t *testing.T) {
108109
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
110+
integration.CreateJfrogHomeConfig(t, "", true)
109111
output := testXrayBinaryScanWithWatch(t, format.SimpleJson, "xray-scan-binary-policy", "scan-binary-watch", true)
110112
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{
111113
Total: &validations.TotalCount{Licenses: 1, Vulnerabilities: 1, Violations: 1},
@@ -114,6 +116,7 @@ func TestXrayBinaryScanSimpleJson(t *testing.T) {
114116

115117
func TestXrayBinaryScanCycloneDx(t *testing.T) {
116118
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
119+
integration.CreateJfrogHomeConfig(t, "", true)
117120
output := testXrayBinaryScanJASArtifact(t, format.CycloneDx, "backupfriend-client.tar.gz", false)
118121
validations.VerifyCycloneDxResults(t, output, validations.ValidationParams{
119122
Total: &validations.TotalCount{Vulnerabilities: 4},
@@ -126,6 +129,7 @@ func TestXrayBinaryScanCycloneDx(t *testing.T) {
126129

127130
func TestXrayBinaryScanJsonDocker(t *testing.T) {
128131
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
132+
integration.CreateJfrogHomeConfig(t, "", true)
129133
// In Windows, indexer fails to index the tar, Caused by: failed to rename path for layer so we run in clean copy in temp dir
130134
output := testXrayBinaryScanJASArtifact(t, format.SimpleJson, "xmas.tar", true)
131135
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{
@@ -139,6 +143,7 @@ func TestXrayBinaryScanJsonDocker(t *testing.T) {
139143

140144
func TestXrayBinaryScanJsonGeneric(t *testing.T) {
141145
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
146+
integration.CreateJfrogHomeConfig(t, "", true)
142147
output := testXrayBinaryScanJASArtifact(t, format.SimpleJson, "backupfriend-client.tar.gz", false)
143148
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{
144149
Total: &validations.TotalCount{Vulnerabilities: 4},
@@ -151,6 +156,7 @@ func TestXrayBinaryScanJsonGeneric(t *testing.T) {
151156

152157
func TestXrayBinaryScanJsonJar(t *testing.T) {
153158
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
159+
integration.CreateJfrogHomeConfig(t, "", true)
154160
output := testXrayBinaryScanJASArtifact(t, format.SimpleJson, "student-services-security-0.0.1.jar", false)
155161
validations.VerifySimpleJsonResults(t, output, validations.ValidationParams{
156162
Total: &validations.TotalCount{Vulnerabilities: 41},
@@ -163,6 +169,7 @@ func TestXrayBinaryScanJsonJar(t *testing.T) {
163169

164170
func TestXrayBinaryScanJsonWithProgress(t *testing.T) {
165171
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
172+
integration.CreateJfrogHomeConfig(t, "", true)
166173
callback := commonTests.MockProgressInitialization()
167174
defer callback()
168175
output := testXrayMultipleBinariesScan(t, binaryScanParams{Format: format.Json, WithLicense: true}, false)
@@ -173,6 +180,7 @@ func TestXrayBinaryScanJsonWithProgress(t *testing.T) {
173180

174181
func TestXrayBinaryScanSimpleJsonWithProgress(t *testing.T) {
175182
integration.InitScanTest(t, scangraph.GraphScanMinXrayVersion)
183+
integration.CreateJfrogHomeConfig(t, "", true)
176184
callback := commonTests.MockProgressInitialization()
177185
defer callback()
178186
output := testXrayBinaryScanWithWatch(t, format.SimpleJson, "xray-scan-binary-progress-policy", "scan-binary-progress-watch", true)
@@ -222,10 +230,11 @@ func testXrayBinaryScanJASArtifact(t *testing.T, format format.OutputFormat, art
222230

223231
func TestXrayBinaryScanWithBypassArchiveLimits(t *testing.T) {
224232
integration.InitScanTest(t, scan.BypassArchiveLimitsMinXrayVersion)
233+
integration.CreateJfrogHomeConfig(t, "", true)
225234
unsetEnv := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JF_INDEXER_COMPRESS_MAXENTITIES", "10")
226235
defer unsetEnv()
227236
binariesPath := filepath.Join(filepath.FromSlash(securityTests.GetTestResourcesPath()), "projects", "binaries", "*")
228-
scanArgs := []string{"scan", "--server-id=default", binariesPath, "--format=json", "--licenses"}
237+
scanArgs := []string{"scan", binariesPath, "--format=json", "--licenses"}
229238
// Run without bypass flag and expect scan to fail
230239
err := securityTests.PlatformCli.Exec(scanArgs...)
231240
// Expect error

0 commit comments

Comments
 (0)