Skip to content

Commit

Permalink
Add XSC tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Aug 24, 2023
1 parent e4ca999 commit cb85c8f
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/xrayTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: [ xray , xsc ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -61,9 +62,9 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run Xray tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.xray --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --jfrog.user=${{ secrets.PLATFORM_USER }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}
- name: Run Xray And Xsc tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.${{ matrix.suite }} --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --jfrog.user=${{ secrets.PLATFORM_USER }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}
if: ${{ matrix.os != 'ubuntu-latest' }}
- name: Run Docker scan and Xray tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.xray --test.dockerScan --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}
- name: Run Docker scan and ${{ matrix.suite }} tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.${{ matrix.suite }} --test.dockerScan --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}
if: ${{ matrix.os == 'ubuntu-latest' }}
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The available flags are:
The available test types are:

| Type | Description |
| -------------------- | ------------------ |
|----------------------|--------------------|
| `-test.artifactory` | Artifactory tests |
| `-test.access` | Access tests |
| `-test.npm` | Npm tests |
Expand All @@ -110,6 +110,7 @@ The available test types are:
| `-test.distribution` | Distribution tests |
| `-test.transfer` | Transfer tests |
| `-test.xray` | Xray tests |
| `-test.xsc` | Xsc tests |

When running the tests, builds and repositories with timestamps will be created, for example: `cli-rt1-1592990748` and `cli-rt2-1592990748`. The content of these repositories will be deleted once the tests are completed.

Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ require (

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230820165857-52ff32c4d8eb

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230823084658-46b57ad6ca5a
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/eyaldelarea/jfrog-cli-core/v2 v2.0.0-20230824082025-8aa7d33c56ed

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230803140217-0a5f43783ae8
replace github.com/jfrog/jfrog-client-go => github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230824065102-75aaa3dc8aa9
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/eyaldelarea/jfrog-cli-core/v2 v2.0.0-20230824082025-8aa7d33c56ed h1:U9wiRQdwrZd2jIxpk0M544+Q5t9Yl03y4spf1C9AY/A=
github.com/eyaldelarea/jfrog-cli-core/v2 v2.0.0-20230824082025-8aa7d33c56ed/go.mod h1:Z6c/gAa65wZ/PlwLcAtEPFI1zBfWan1oFf/q2EDTZOc=
github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230824065102-75aaa3dc8aa9 h1:mjWx7wq3DRmP7EhjvV/xQUIihTfr1jVI21FWj+cPqM8=
github.com/eyaldelarea/jfrog-client-go v1.28.4-0.20230824065102-75aaa3dc8aa9/go.mod h1:icb00ZJN/mMMNkQduHDkzpqsXH9Flwi3f3COYexq3Nc=
github.com/forPelevin/gomoji v1.1.8 h1:JElzDdt0TyiUlecy6PfITDL6eGvIaxqYH1V52zrd0qQ=
github.com/forPelevin/gomoji v1.1.8/go.mod h1:8+Z3KNGkdslmeGZBC3tCrwMrcPy5GRzAD+gL9NAwMXg=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
Expand Down Expand Up @@ -241,10 +245,6 @@ github.com/jfrog/build-info-go v1.9.8 h1:D8/ga+YgQpqp/CJj2zteS4/twmSy8zvm1v9lCd2
github.com/jfrog/build-info-go v1.9.8/go.mod h1:t31QRpH5xUJKw8XkQlAA+Aq7aanyS1rrzpcK8xSNVts=
github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk=
github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/jfrog-cli-core/v2 v2.41.0 h1:M2z/BuZKZc4DHtmO3Jx49bf5qCLyfLG8jJ9/iKpkALs=
github.com/jfrog/jfrog-cli-core/v2 v2.41.0/go.mod h1:YqB9rEJF1P7uGLIPUvF5qdDDf1zM5f4DneIQNkqyAfs=
github.com/jfrog/jfrog-client-go v1.31.5 h1:dYVgIJzMwX+EU9GEELKPSHFLyfW6UrrjZWMEZtAyx6A=
github.com/jfrog/jfrog-client-go v1.31.5/go.mod h1:icb00ZJN/mMMNkQduHDkzpqsXH9Flwi3f3COYexq3Nc=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk=
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func setupIntegrationTests() {
if *tests.TestPlugins {
InitPluginsTests()
}
if *tests.TestXray {
if *tests.TestXray || *tests.TestXsc {
InitXrayTests()
}
if *tests.TestAccess {
Expand Down
4 changes: 4 additions & 0 deletions utils/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var (
TestPoetry *bool
TestPlugins *bool
TestXray *bool
TestXsc *bool
TestAccess *bool
TestTransfer *bool
TestLifecycle *bool
Expand Down Expand Up @@ -104,6 +105,7 @@ func init() {
TestPoetry = flag.Bool("test.poetry", false, "Test Poetry")
TestPlugins = flag.Bool("test.plugins", false, "Test Plugins")
TestXray = flag.Bool("test.xray", false, "Test Xray")
TestXsc = flag.Bool("test.xsc", false, "Test Xsc")
TestAccess = flag.Bool("test.access", false, "Test Access")
TestTransfer = flag.Bool("test.transfer", false, "Test files transfer")
TestLifecycle = flag.Bool("test.lc", false, "Test lifecycle")
Expand Down Expand Up @@ -403,6 +405,7 @@ func GetNonVirtualRepositories() map[*string]string {
TestPoetry: {&PoetryRemoteRepo},
TestPlugins: {&RtRepo1},
TestXray: {},
TestXsc: {},
TestAccess: {&RtRepo1},
TestTransfer: {&RtRepo1, &RtRepo2, &MvnRepo1, &MvnRemoteRepo, &DockerRemoteRepo},
TestLifecycle: {&RtDevRepo, &RtProdRepo},
Expand All @@ -428,6 +431,7 @@ func GetVirtualRepositories() map[*string]string {
TestPoetry: {&PoetryVirtualRepo},
TestPlugins: {},
TestXray: {},
TestXsc: {},
TestAccess: {},
}
return getNeededRepositories(virtualReposMap)
Expand Down
3 changes: 2 additions & 1 deletion xray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func InitXrayTests() {

func authenticateXray() string {
*tests.JfrogUrl = clientUtils.AddTrailingSlashIfNeeded(*tests.JfrogUrl)
xrayDetails = &config.ServerDetails{Url: *tests.JfrogUrl, XrayUrl: *tests.JfrogUrl + tests.XrayEndpoint}
xrayDetails = &config.ServerDetails{Url: *tests.JfrogUrl, XrayUrl: *tests.JfrogUrl + tests.XrayEndpoint, XscUrl: *tests.JfrogUrl + tests.XscEndpoint}
cred := fmt.Sprintf("--url=%s", xrayDetails.XrayUrl)
if *tests.JfrogAccessToken != "" {
xrayDetails.AccessToken = *tests.JfrogAccessToken
Expand All @@ -75,6 +75,7 @@ func authenticateXray() string {
coreutils.ExitOnErr(errors.New("Failed while attempting to authenticate with Xray: " + err.Error()))
}
xrayDetails.XrayUrl = xrayAuth.GetUrl()
xrayDetails.XscUrl = xrayAuth.GetXscUrl()
return cred
}

Expand Down
26 changes: 26 additions & 0 deletions xsc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/xray/commands/utils"
"github.com/jfrog/jfrog-cli/utils/tests"
"testing"
)

func initXscTest(t *testing.T, minVersion string) {
if !*tests.TestXsc {
t.Skip("Skipping Xsc test. To run xsc test add the '-test.xsc=true' option.")
}
*tests.TestXray = true
validateXscVersion(t, minVersion)
}
func validateXscVersion(t *testing.T, minVersion string) {
err := coreutils.ValidateMinimumVersion(coreutils.Xsc, xrayDetails.XscVersion, minVersion)
if err != nil {
t.Skip(err)
}
}
func TestXSCAudit(t *testing.T) {
initXscTest(t, utils.XscMinVersion)
testXrayAuditNpm(t, "json")
}

0 comments on commit cb85c8f

Please sign in to comment.