Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions artifactorybulkrepository_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package main

import (
"fmt"
"github.com/jfrog/jfrog-cli/utils/tests"
"github.com/stretchr/testify/assert"
"testing"
)

func TestRepositoryCreateAndUpdateIntegration(t *testing.T) {
initArtifactoryTest(t, "")
defer cleanArtifactoryTest()

t.Run("SingleRepositoryCreate", func(t *testing.T) {
testSingleRepositoryCreate(t)
})

t.Run("SingleRepositoryUpdate", func(t *testing.T) {
testSingleRepositoryUpdate(t)
})

t.Run("MultipleRepositoryCreate", func(t *testing.T) {
testMultipleRepositoryCreate(t)
})

t.Run("MultipleRepositoryUpdate", func(t *testing.T) {
testMultipleRepositoryUpdate(t)
})

t.Run("DifferentPackageTypesAndRClass", func(t *testing.T) {
testCreateWithDifferentRclass(t)
})

t.Run("DifferentPackageTypesAndRClassUpdate", func(t *testing.T) {
testUpdateWithDifferentRclass(t)
})
}

func testSingleRepositoryCreate(t *testing.T) {
templatePath := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1

runRt(t, "repo-create", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))

assert.True(t, isRepoExist(tests.MvnRepo1), "Repository should exist after creation")

execDeleteRepo(tests.MvnRepo1)
}

func testSingleRepositoryUpdate(t *testing.T) {
templatePath := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1

runRt(t, "repo-create", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))

runRt(t, "repo-update", templatePath, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", tests.MvnRepo1))

assert.True(t, isRepoExist(tests.MvnRepo1), "Repository should still exist after update")

execDeleteRepo(tests.MvnRepo1)
}

func testMultipleRepositoryCreate(t *testing.T) {
repo1Name := "test-maven-repo1"
repo2Name := "test-npm-repo2"
repo3Name := "test-docker-repo3"

templatePath := tests.GetTestResourcesPath() + tests.MultipleRepositoriesConfig

runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))

assert.True(t, isRepoExist(repo1Name), "Repository 1 doesn't exist")
assert.True(t, isRepoExist(repo2Name), "Repository 2 doesn't exist")
assert.True(t, isRepoExist(repo3Name), "Repository 3 doesn't exist")

execDeleteRepo(repo1Name)
execDeleteRepo(repo2Name)
execDeleteRepo(repo3Name)
}

func testMultipleRepositoryUpdate(t *testing.T) {
repo1Name := "test-multi-repo1"
repo2Name := "test-multi-repo2"
repo3Name := "test-multi-repo3"

templatePath := tests.GetTestResourcesPath() + tests.MultipleRepositoriesConfig

runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))

runRt(t, "repo-update", templatePath, "--vars",
fmt.Sprintf("REPO1_KEY=%s;REPO2_KEY=%s;REPO3_KEY=%s", repo1Name, repo2Name, repo3Name))

assert.True(t, isRepoExist(repo1Name), "Repository 1 doesn't exist")
assert.True(t, isRepoExist(repo2Name), "Repository 2 doesn't exist")
assert.True(t, isRepoExist(repo3Name), "Repository 3 doesn't exist")

execDeleteRepo(repo1Name)
execDeleteRepo(repo2Name)
execDeleteRepo(repo3Name)
}

func testCreateWithDifferentRclass(t *testing.T) {
mvnRepoName := "test-mvn-local1"
dockerLocalRepoName := "test-docker-local1"
npmRepoName := "test-npm-local"
dockerRemoteRepoName := "test-docker-remote1"
dockerVirtualRepoName := "test-docker-virtual1"

templatePathForLocalMvnRepo := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
templatePathForDockerRepo := tests.GetTestResourcesPath() + tests.DockerLocalRepositoryConfig

runRt(t, "repo-create", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-create", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))

templatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesConfig
runRt(t, "repo-create", templatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))

assert.True(t, isRepoExist(mvnRepoName), "local Maven repository doesn't exist")
assert.True(t, isRepoExist(dockerLocalRepoName), "local docker repository doesn't exist")
assert.True(t, isRepoExist(npmRepoName), "local npm repository doesn't exist")
assert.True(t, isRepoExist(dockerRemoteRepoName), "remote docker repository doesn't exist")
assert.True(t, isRepoExist(dockerVirtualRepoName), "virtual docker repository doesn't exist")

execDeleteRepo(dockerVirtualRepoName)
execDeleteRepo(dockerRemoteRepoName)
execDeleteRepo(npmRepoName)
execDeleteRepo(dockerLocalRepoName)
execDeleteRepo(mvnRepoName)
}

func testUpdateWithDifferentRclass(t *testing.T) {
mvnRepoName := "test-mvn-local-1"
dockerLocalRepoName := "test-docker-local-1"
npmRepoName := "test-npm-local"
dockerRemoteRepoName := "test-docker-remote-1"
dockerVirtualRepoName := "test-docker-virtual-1"

templatePathForLocalMvnRepo := tests.GetTestResourcesPath() + tests.MavenRepositoryConfig1
templatePathForDockerRepo := tests.GetTestResourcesPath() + tests.DockerLocalRepositoryConfig

runRt(t, "repo-create", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-create", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))

createTemplatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesConfig
runRt(t, "repo-create", createTemplatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))

updateTemplatePath := tests.GetTestResourcesPath() + tests.MixedRepositoriesUpdateConfig
runRt(t, "repo-update", templatePathForLocalMvnRepo, "--vars", fmt.Sprintf("MAVEN_REPO1=%s", mvnRepoName))
runRt(t, "repo-update", templatePathForDockerRepo, "--vars", fmt.Sprintf("DOCKER_REPO=%s", dockerLocalRepoName))
runRt(t, "repo-update", updateTemplatePath, "--vars",
fmt.Sprintf("REPO2_KEY=%s;DOCKER_REMOTE_REPO=%s;DOCKER_VIRTUAL_REPO=%s;REPO1=%s;DEBIAN_REPO=%s",
npmRepoName, dockerRemoteRepoName, dockerVirtualRepoName, mvnRepoName, dockerLocalRepoName))

assert.True(t, isRepoExist(mvnRepoName), "local Maven repository doesn't exist after update")
assert.True(t, isRepoExist(dockerLocalRepoName), "local docker repository doesn't exist after update")
assert.True(t, isRepoExist(npmRepoName), "local npm repository doesn't exist after update")
assert.True(t, isRepoExist(dockerRemoteRepoName), "remote docker repository doesn't exist after update")
assert.True(t, isRepoExist(dockerVirtualRepoName), "virtual docker repository doesn't exist after update")

execDeleteRepo(dockerVirtualRepoName)
execDeleteRepo(dockerRemoteRepoName)
execDeleteRepo(npmRepoName)
execDeleteRepo(dockerLocalRepoName)
execDeleteRepo(mvnRepoName)
}
101 changes: 71 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,23 @@ require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/apache/camel-k/v2 v2.5.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beevik/etree v1.4.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/c-bata/go-prompt v0.2.6 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand All @@ -64,20 +70,35 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/forPelevin/gomoji v1.3.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gfleury/go-bitbucket-v1 v0.0.0-20230825095122-9bc1711434ab // indirect
github.com/go-chi/chi v4.1.2+incompatible // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-git/v5 v5.16.0 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.1 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/runtime v0.28.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/certificate-transparency-go v1.3.1 // indirect
github.com/google/go-containerregistry v0.20.3 // indirect
github.com/google/go-github/v56 v56.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand All @@ -88,22 +109,28 @@ require (
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.3 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/in-toto/attestation v1.1.1 // indirect
github.com/in-toto/in-toto-golang v0.9.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jedib0t/go-pretty/v6 v6.6.5 // indirect
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b // indirect
github.com/jfrog/froggit-go v1.18.0 // indirect
github.com/jfrog/go-mockhttp v0.3.1 // indirect
github.com/jfrog/jfrog-apps-config v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/ktrysmt/go-bitbucket v0.9.80 // indirect
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
Expand All @@ -122,11 +149,13 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/owenrumney/go-sarif/v3 v3.1.4 // indirect
github.com/package-url/packageurl-go v0.1.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
Expand All @@ -137,23 +166,34 @@ require (
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.8.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sassoftware/relic v7.2.1+incompatible // indirect
github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sigstore/protobuf-specs v0.5.0 // indirect
github.com/sigstore/rekor v1.3.10 // indirect
github.com/sigstore/sigstore v1.9.4 // indirect
github.com/sigstore/sigstore-go v1.0.0 // indirect
github.com/sigstore/timestamp-authority v1.2.7 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.20.1 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/theupdateframework/go-tuf v0.7.0 // indirect
github.com/theupdateframework/go-tuf/v2 v2.1.1 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/transparency-dev/merkle v0.0.2 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/vbauerster/mpb/v8 v8.9.1 // indirect
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 // indirect
Expand All @@ -164,27 +204,28 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.69.4 // indirect
google.golang.org/protobuf v1.36.3 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.25.0 // indirect
golang.org/x/time v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
google.golang.org/grpc v1.72.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand All @@ -199,12 +240,12 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250529104758-6d769a684388

// replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory main
replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.4.1-0.20250717082417-55c8609c3397

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 dev
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.59.2-0.20250717045550-6e019038f578

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go dev
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250717041744-d3ea4d99f4e7

//replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security v1.17.2-0.20250511132918-d9cc4cd50020
Loading
Loading