diff --git a/.github/workflows/feature-branches.yaml b/.github/workflows/feature-branches.yaml index 22356e1..0be7c8d 100644 --- a/.github/workflows/feature-branches.yaml +++ b/.github/workflows/feature-branches.yaml @@ -5,7 +5,7 @@ jobs: strategy: max-parallel: 1 matrix: - go-version: [1.20.x, 1.21.x, 1.22.x] + go-version: [1.21.x, 1.22.x, 1.23.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/README.md b/README.md index 801be1e..1eed464 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Sonatype Nexus Golang Client -Implemented and tested with Sonatype Nexus `3.70.1` with `java11` and legacy DB `OrientDB`. +Implemented and tested with Sonatype Nexus `3.72.0` with `java17` and DB `H2`. ## Development and testing diff --git a/nexus3/pkg/repository/bower/group_test.go b/nexus3/pkg/repository/bower/group_test.go deleted file mode 100644 index 97e8a9e..0000000 --- a/nexus3/pkg/repository/bower/group_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package bower - -import ( - "math/rand" - "strconv" - "testing" - - "github.com/datadrivers/go-nexus-client/nexus3/schema/repository" - "github.com/stretchr/testify/assert" -) - -func getTestBowerGroupRepository(name string) repository.BowerGroupRepository { - return repository.BowerGroupRepository{ - Name: name, - Online: true, - - Group: repository.Group{ - MemberNames: []string{}, - }, - Storage: repository.Storage{ - BlobStoreName: "default", - StrictContentTypeValidation: true, - }, - } -} - -func TestBowerGroupRepository(t *testing.T) { - service := getTestService() - repo := getTestBowerGroupRepository("test-bower-repo-group-" + strconv.Itoa(rand.Intn(1024))) - - testProxyRepo := getTestBowerProxyRepository("test-bower-group-proxy-" + strconv.Itoa(rand.Intn(1024))) - defer service.Proxy.Delete(testProxyRepo.Name) - err := service.Proxy.Create(testProxyRepo) - assert.Nil(t, err) - repo.Group.MemberNames = append(repo.Group.MemberNames, testProxyRepo.Name) - - err = service.Group.Create(repo) - assert.Nil(t, err) - generatedRepo, err := service.Group.Get(repo.Name) - assert.Nil(t, err) - assert.Equal(t, repo.Online, generatedRepo.Online) - assert.Equal(t, repo.Group, generatedRepo.Group) - assert.Equal(t, repo.Storage, generatedRepo.Storage) - - updatedRepo := repo - updatedRepo.Online = false - - err = service.Group.Update(repo.Name, updatedRepo) - assert.Nil(t, err) - generatedRepo, err = service.Group.Get(updatedRepo.Name) - assert.Nil(t, err) - assert.Equal(t, updatedRepo.Online, generatedRepo.Online) - - service.Group.Delete(repo.Name) - assert.Nil(t, err) -} diff --git a/nexus3/pkg/repository/bower/hosted_test.go b/nexus3/pkg/repository/bower/hosted_test.go deleted file mode 100644 index 673195b..0000000 --- a/nexus3/pkg/repository/bower/hosted_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package bower - -import ( - "math/rand" - "strconv" - "testing" - - "github.com/datadrivers/go-nexus-client/nexus3/schema/repository" - "github.com/stretchr/testify/assert" -) - -func getTestBowerHostedRepository(name string) repository.BowerHostedRepository { - writePolicy := repository.StorageWritePolicyAllow - return repository.BowerHostedRepository{ - Name: name, - Online: true, - - Cleanup: &repository.Cleanup{ - PolicyNames: []string{"weekly-cleanup"}, - }, - Storage: repository.HostedStorage{ - BlobStoreName: "default", - StrictContentTypeValidation: true, - WritePolicy: &writePolicy, - }, - Component: &repository.Component{ - ProprietaryComponents: true, - }, - } -} - -func TestBowerHostedRepository(t *testing.T) { - service := getTestService() - repo := getTestBowerHostedRepository("test-bower-repo-hosted-" + strconv.Itoa(rand.Intn(1024))) - - err := service.Hosted.Create(repo) - assert.Nil(t, err) - generatedRepo, err := service.Hosted.Get(repo.Name) - assert.Nil(t, err) - assert.Equal(t, repo.Online, generatedRepo.Online) - assert.Equal(t, repo.Cleanup, generatedRepo.Cleanup) - assert.Equal(t, repo.Storage, generatedRepo.Storage) - assert.Equal(t, repo.Component, generatedRepo.Component) - - updatedRepo := repo - updatedRepo.Online = false - - err = service.Hosted.Update(repo.Name, updatedRepo) - assert.Nil(t, err) - generatedRepo, err = service.Hosted.Get(updatedRepo.Name) - assert.Nil(t, err) - assert.Equal(t, updatedRepo.Online, generatedRepo.Online) - - service.Hosted.Delete(repo.Name) - assert.Nil(t, err) -} diff --git a/nexus3/pkg/repository/bower/proxy_test.go b/nexus3/pkg/repository/bower/proxy_test.go deleted file mode 100644 index 97d5110..0000000 --- a/nexus3/pkg/repository/bower/proxy_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package bower - -import ( - "math/rand" - "strconv" - "testing" - - "github.com/datadrivers/go-nexus-client/nexus3/pkg/tools" - "github.com/datadrivers/go-nexus-client/nexus3/schema/repository" - "github.com/stretchr/testify/assert" -) - -func getTestBowerProxyRepository(name string) repository.BowerProxyRepository { - return repository.BowerProxyRepository{ - Name: name, - Online: true, - HTTPClient: repository.HTTPClient{ - Blocked: true, - AutoBlock: true, - Connection: &repository.HTTPClientConnection{ - Timeout: tools.GetIntPointer(20), - UseTrustStore: tools.GetBoolPointer(true), - }, - }, - NegativeCache: repository.NegativeCache{ - Enabled: true, - TTL: 1440, - }, - Proxy: repository.Proxy{ - ContentMaxAge: 1440, - MetadataMaxAge: 1440, - RemoteURL: "https://archive.ubuntu.com/ubuntu/", - }, - Storage: repository.Storage{ - BlobStoreName: "default", - StrictContentTypeValidation: true, - }, - - Bower: repository.Bower{ - RewritePackageUrls: true, - }, - } -} - -func TestBowerProxyRepository(t *testing.T) { - service := getTestService() - repo := getTestBowerProxyRepository("test-bower-repo-hosted-" + strconv.Itoa(rand.Intn(1024))) - - err := service.Proxy.Create(repo) - assert.Nil(t, err) - generatedRepo, err := service.Proxy.Get(repo.Name) - assert.Nil(t, err) - assert.Equal(t, repo.Online, generatedRepo.Online) - assert.Equal(t, repo.HTTPClient.Blocked, generatedRepo.HTTPClient.Blocked) - assert.Equal(t, repo.HTTPClient.AutoBlock, generatedRepo.HTTPClient.AutoBlock) - assert.Equal(t, repo.HTTPClient.Connection.Timeout, generatedRepo.HTTPClient.Connection.Timeout) - assert.Equal(t, repo.HTTPClient.Connection.UseTrustStore, generatedRepo.HTTPClient.Connection.UseTrustStore) - assert.Equal(t, repo.NegativeCache, generatedRepo.NegativeCache) - assert.Equal(t, repo.Proxy, generatedRepo.Proxy) - assert.Equal(t, repo.Storage, generatedRepo.Storage) - assert.Equal(t, repo.Bower, generatedRepo.Bower) - - updatedRepo := repo - updatedRepo.Online = false - updatedRepo.RewritePackageUrls = false - - err = service.Proxy.Update(repo.Name, updatedRepo) - assert.Nil(t, err) - generatedRepo, err = service.Proxy.Get(updatedRepo.Name) - assert.Nil(t, err) - assert.Equal(t, updatedRepo.Online, generatedRepo.Online) - assert.Equal(t, updatedRepo.Bower, generatedRepo.Bower) - - service.Proxy.Delete(repo.Name) - assert.Nil(t, err) -} diff --git a/nexus3/pkg/repository/bower/service_test.go b/nexus3/pkg/repository/bower/service_test.go deleted file mode 100644 index e39057f..0000000 --- a/nexus3/pkg/repository/bower/service_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package bower - -import ( - "testing" - - "github.com/datadrivers/go-nexus-client/nexus3/pkg/client" - "github.com/datadrivers/go-nexus-client/nexus3/pkg/tools" - "github.com/stretchr/testify/assert" -) - -var ( - testClient *client.Client = nil -) - -func getTestClient() *client.Client { - if testClient != nil { - return testClient - } - return client.NewClient(getDefaultConfig()) -} - -func getTestService() *RepositoryBowerService { - return NewRepositoryBowerService(getTestClient()) -} - -func getDefaultConfig() client.Config { - return client.Config{ - Insecure: tools.GetEnv("NEXUS_INSECURE_SKIP_VERIFY", true).(bool), - Password: tools.GetEnv("NEXUS_PASSWORD", "admin123").(string), - URL: tools.GetEnv("NEXUS_URL", "http://127.0.0.1:8081").(string), - Username: tools.GetEnv("NEXUS_USRNAME", "admin").(string), - } -} - -func TestNewRepositoryService(t *testing.T) { - s := getTestService() - - assert.NotNil(t, s, "NewRepositoryService() must not return nil") -} diff --git a/scripts/.env b/scripts/.env index ae8686c..6e8bee9 100644 --- a/scripts/.env +++ b/scripts/.env @@ -1,4 +1,4 @@ export NEXUS_IMAGE=sonatypecommunity/nexus3 -export NEXUS_VERSION=3.70.1 -export NEXUS_JAVA_VERSION=java11 +export NEXUS_VERSION=3.72.0 +export NEXUS_JAVA_VERSION=java17 export NEXUS_PORT=8081 diff --git a/scripts/oss-nexus.properties b/scripts/oss-nexus.properties index 271b630..9c63297 100644 --- a/scripts/oss-nexus.properties +++ b/scripts/oss-nexus.properties @@ -18,3 +18,5 @@ nexus.scripts.allowCreation=true nexus.onboarding.enabled=false # Disable random password nexus.security.randompassword=false + +nexus.datastore.enabled=true diff --git a/scripts/pro-nexus.properties b/scripts/pro-nexus.properties index ea68ca7..981962a 100644 --- a/scripts/pro-nexus.properties +++ b/scripts/pro-nexus.properties @@ -19,3 +19,5 @@ nexus.onboarding.enabled=false # Disable random password nexus.security.randompassword=false nexus.licenseFile=/nexus-data/etc/license.lic + +nexus.datastore.enabled=true