Skip to content

Commit

Permalink
Move XSC tests to unit tests and remove from suits
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Sep 10, 2023
1 parent cd281a3 commit 412c1e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ jobs:
- name: artifactory tests
run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.${{ matrix.suite }} --ci.runId=${{ runner.os }}-${{ matrix.suite }}

JFrog-Client-Go-Ds-Xr-Xsc-Tests:
JFrog-Client-Go-Ds-Xr-Tests:
needs: Pretest
name: ${{ matrix.suite }} ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
suite: [ distribution, xray, xsc ]
suite: [ distribution, xray ]
os: [ ubuntu, windows, macos ]
runs-on: ${{ matrix.os }}-latest
steps:
Expand Down
12 changes: 5 additions & 7 deletions tests/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,9 @@ func GetXrayDetails() auth.ServiceDetails {
xrayDetails := xrayAuth.NewXrayDetails()
xrayUrl := clientutils.AddTrailingSlashIfNeeded(*XrayUrl)
xrayDetails.SetUrl(xrayUrl)
if *TestXsc {
xrayDetails.SetXscUrl(strings.Replace(xrayUrl, "xray", "xsc", 1))
xrayDetails.SetXscVersion("0.0.0")
}
xrayDetails.SetXscUrl(strings.Replace(xrayUrl, "xray", "xsc", 1))
xrayDetails.SetXscVersion("0.0.0")

setAuthenticationDetail(xrayDetails)
return xrayDetails
}
Expand Down Expand Up @@ -1130,9 +1129,8 @@ func createSecurityServiceManager() {
xrayDetails.SetUrl(xrayUrl)
xrayDetails.SetXscUrl(strings.Replace(xrayUrl, "/xray/", "/xsc/", 1))
// XSC version is used to determine if XSC in enabled or not.
if *TestXsc {
xrayDetails.SetXscVersion("0.0.0")
}
xrayDetails.SetXscVersion("0.0.0")

setAuthenticationDetail(xrayDetails)
initSecurityManagerByServerDetails(xrayDetails)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/xray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func initXrayTest(t *testing.T) {

type testXrayDetails struct {
auth.ServiceDetails
version string
version string
xscVersion string

Check failure on line 114 in tests/xray_test.go

View workflow job for this annotation

GitHub Actions / Static-Check

field `xscVersion` is unused (unused)
}

func newTestXrayDetails(serviceDetails auth.ServiceDetails) testXrayDetails {
Expand Down
1 change: 0 additions & 1 deletion tests/xrayscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestXrayScanGraph(t *testing.T) {
assert.NoError(t, err)
securityServiceManager, err = services2.New(serviceConfig)
assert.NoError(t, err)
assertSecurityManagerType(t)

scanId, err := securityServiceManager.ScanGraph(&services2.XrayGraphScanParams{})
assert.NoError(t, err)
Expand Down
21 changes: 3 additions & 18 deletions tests/xsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestXscScanGraph(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

scanId, err := securityServiceManager.ScanGraph(test.xrayGraphParams)
assert.NoError(t, err)
assert.Equal(t, test.expectedMultiScanId, test.xrayGraphParams.MultiScanId)
Expand All @@ -52,13 +53,6 @@ func TestXscEnabled(t *testing.T) {
}

func initXscTest(t *testing.T) {
if !*TestXsc {
t.Skip("Skipping xray test. To run xray test add the '-test.xsc=true' option.")
}
prepareXscTest(t)
}

func prepareXscTest(t *testing.T) {
initializeTestSecurityManager(t, initMockXscServer())
}

Expand All @@ -80,14 +74,5 @@ func initializeTestSecurityManager(t *testing.T, xscDetails testXrayDetails) {
securityServiceManager, err = services.New(serviceConfig)
assert.NoError(t, err)
// Assert correct security manager Xsc/Xray
assertSecurityManagerType(t)
}

func assertSecurityManagerType(t *testing.T) {
switch securityServiceManager.(type) {
case *services.XscServicesManger:
assert.Equal(t, true, *TestXsc)
case *services.XrayServicesManager:
assert.Equal(t, false, *TestXsc)
}
}
assert.IsType(t, securityServiceManager,&services.XscServicesManger{})
}

0 comments on commit 412c1e6

Please sign in to comment.