diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5801cbc44..0712f08fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,13 +13,13 @@ concurrency: group: ${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true jobs: - JFrog-Client-Go-Tests: + JFrog-Client-Go-Ds-Xr-Access-Tests: if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push' name: ${{ matrix.suite }} ${{ matrix.os }} strategy: fail-fast: false matrix: - suite: [artifactory, distribution, xray, access] + suite: [distribution, xray, access] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: @@ -27,12 +27,15 @@ jobs: uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - name: Install Go uses: actions/setup-go@v2 with: go-version: 1.17.x + - name: Lint run: go vet -v ./... + - name: ${{ matrix.suite }} tests run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.${{ matrix.suite }}=true --rt.url=${{ secrets.CLI_RT_URL }} --ds.url=${{ secrets.CLI_DIST_URL }} --xr.url=${{ secrets.CLI_XRAY_URL }} --access.url=${{ secrets.CLI_ACCESS_URL }} --rt.user=${{ secrets.CLI_RT_USER }} --rt.password=${{ secrets.CLI_RT_PASSWORD }} --access.token=${{ secrets.CLI_ACCESS_TOKEN }} --ci.runId=${{ runner.os }}-${{ matrix.suite }} JFrog-Client-Go-Pipelines-Tests: @@ -49,10 +52,12 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17.x + - name: Checkout code uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + - name: pipelines tests run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.pipelines=true --rt.url=${{ secrets.CLI_RT_URL }} --pipe.url=${{ secrets.CLI_PIPE_URL }} --rt.user=${{ secrets.CLI_RT_USER }} --rt.password=${{ secrets.CLI_RT_PASSWORD }} --pipe.accessToken=${{ secrets.CLI_PIPE_ACCESS_TOKE }} --pipe.vcsToken=${{ secrets.CLI_PIPE_VCS_TOKEN }} --pipe.vcsRepo=${{ secrets.CLI_PIPE_VCS_REPO }} --pipe.vcsBranch=${{ secrets.CLI_PIPE_VCS_BRANCH }} --ci.runId=${{ runner.os }}-pipe JFrog-Client-Go-Repository-Tests: @@ -64,9 +69,49 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17.x + - name: Checkout code uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Artifactory + run: | + go install github.com/jfrog/jfrog-testing-infra/local-rt-setup@latest + ~/go/bin/local-rt-setup + env: + RTLIC: ${{secrets.RTLIC}} + GOPROXY: direct + - name: repository tests - run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.repository=true --rt.url=${{ secrets.CLI_RT_URL }} --rt.user=${{ secrets.CLI_RT_USER }} --rt.password=${{ secrets.CLI_RT_PASSWORD }} --access.token=${{ secrets.CLI_ACCESS_TOKEN }} + run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.repository=true --rt.url='http://localhost:8081/artifactory/' --rt.user='admin' --rt.password='password' + JFrog-Client-Go-Artifactory-Tests: + if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push' + name: ${{ matrix.suite }} ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + suite: [artifactory] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.17.x + + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Artifactory + run: | + go install github.com/jfrog/jfrog-testing-infra/local-rt-setup@latest + ~/go/bin/local-rt-setup + env: + RTLIC: ${{secrets.RTLIC}} + GOPROXY: direct + + - name: artifactory tests + run: go test -v github.com/jfrog/jfrog-client-go/tests --timeout 0 --test.artifactory=true --rt.url='http://localhost:8081/artifactory/' --rt.user='admin' --rt.password='password' --ci.runId=${{ runner.os }}-${{ matrix.suite }} diff --git a/tests/artifactoryfederatedrepository_test.go b/tests/artifactoryfederatedrepository_test.go index 1ea522b0d..295e5c44f 100644 --- a/tests/artifactoryfederatedrepository_test.go +++ b/tests/artifactoryfederatedrepository_test.go @@ -74,7 +74,9 @@ func federatedAlpineTest(t *testing.T) { setFederatedRepositoryBaseParams(&afp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Alpine(afp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, afp) @@ -92,7 +94,9 @@ func federatedBowerTest(t *testing.T) { setFederatedRepositoryBaseParams(&bfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Bower(bfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, bfp) @@ -111,7 +115,9 @@ func federatedCargoTest(t *testing.T) { setCargoRepositoryParams(&cfp.CargoRepositoryParams, false) err := testsCreateFederatedRepositoryService.Cargo(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -130,7 +136,9 @@ func federatedChefTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Chef(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -148,7 +156,9 @@ func federatedCocoapodsTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Cocoapods(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -166,7 +176,9 @@ func federatedComposerTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Composer(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -184,7 +196,9 @@ func federatedConanTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Conan(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -202,7 +216,9 @@ func federatedCondaTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Conda(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -220,7 +236,9 @@ func federatedCranTest(t *testing.T) { setFederatedRepositoryBaseParams(&cfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Cran(cfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cfp) @@ -239,7 +257,9 @@ func federatedDebianTest(t *testing.T) { setDebianRepositoryParams(&dfp.DebianRepositoryParams, false) err := testsCreateFederatedRepositoryService.Debian(dfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dfp) @@ -259,7 +279,9 @@ func federatedDockerTest(t *testing.T) { setDockerRepositoryParams(&dfp.DockerRepositoryParams, false) err := testsCreateFederatedRepositoryService.Docker(dfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dfp) @@ -278,7 +300,9 @@ func federatedGemsTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Gems(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -296,7 +320,9 @@ func federatedGenericTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Generic(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -314,7 +340,9 @@ func federatedGitlfsTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Gitlfs(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -332,7 +360,9 @@ func federatedGoTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Go(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -351,7 +381,9 @@ func federatedGradleTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&gfp.JavaPackageManagersRepositoryParams, false) err := testsCreateFederatedRepositoryService.Gradle(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -370,7 +402,9 @@ func federatedHelmTest(t *testing.T) { setFederatedRepositoryBaseParams(&hfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Helm(hfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, hfp) @@ -389,7 +423,9 @@ func federatedIvyTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&ifp.JavaPackageManagersRepositoryParams, false) err := testsCreateFederatedRepositoryService.Ivy(ifp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, ifp) @@ -409,7 +445,9 @@ func federatedMavenTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&mfp.JavaPackageManagersRepositoryParams, false) err := testsCreateFederatedRepositoryService.Maven(mfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, mfp) @@ -428,7 +466,9 @@ func federatedNpmTest(t *testing.T) { setFederatedRepositoryBaseParams(&nfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Npm(nfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nfp) @@ -447,7 +487,9 @@ func federatedNugetTest(t *testing.T) { setNugetRepositoryParams(&nfp.NugetRepositoryParams, false) err := testsCreateFederatedRepositoryService.Nuget(nfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nfp) @@ -466,7 +508,9 @@ func federatedOpkgTest(t *testing.T) { setFederatedRepositoryBaseParams(&ofp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Opkg(ofp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, ofp) @@ -484,7 +528,9 @@ func federatedPuppetTest(t *testing.T) { setFederatedRepositoryBaseParams(&pfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Puppet(pfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, pfp) @@ -502,7 +548,9 @@ func federatedPypiTest(t *testing.T) { setFederatedRepositoryBaseParams(&pfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Pypi(pfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, pfp) @@ -521,7 +569,9 @@ func federatedRpmTest(t *testing.T) { setRpmRepositoryParams(&rfp.RpmRepositoryParams, false) err := testsCreateFederatedRepositoryService.Rpm(rfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, rfp) @@ -541,7 +591,9 @@ func federatedSbtTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&sfp.JavaPackageManagersRepositoryParams, false) err := testsCreateFederatedRepositoryService.Sbt(sfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, sfp) @@ -560,7 +612,9 @@ func federatedVagrantTest(t *testing.T) { setFederatedRepositoryBaseParams(&vfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Vagrant(vfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, vfp) @@ -579,7 +633,9 @@ func federatedYumTest(t *testing.T) { setRpmRepositoryParams(&yfp.RpmRepositoryParams, false) err := testsCreateFederatedRepositoryService.Yum(yfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // "yum" package type is converted to "rpm" by Artifactory, so we have to change it too to pass the validation. yfp.PackageType = "rpm" @@ -598,7 +654,9 @@ func federatedCreateWithParamTest(t *testing.T) { params := services.NewFederatedRepositoryBaseParams() params.Key = repoKey err := testsRepositoriesService.CreateFederated(params) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, params) } @@ -611,7 +669,9 @@ func getFederatedRepoDetailsTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Generic(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getRepo(t, repoKey) @@ -631,7 +691,9 @@ func getAllFederatedRepoDetailsTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Generic(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getAllRepos(t, "federated", "") diff --git a/tests/artifactoryfederation_test.go b/tests/artifactoryfederation_test.go index c0af8ddf1..08632bfbd 100644 --- a/tests/artifactoryfederation_test.go +++ b/tests/artifactoryfederation_test.go @@ -34,7 +34,9 @@ func localConvertLocalToFederatedTest(t *testing.T) { glp.ArchiveBrowsingEnabled = &falseValue err := testsCreateLocalRepositoryService.Generic(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) err = testsFederationService.ConvertLocalToFederated(repoKey) @@ -54,7 +56,9 @@ func localTriggerFederatedFullSyncAllTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Generic(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) @@ -69,7 +73,9 @@ func localTriggerFederatedFullSyncMirrorTest(t *testing.T) { setFederatedRepositoryBaseParams(&gfp.FederatedRepositoryBaseParams, false) err := testsCreateFederatedRepositoryService.Generic(gfp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gfp) diff --git a/tests/artifactorylocalrepository_test.go b/tests/artifactorylocalrepository_test.go index 91ed6eda8..4fb0ae75e 100644 --- a/tests/artifactorylocalrepository_test.go +++ b/tests/artifactorylocalrepository_test.go @@ -7,43 +7,41 @@ import ( "github.com/stretchr/testify/assert" ) -// Temporarily disabled - -// func TestArtifactoryLocalRepository(t *testing.T) { -// initRepositoryTest(t) -// t.Run("localAlpineTest", localAlpineTest) -// t.Run("localBowerTest", localBowerTest) -// t.Run("localCargoTest", localCargoTest) -// t.Run("localChefTest", localChefTest) -// t.Run("localCocoapodsTest", localCocoapodsTest) -// t.Run("localComposerTest", localComposerTest) -// t.Run("localConanTest", localConanTest) -// t.Run("localCondaTest", localCondaTest) -// t.Run("localCranTest", localCranTest) -// t.Run("localDebianTest", localDebianTest) -// t.Run("localDockerTest", localDockerTest) -// t.Run("localGemsTest", localGemsTest) -// t.Run("localGenericTest", localGenericTest) -// t.Run("localGitlfsTest", localGitlfsTest) -// t.Run("localGoTest", localGoTest) -// t.Run("localGradleTest", localGradleTest) -// t.Run("localHelmTest", localHelmTest) -// t.Run("localIvyTest", localIvyTest) -// t.Run("localMavenTest", localMavenTest) -// t.Run("localNpmTest", localNpmTest) -// t.Run("localNugetTest", localNugetTest) -// t.Run("localOkgTest", localOpkgTest) -// t.Run("localPuppetTest", localPuppetTest) -// t.Run("localPypiTest", localPypiTest) -// t.Run("localRpmTest", localRpmTest) -// t.Run("localSbtTest", localSbtTest) -// t.Run("localVagrantTest", localVagrantTest) -// t.Run("localYumTest", localYumTest) -// t.Run("localCreateWithParamTest", localCreateWithParamTest) -// t.Run("getLocalRepoDetailsTest", getLocalRepoDetailsTest) -// t.Run("getAllLocalRepoDetailsTest", getAllLocalRepoDetailsTest) -// t.Run("isLocalRepoExistsTest", isLocalRepoExistsTest) -// } +func TestArtifactoryLocalRepository(t *testing.T) { + initRepositoryTest(t) + t.Run("localAlpineTest", localAlpineTest) + t.Run("localBowerTest", localBowerTest) + t.Run("localCargoTest", localCargoTest) + t.Run("localChefTest", localChefTest) + t.Run("localCocoapodsTest", localCocoapodsTest) + t.Run("localComposerTest", localComposerTest) + t.Run("localConanTest", localConanTest) + t.Run("localCondaTest", localCondaTest) + t.Run("localCranTest", localCranTest) + t.Run("localDebianTest", localDebianTest) + t.Run("localDockerTest", localDockerTest) + t.Run("localGemsTest", localGemsTest) + t.Run("localGenericTest", localGenericTest) + t.Run("localGitlfsTest", localGitlfsTest) + t.Run("localGoTest", localGoTest) + t.Run("localGradleTest", localGradleTest) + t.Run("localHelmTest", localHelmTest) + t.Run("localIvyTest", localIvyTest) + t.Run("localMavenTest", localMavenTest) + t.Run("localNpmTest", localNpmTest) + t.Run("localNugetTest", localNugetTest) + t.Run("localOkgTest", localOpkgTest) + t.Run("localPuppetTest", localPuppetTest) + t.Run("localPypiTest", localPypiTest) + t.Run("localRpmTest", localRpmTest) + t.Run("localSbtTest", localSbtTest) + t.Run("localVagrantTest", localVagrantTest) + t.Run("localYumTest", localYumTest) + t.Run("localCreateWithParamTest", localCreateWithParamTest) + t.Run("getLocalRepoDetailsTest", getLocalRepoDetailsTest) + t.Run("getAllLocalRepoDetailsTest", getAllLocalRepoDetailsTest) + t.Run("isLocalRepoExistsTest", isLocalRepoExistsTest) +} func setLocalRepositoryBaseParams(params *services.LocalRepositoryBaseParams, isUpdate bool) { setRepositoryBaseParams(¶ms.RepositoryBaseParams, isUpdate) @@ -62,7 +60,9 @@ func localAlpineTest(t *testing.T) { setLocalRepositoryBaseParams(&alp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Alpine(alp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, alp) @@ -80,7 +80,9 @@ func localBowerTest(t *testing.T) { setLocalRepositoryBaseParams(&blp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Bower(blp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, blp) @@ -99,7 +101,9 @@ func localCargoTest(t *testing.T) { setCargoRepositoryParams(&clp.CargoRepositoryParams, false) err := testsCreateLocalRepositoryService.Cargo(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -118,7 +122,9 @@ func localChefTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Chef(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -136,7 +142,9 @@ func localCocoapodsTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Cocoapods(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -154,7 +162,9 @@ func localComposerTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Composer(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -172,7 +182,9 @@ func localConanTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Conan(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -190,7 +202,9 @@ func localCondaTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Conda(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -208,7 +222,9 @@ func localCranTest(t *testing.T) { setLocalRepositoryBaseParams(&clp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Cran(clp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, clp) @@ -227,7 +243,9 @@ func localDebianTest(t *testing.T) { setDebianRepositoryParams(&dlp.DebianRepositoryParams, false) err := testsCreateLocalRepositoryService.Debian(dlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dlp) @@ -247,7 +265,9 @@ func localDockerTest(t *testing.T) { setDockerRepositoryParams(&dlp.DockerRepositoryParams, false) err := testsCreateLocalRepositoryService.Docker(dlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dlp) @@ -266,7 +286,9 @@ func localGemsTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Gems(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, glp) @@ -284,7 +306,9 @@ func localGenericTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Generic(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, glp) @@ -302,7 +326,9 @@ func localGitlfsTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Gitlfs(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, glp) @@ -320,7 +346,9 @@ func localGoTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Go(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, glp) @@ -339,7 +367,9 @@ func localGradleTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&glp.JavaPackageManagersRepositoryParams, false) err := testsCreateLocalRepositoryService.Gradle(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, glp) @@ -358,7 +388,9 @@ func localHelmTest(t *testing.T) { setLocalRepositoryBaseParams(&hlp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Helm(hlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, hlp) @@ -377,7 +409,9 @@ func localIvyTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&ilp.JavaPackageManagersRepositoryParams, false) err := testsCreateLocalRepositoryService.Ivy(ilp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, ilp) @@ -397,7 +431,9 @@ func localMavenTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&mlp.JavaPackageManagersRepositoryParams, false) err := testsCreateLocalRepositoryService.Maven(mlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, mlp) @@ -416,7 +452,9 @@ func localNpmTest(t *testing.T) { setLocalRepositoryBaseParams(&nlp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Npm(nlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nlp) @@ -435,7 +473,9 @@ func localNugetTest(t *testing.T) { setNugetRepositoryParams(&nlp.NugetRepositoryParams, false) err := testsCreateLocalRepositoryService.Nuget(nlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nlp) @@ -454,7 +494,9 @@ func localOpkgTest(t *testing.T) { setLocalRepositoryBaseParams(&olp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Opkg(olp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, olp) @@ -472,7 +514,9 @@ func localPuppetTest(t *testing.T) { setLocalRepositoryBaseParams(&plp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Puppet(plp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, plp) @@ -490,7 +534,9 @@ func localPypiTest(t *testing.T) { setLocalRepositoryBaseParams(&plp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Pypi(plp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, plp) @@ -509,7 +555,9 @@ func localRpmTest(t *testing.T) { setRpmRepositoryParams(&rlp.RpmRepositoryParams, false) err := testsCreateLocalRepositoryService.Rpm(rlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, rlp) @@ -529,7 +577,9 @@ func localSbtTest(t *testing.T) { setJavaPackageManagersRepositoryParams(&slp.JavaPackageManagersRepositoryParams, false) err := testsCreateLocalRepositoryService.Sbt(slp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, slp) @@ -548,7 +598,9 @@ func localVagrantTest(t *testing.T) { setLocalRepositoryBaseParams(&vlp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Vagrant(vlp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, vlp) @@ -570,7 +622,9 @@ func localYumTest(t *testing.T) { ylp.YumGroupFileNames = "filename" err := testsCreateLocalRepositoryService.Yum(ylp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // "yum" package type is converted to "rpm" by Artifactory, so we have to change it too to pass the validation. ylp.PackageType = "rpm" @@ -592,7 +646,9 @@ func localCreateWithParamTest(t *testing.T) { params := services.NewLocalRepositoryBaseParams() params.Key = repoKey err := testsRepositoriesService.CreateLocal(params) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, params) } @@ -605,7 +661,9 @@ func getLocalRepoDetailsTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Generic(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getRepo(t, repoKey) @@ -627,7 +685,9 @@ func isLocalRepoExistsTest(t *testing.T) { glp.Key = repoKey setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Generic(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Validate repo exists exists = isRepoExists(t, repoKey) @@ -642,7 +702,9 @@ func getAllLocalRepoDetailsTest(t *testing.T) { setLocalRepositoryBaseParams(&glp.LocalRepositoryBaseParams, false) err := testsCreateLocalRepositoryService.Generic(glp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getAllRepos(t, "local", "") diff --git a/tests/artifactoryremoterepository_test.go b/tests/artifactoryremoterepository_test.go index fd0c30ee6..dd7db0fc5 100644 --- a/tests/artifactoryremoterepository_test.go +++ b/tests/artifactoryremoterepository_test.go @@ -10,45 +10,43 @@ import ( const ArtifactoryLocalFileCacheSuffix = " (local file cache)" const MavenCentralUrl = "https://repo.maven.apache.org" -// Temporarily disabled - -// func TestArtifactoryRemoteRepository(t *testing.T) { -// initRepositoryTest(t) -// t.Run("remoteAlpineTest", remoteAlpineTest) -// t.Run("remoteBowerTest", remoteBowerTest) -// t.Run("remoteCargoTest", remoteCargoTest) -// t.Run("remoteChefTest", remoteChefTest) -// t.Run("remoteCocoapodsTest", remoteCocoapodsTest) -// t.Run("remoteComposerTest", remoteComposerTest) -// t.Run("remoteConanTest", remoteConanTest) -// t.Run("remoteCondaTest", remoteCondaTest) -// t.Run("remoteCranTest", remoteCranTest) -// t.Run("remoteDebianTest", remoteDebianTest) -// t.Run("remoteDockerTest", remoteDockerTest) -// t.Run("remoteGemsTest", remoteGemsTest) -// t.Run("remoteGenericTest", remoteGenericTest) -// t.Run("remoteGitlfsTest", remoteGitlfsTest) -// t.Run("remoteGoTest", remoteGoTest) -// t.Run("remoteGradleTest", remoteGradleTest) -// t.Run("remoteHelmTest", remoteHelmTest) -// t.Run("remoteIvyTest", remoteIvyTest) -// t.Run("remoteMavenTest", remoteMavenTest) -// t.Run("remoteNpmTest", remoteNpmTest) -// t.Run("remoteNugetTest", remoteNugetTest) -// t.Run("remoteOkgTest", remoteOpkgTest) -// t.Run("remoteP2Test", remoteP2Test) -// t.Run("remotePuppetTest", remotePuppetTest) -// t.Run("remotePypiTest", remotePypiTest) -// t.Run("remoteRpmTest", remoteRpmTest) -// t.Run("remoteSbtTest", remoteSbtTest) -// t.Run("remoteVcsTest", remoteVcsTest) -// t.Run("remoteYumTest", remoteYumTest) -// t.Run("remoteGenericSmartRemoteTest", remoteGenericSmartRemoteTest) -// t.Run("remoteCreateWithParamTest", remoteCreateWithParamTest) -// t.Run("getRemoteRepoDetailsTest", getRemoteRepoDetailsTest) -// t.Run("getAllRemoteRepoDetailsTest", getAllRemoteRepoDetailsTest) -// t.Run("isRemoteRepoExistsTest", isRemoteRepoExistsTest) -// } +func TestArtifactoryRemoteRepository(t *testing.T) { + initRepositoryTest(t) + t.Run("remoteAlpineTest", remoteAlpineTest) + t.Run("remoteBowerTest", remoteBowerTest) + t.Run("remoteCargoTest", remoteCargoTest) + t.Run("remoteChefTest", remoteChefTest) + t.Run("remoteCocoapodsTest", remoteCocoapodsTest) + t.Run("remoteComposerTest", remoteComposerTest) + t.Run("remoteConanTest", remoteConanTest) + t.Run("remoteCondaTest", remoteCondaTest) + t.Run("remoteCranTest", remoteCranTest) + t.Run("remoteDebianTest", remoteDebianTest) + t.Run("remoteDockerTest", remoteDockerTest) + t.Run("remoteGemsTest", remoteGemsTest) + t.Run("remoteGenericTest", remoteGenericTest) + t.Run("remoteGitlfsTest", remoteGitlfsTest) + t.Run("remoteGoTest", remoteGoTest) + t.Run("remoteGradleTest", remoteGradleTest) + t.Run("remoteHelmTest", remoteHelmTest) + t.Run("remoteIvyTest", remoteIvyTest) + t.Run("remoteMavenTest", remoteMavenTest) + t.Run("remoteNpmTest", remoteNpmTest) + t.Run("remoteNugetTest", remoteNugetTest) + t.Run("remoteOkgTest", remoteOpkgTest) + t.Run("remoteP2Test", remoteP2Test) + t.Run("remotePuppetTest", remotePuppetTest) + t.Run("remotePypiTest", remotePypiTest) + t.Run("remoteRpmTest", remoteRpmTest) + t.Run("remoteSbtTest", remoteSbtTest) + t.Run("remoteVcsTest", remoteVcsTest) + t.Run("remoteYumTest", remoteYumTest) + t.Run("remoteGenericSmartRemoteTest", remoteGenericSmartRemoteTest) + t.Run("remoteCreateWithParamTest", remoteCreateWithParamTest) + t.Run("getRemoteRepoDetailsTest", getRemoteRepoDetailsTest) + t.Run("getAllRemoteRepoDetailsTest", getAllRemoteRepoDetailsTest) + t.Run("isRemoteRepoExistsTest", isRemoteRepoExistsTest) +} func setRemoteRepositoryBaseParams(params *services.RemoteRepositoryBaseParams, isUpdate bool) { setRepositoryBaseParams(¶ms.RepositoryBaseParams, isUpdate) @@ -134,7 +132,9 @@ func remoteAlpineTest(t *testing.T) { setRemoteRepositoryBaseParams(&arp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Alpine(arp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation arp.Description += ArtifactoryLocalFileCacheSuffix @@ -157,7 +157,9 @@ func remoteBowerTest(t *testing.T) { brp.BowerRegistryUrl = "https://registry.bower.io" err := testsCreateRemoteRepositoryService.Bower(brp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation brp.Description += ArtifactoryLocalFileCacheSuffix @@ -181,7 +183,9 @@ func remoteCargoTest(t *testing.T) { crp.CargoAnonymousAccess = &trueValue err := testsCreateRemoteRepositoryService.Cargo(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -203,7 +207,9 @@ func remoteChefTest(t *testing.T) { setRemoteRepositoryBaseParams(&crp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Chef(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -226,7 +232,9 @@ func remoteCocoapodsTest(t *testing.T) { crp.PodsSpecsRepoUrl = "https://github.com/CocoaPods/Specs" err := testsCreateRemoteRepositoryService.Cocoapods(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -250,7 +258,9 @@ func remoteComposerTest(t *testing.T) { crp.ComposerRegistryUrl = "https://composer.registry.com/" err := testsCreateRemoteRepositoryService.Composer(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -272,7 +282,9 @@ func remoteConanTest(t *testing.T) { setRemoteRepositoryBaseParams(&crp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Conan(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -293,7 +305,9 @@ func remoteCondaTest(t *testing.T) { setRemoteRepositoryBaseParams(&crp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Conda(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -314,7 +328,9 @@ func remoteCranTest(t *testing.T) { setRemoteRepositoryBaseParams(&crp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Cran(crp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation crp.Description += ArtifactoryLocalFileCacheSuffix @@ -336,7 +352,9 @@ func remoteDebianTest(t *testing.T) { drp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.Debian(drp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation drp.Description += ArtifactoryLocalFileCacheSuffix @@ -362,7 +380,9 @@ func remoteDockerTest(t *testing.T) { drp.BlockPullingSchema1 = &trueValue err := testsCreateRemoteRepositoryService.Docker(drp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation drp.Description += ArtifactoryLocalFileCacheSuffix @@ -389,7 +409,9 @@ func remoteGemsTest(t *testing.T) { grp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.Gems(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation grp.Description += ArtifactoryLocalFileCacheSuffix @@ -412,7 +434,9 @@ func remoteGenericTest(t *testing.T) { grp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.Generic(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation grp.Description += ArtifactoryLocalFileCacheSuffix @@ -434,7 +458,9 @@ func remoteGitlfsTest(t *testing.T) { setRemoteRepositoryBaseParams(&grp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Gitlfs(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation grp.Description += ArtifactoryLocalFileCacheSuffix @@ -456,7 +482,9 @@ func remoteGoTest(t *testing.T) { grp.VcsGitProvider = "ARTIFACTORY" err := testsCreateRemoteRepositoryService.Go(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation grp.Description += ArtifactoryLocalFileCacheSuffix @@ -479,7 +507,9 @@ func remoteGradleTest(t *testing.T) { setJavaPackageManagersRemoteRepositoryParams(&grp.JavaPackageManagersRemoteRepositoryParams, false) err := testsCreateRemoteRepositoryService.Gradle(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation grp.Description += ArtifactoryLocalFileCacheSuffix @@ -502,7 +532,9 @@ func remoteHelmTest(t *testing.T) { hrp.ChartsBaseUrl = "charts" err := testsCreateRemoteRepositoryService.Helm(hrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation hrp.Description += ArtifactoryLocalFileCacheSuffix @@ -525,7 +557,9 @@ func remoteIvyTest(t *testing.T) { setJavaPackageManagersRemoteRepositoryParams(&irp.JavaPackageManagersRemoteRepositoryParams, false) err := testsCreateRemoteRepositoryService.Ivy(irp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation irp.Description += ArtifactoryLocalFileCacheSuffix @@ -548,7 +582,9 @@ func remoteMavenTest(t *testing.T) { setJavaPackageManagersRemoteRepositoryParams(&mrp.JavaPackageManagersRemoteRepositoryParams, false) err := testsCreateRemoteRepositoryService.Maven(mrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation mrp.Description += ArtifactoryLocalFileCacheSuffix @@ -570,7 +606,9 @@ func remoteNpmTest(t *testing.T) { setRemoteRepositoryBaseParams(&nrp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Npm(nrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation nrp.Description += ArtifactoryLocalFileCacheSuffix @@ -595,7 +633,9 @@ func remoteNugetTest(t *testing.T) { nrp.ForceNugetAuthentication = &trueValue err := testsCreateRemoteRepositoryService.Nuget(nrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation nrp.Description += ArtifactoryLocalFileCacheSuffix @@ -620,7 +660,9 @@ func remoteOpkgTest(t *testing.T) { setRemoteRepositoryBaseParams(&orp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Opkg(orp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation orp.Description += ArtifactoryLocalFileCacheSuffix @@ -642,7 +684,9 @@ func remoteP2Test(t *testing.T) { prp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.P2(prp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation prp.Description += ArtifactoryLocalFileCacheSuffix @@ -664,7 +708,9 @@ func remotePuppetTest(t *testing.T) { setRemoteRepositoryBaseParams(&prp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Puppet(prp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation prp.Description += ArtifactoryLocalFileCacheSuffix @@ -687,7 +733,9 @@ func remotePypiTest(t *testing.T) { prp.PypiRepositorySuffix = "simple" err := testsCreateRemoteRepositoryService.Pypi(prp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation prp.Description += ArtifactoryLocalFileCacheSuffix @@ -709,7 +757,9 @@ func remoteRpmTest(t *testing.T) { rrp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.Rpm(rrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation rrp.Description += ArtifactoryLocalFileCacheSuffix @@ -732,7 +782,9 @@ func remoteSbtTest(t *testing.T) { setJavaPackageManagersRemoteRepositoryParams(&srp.JavaPackageManagersRemoteRepositoryParams, false) err := testsCreateRemoteRepositoryService.Sbt(srp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation srp.Description += ArtifactoryLocalFileCacheSuffix @@ -756,7 +808,9 @@ func remoteVcsTest(t *testing.T) { vrp.MaxUniqueSnapshots = 25 err := testsCreateRemoteRepositoryService.Vcs(vrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // The local file cache suffix is added by Artifactory, so we add it here to pass the validation vrp.Description += ArtifactoryLocalFileCacheSuffix @@ -780,7 +834,9 @@ func remoteYumTest(t *testing.T) { yrp.ListRemoteFolderItems = &trueValue err := testsCreateRemoteRepositoryService.Yum(yrp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // "yum" package type is converted to "rpm" by Artifactory, so we have to change it too to pass the validation. yrp.PackageType = "rpm" @@ -875,7 +931,9 @@ func remoteCreateWithParamTest(t *testing.T) { params.Key = repoKey params.Url = "https://github.com/" err := testsRepositoriesService.CreateRemote(params) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, params) } @@ -889,7 +947,9 @@ func getRemoteRepoDetailsTest(t *testing.T) { setRemoteRepositoryBaseParams(&grp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Generic(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getRepo(t, repoKey) @@ -910,7 +970,9 @@ func getAllRemoteRepoDetailsTest(t *testing.T) { setRemoteRepositoryBaseParams(&grp.RemoteRepositoryBaseParams, false) err := testsCreateRemoteRepositoryService.Generic(grp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getAllRepos(t, "remote", "") diff --git a/tests/artifactoryvirtualrepository_test.go b/tests/artifactoryvirtualrepository_test.go index 4f6d4d1ac..5fb3a1eea 100644 --- a/tests/artifactoryvirtualrepository_test.go +++ b/tests/artifactoryvirtualrepository_test.go @@ -7,39 +7,37 @@ import ( "github.com/stretchr/testify/assert" ) -// Temporarily disabled - -// func TestArtifactoryVirtualRepository(t *testing.T) { -// initRepositoryTest(t) -// t.Run("virtualAlpineTest", virtualAlpineTest) -// t.Run("virtualBowerTest", virtualBowerTest) -// t.Run("virtualChefTest", virtualChefTest) -// t.Run("virtualConanTest", virtualConanTest) -// t.Run("virtualCondaTest", virtualCondaTest) -// t.Run("virtualCranTest", virtualCranTest) -// t.Run("virtualDebianTest", virtualDebianTest) -// t.Run("virtualDockerTest", virtualDockerTest) -// t.Run("virtualGemsTest", virtualGemsTest) -// t.Run("virtualGenericTest", virtualGenericTest) -// t.Run("virtualGitlfsTest", virtualGitlfsTest) -// t.Run("virtualGoTest", virtualGoTest) -// t.Run("virtualGradleTest", virtualGradleTest) -// t.Run("virtualHelmTest", virtualHelmTest) -// t.Run("virtualIvyTest", virtualIvyTest) -// t.Run("virtualMavenTest", virtualMavenTest) -// t.Run("virtualNpmTest", virtualNpmTest) -// t.Run("virtualNugetTest", virtualNugetTest) -// t.Run("virtualP2Test", virtualP2Test) -// t.Run("virtualPuppetTest", virtualPuppetTest) -// t.Run("virtualPypiTest", virtualPypiTest) -// t.Run("virtualRpmTest", virtualRpmTest) -// t.Run("virtualSbtTest", virtualSbtTest) -// t.Run("virtualYumTest", virtualYumTest) -// t.Run("virtualCreateWithParamTest", virtualCreateWithParamTest) -// t.Run("getVirtualRepoDetailsTest", getVirtualRepoDetailsTest) -// t.Run("getAllVirtualRepoDetailsTest", getAllVirtualRepoDetailsTest) -// t.Run("isVirtualRepoExistsTest", isVirtualRepoExistsTest) -// } +func TestArtifactoryVirtualRepository(t *testing.T) { + initRepositoryTest(t) + t.Run("virtualAlpineTest", virtualAlpineTest) + t.Run("virtualBowerTest", virtualBowerTest) + t.Run("virtualChefTest", virtualChefTest) + t.Run("virtualConanTest", virtualConanTest) + t.Run("virtualCondaTest", virtualCondaTest) + t.Run("virtualCranTest", virtualCranTest) + t.Run("virtualDebianTest", virtualDebianTest) + t.Run("virtualDockerTest", virtualDockerTest) + t.Run("virtualGemsTest", virtualGemsTest) + t.Run("virtualGenericTest", virtualGenericTest) + t.Run("virtualGitlfsTest", virtualGitlfsTest) + t.Run("virtualGoTest", virtualGoTest) + t.Run("virtualGradleTest", virtualGradleTest) + t.Run("virtualHelmTest", virtualHelmTest) + t.Run("virtualIvyTest", virtualIvyTest) + t.Run("virtualMavenTest", virtualMavenTest) + t.Run("virtualNpmTest", virtualNpmTest) + t.Run("virtualNugetTest", virtualNugetTest) + t.Run("virtualP2Test", virtualP2Test) + t.Run("virtualPuppetTest", virtualPuppetTest) + t.Run("virtualPypiTest", virtualPypiTest) + t.Run("virtualRpmTest", virtualRpmTest) + t.Run("virtualSbtTest", virtualSbtTest) + t.Run("virtualYumTest", virtualYumTest) + t.Run("virtualCreateWithParamTest", virtualCreateWithParamTest) + t.Run("getVirtualRepoDetailsTest", getVirtualRepoDetailsTest) + t.Run("getAllVirtualRepoDetailsTest", getAllVirtualRepoDetailsTest) + t.Run("isVirtualRepoExistsTest", isVirtualRepoExistsTest) +} func setVirtualRepositoryBaseParams(params *services.VirtualRepositoryBaseParams, isUpdate bool) { setRepositoryBaseParams(¶ms.RepositoryBaseParams, isUpdate) @@ -81,7 +79,9 @@ func virtualAlpineTest(t *testing.T) { setCacheVirtualRepositoryParams(&avp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Alpine(avp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, avp) @@ -103,7 +103,9 @@ func virtualBowerTest(t *testing.T) { bvp.ExternalDependenciesRemoteRepo = "" err := testsCreateVirtualRepositoryService.Bower(bvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, bvp) @@ -125,7 +127,9 @@ func virtualChefTest(t *testing.T) { setCacheVirtualRepositoryParams(&cvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Chef(cvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cvp) @@ -145,7 +149,9 @@ func virtualConanTest(t *testing.T) { setCacheVirtualRepositoryParams(&cvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Conan(cvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cvp) @@ -165,7 +171,9 @@ func virtualCondaTest(t *testing.T) { setCacheVirtualRepositoryParams(&cvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Conda(cvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cvp) @@ -185,7 +193,9 @@ func virtualCranTest(t *testing.T) { setCacheVirtualRepositoryParams(&cvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Cran(cvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, cvp) @@ -207,7 +217,9 @@ func virtualDebianTest(t *testing.T) { dvp.OptionalIndexCompressionFormats = []string{"bz2", "lzma"} err := testsCreateVirtualRepositoryService.Debian(dvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dvp) @@ -229,7 +241,9 @@ func virtualDockerTest(t *testing.T) { dvp.ResolveDockerTagsByTimestamp = &trueValue err := testsCreateVirtualRepositoryService.Docker(dvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, dvp) @@ -248,7 +262,9 @@ func virtualGemsTest(t *testing.T) { setVirtualRepositoryBaseParams(&gvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Gems(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gvp) @@ -266,7 +282,9 @@ func virtualGenericTest(t *testing.T) { setVirtualRepositoryBaseParams(&gvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Generic(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gvp) @@ -284,7 +302,9 @@ func virtualGitlfsTest(t *testing.T) { setVirtualRepositoryBaseParams(&gvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Gitlfs(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gvp) @@ -304,7 +324,9 @@ func virtualGoTest(t *testing.T) { gvp.ExternalDependenciesPatterns = []string{"**/*microsoft*/**", "**/*github*/**"} err := testsCreateVirtualRepositoryService.Go(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gvp) @@ -325,7 +347,9 @@ func virtualGradleTest(t *testing.T) { setJavaPackageManagersVirtualRepositoryParams(&gvp.CommonJavaVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Gradle(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, gvp) @@ -345,7 +369,9 @@ func virtualHelmTest(t *testing.T) { setCacheVirtualRepositoryParams(&hvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Helm(hvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, hvp) @@ -365,7 +391,9 @@ func virtualIvyTest(t *testing.T) { setJavaPackageManagersVirtualRepositoryParams(&ivp.CommonJavaVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Ivy(ivp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, ivp) @@ -385,7 +413,9 @@ func virtualMavenTest(t *testing.T) { setJavaPackageManagersVirtualRepositoryParams(&mvp.CommonJavaVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Maven(mvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, mvp) @@ -408,7 +438,9 @@ func virtualNpmTest(t *testing.T) { nvp.ExternalDependenciesRemoteRepo = "" err := testsCreateVirtualRepositoryService.Npm(nvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nvp) @@ -431,7 +463,9 @@ func virtualNugetTest(t *testing.T) { nvp.ForceNugetAuthentication = &trueValue err := testsCreateVirtualRepositoryService.Nuget(nvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, nvp) @@ -450,7 +484,9 @@ func virtualP2Test(t *testing.T) { setVirtualRepositoryBaseParams(&pvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.P2(pvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, pvp) @@ -469,7 +505,9 @@ func virtualPuppetTest(t *testing.T) { setVirtualRepositoryBaseParams(&pvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Puppet(pvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, pvp) @@ -487,7 +525,9 @@ func virtualPypiTest(t *testing.T) { setVirtualRepositoryBaseParams(&pvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Pypi(pvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, pvp) @@ -506,7 +546,9 @@ func virtualRpmTest(t *testing.T) { setCacheVirtualRepositoryParams(&rvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Rpm(rvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, rvp) @@ -526,7 +568,9 @@ func virtualSbtTest(t *testing.T) { setJavaPackageManagersVirtualRepositoryParams(&svp.CommonJavaVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Sbt(svp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, svp) @@ -546,7 +590,9 @@ func virtualYumTest(t *testing.T) { setCacheVirtualRepositoryParams(&yvp.CommonCacheVirtualRepositoryParams, false) err := testsCreateVirtualRepositoryService.Yum(yvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // "yum" package type is converted to "rpm" by Artifactory, so we have to change it too to pass the validation. yvp.PackageType = "rpm" @@ -565,7 +611,9 @@ func virtualCreateWithParamTest(t *testing.T) { params := services.NewVirtualRepositoryBaseParams() params.Key = repoKey err := testsRepositoriesService.CreateVirtual(params) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) validateRepoConfig(t, repoKey, params) } @@ -578,7 +626,9 @@ func getVirtualRepoDetailsTest(t *testing.T) { setVirtualRepositoryBaseParams(&gvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Generic(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getRepo(t, repoKey) @@ -598,7 +648,9 @@ func getAllVirtualRepoDetailsTest(t *testing.T) { setVirtualRepositoryBaseParams(&gvp.VirtualRepositoryBaseParams, false) err := testsCreateVirtualRepositoryService.Generic(gvp) - assert.NoError(t, err, "Failed to create "+repoKey) + if !assert.NoError(t, err, "Failed to create "+repoKey) { + return + } defer deleteRepo(t, repoKey) // Get repo details data := getAllRepos(t, "virtual", "") diff --git a/tests/utils_test.go b/tests/utils_test.go index 06fb8f32d..cce8430cd 100644 --- a/tests/utils_test.go +++ b/tests/utils_test.go @@ -5,6 +5,8 @@ import ( "errors" "flag" "fmt" + "github.com/buger/jsonparser" + "github.com/jfrog/jfrog-client-go/utils/errorutils" clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" "io/ioutil" "net/http" @@ -587,7 +589,7 @@ func artifactoryCleanup(t *testing.T) { } func createRepo() error { - if !(*TestArtifactory || *TestDistribution || *TestXray) { + if !(*TestArtifactory || *TestDistribution || *TestXray || *TestRepository) { return nil } var err error @@ -774,18 +776,39 @@ func setRpmRepositoryParams(params *services.RpmRepositoryParams, isUpdate bool) } } -func getRepoConfig(repoKey string) (body []byte, err error) { +func getRepoConfig(repoKey string) ([]byte, error) { artDetails := GetRtDetails() artHttpDetails := artDetails.CreateHttpClientDetails() client, err := httpclient.ClientBuilder().Build() if err != nil { - return + return nil, err } resp, body, _, err := client.SendGet(artDetails.GetUrl()+"api/repositories/"+repoKey, false, artHttpDetails, "") + if err != nil { + return nil, err + } + if err = errorutils.CheckResponseStatus(resp, http.StatusOK); err != nil { + return nil, errorutils.CheckError(errorutils.GenerateResponseError(resp.Status, clientutils.IndentJson(body))) + } + return body, nil +} + +func isEnterprisePlus() (bool, error) { + artDetails := GetRtDetails() + artHttpDetails := artDetails.CreateHttpClientDetails() + client, err := httpclient.ClientBuilder().Build() + if err != nil { + return false, err + } + resp, body, _, err := client.SendGet(artDetails.GetUrl()+"api/system/license", false, artHttpDetails, "") if err != nil || resp.StatusCode != http.StatusOK { - return + return false, err + } + value, err := jsonparser.GetString(body, "type") + if err != nil { + return false, err } - return + return value == "Enterprise Plus", nil } func createRepoConfigValidationFunc(repoKey string, expectedConfig interface{}) clientutils.ExecutionHandlerFunc { @@ -810,6 +833,16 @@ func createRepoConfigValidationFunc(repoKey string, expectedConfig interface{}) if key == "password" { continue } + // Download Redirect is only supported on Enterprise Plus. Expect false otherwise. + if key == "downloadRedirect" { + eplus, err := isEnterprisePlus() + if err != nil { + return false, err + } + if !eplus { + expectedValue = false + } + } if !assert.ObjectsAreEqual(confMap[key], expectedValue) { errMsg := fmt.Sprintf("config validation for %s failed. key: %s expected: %s actual: %s", repoKey, key, expectedValue, confMap[key]) return true, errors.New(errMsg)