diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry_omnibus_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/container_registry_omnibus_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_omnibus_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/container_registry_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/online_garbage_collection_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/online_garbage_collection_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/online_garbage_collection_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/container_registry/online_garbage_collection_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/dependency_proxy_spec.rb b/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/dependency_proxy_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/maven_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb similarity index 90% rename from qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb index f87b324fe819221b0f696c84d2fca22e14995e54..e603eb1c2a38620311aa7e51e6fa38c2974b03a5 100644 --- a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages, :reliable, :object_storage do - describe 'npm registry' do + RSpec.describe 'Package Registry', :orchestrated, :packages, :reliable, :object_storage do + describe 'npm instance level endpoint' do using RSpec::Parameterized::TableSyntax include Runtime::Fixtures @@ -28,13 +28,13 @@ module QA let!(:project) do Resource::Project.fabricate_via_api! do |project| - project.name = 'npm-project' + project.name = 'npm-instace-level-publish' end end let!(:another_project) do Resource::Project.fabricate_via_api! do |another_project| - another_project.name = 'npm-another-project' + another_project.name = 'npm-instance-level-install' another_project.template_name = 'express' another_project.group = project.group end @@ -54,7 +54,7 @@ module QA file_path: '.gitlab-ci.yml', content: <<~YAML - image: node:14-buster + image: node:latest stages: - deploy @@ -62,6 +62,7 @@ module QA deploy: stage: deploy script: + - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=#{auth_token}">.npmrc - npm publish only: - "#{project.default_branch}" @@ -149,23 +150,12 @@ module QA end end - let(:npmrc) do - { - file_path: '.npmrc', - content: <<~NPMRC - //#{gitlab_host_with_port}/api/v4/projects/#{project.id}/packages/npm/:_authToken=#{auth_token} - @#{registry_scope}:registry=#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/npm/ - NPMRC - } - end - it "push and pull a npm package via CI using a #{params[:token_name]}" do Resource::Repository::Commit.fabricate_via_api! do |commit| commit.project = project commit.commit_message = 'Add .gitlab-ci.yml' commit.add_files([ gitlab_ci_deploy_yaml, - npmrc, package_json ]) end diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..f4b306d683086cb020ba82281658ebdbe07c8161 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb @@ -0,0 +1,192 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package Registry', :orchestrated, :packages, :reliable, :object_storage do + describe 'npm project level endpoint' do + using RSpec::Parameterized::TableSyntax + include Runtime::Fixtures + + let!(:registry_scope) { Runtime::Namespace.sandbox_name } + let!(:personal_access_token) do + unless Page::Main::Menu.perform(&:signed_in?) + Flow::Login.sign_in + end + + Resource::PersonalAccessToken.fabricate!.token + end + + let(:project_deploy_token) do + Resource::DeployToken.fabricate_via_browser_ui! do |deploy_token| + deploy_token.name = 'npm-deploy-token' + deploy_token.project = project + end + end + + let(:uri) { URI.parse(Runtime::Scenario.gitlab_address) } + let(:gitlab_address_with_port) { "#{uri.scheme}://#{uri.host}:#{uri.port}" } + let(:gitlab_host_with_port) { "#{uri.host}:#{uri.port}" } + + let!(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'npm-project-level' + end + end + + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.name = "qa-runner-#{Time.now.to_i}" + runner.tags = ["runner-for-#{project.name}"] + runner.executor = :docker + runner.project = project + end + end + + let(:gitlab_ci_yaml) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + image: node:latest + + stages: + - deploy + - install + + deploy: + stage: deploy + script: + - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=#{auth_token}">.npmrc + - npm publish + only: + - "#{project.default_branch}" + tags: + - "runner-for-#{project.name}" + install: + stage: install + script: + - "npm config set @#{registry_scope}:registry #{gitlab_address_with_port}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" + - "npm install #{package.name}" + cache: + key: ${CI_BUILD_REF_NAME} + paths: + - node_modules/ + artifacts: + paths: + - node_modules/ + only: + - "#{project.default_branch}" + tags: + - "runner-for-#{project.name}" + YAML + } + end + + let(:package_json) do + { + file_path: 'package.json', + content: <<~JSON + { + "name": "@#{registry_scope}/mypackage", + "version": "1.0.0", + "description": "Example package for GitLab npm registry", + "publishConfig": { + "@#{registry_scope}:registry": "#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/npm/" + } + } + JSON + } + end + + let(:package) do + Resource::Package.init do |package| + package.name = "@#{registry_scope}/mypackage" + package.project = project + end + end + + after do + package.remove_via_api! + runner.remove_via_api! + project.remove_via_api! + end + + where(:authentication_token_type, :token_name) do + :personal_access_token | 'Personal Access Token' + :ci_job_token | 'CI Job Token' + :project_deploy_token | 'Deploy Token' + end + + with_them do + let(:auth_token) do + case authentication_token_type + when :personal_access_token + "\"#{personal_access_token}\"" + when :ci_job_token + '${CI_JOB_TOKEN}' + when :project_deploy_token + "\"#{project_deploy_token.password}\"" + end + end + + it "push and pull a npm package via CI using a #{params[:token_name]}" do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([ + gitlab_ci_yaml, + package_json + ]) + end + + project.visit! + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('deploy') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('install') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + job.click_browse_button + end + + Page::Project::Artifact::Show.perform do |artifacts| + artifacts.go_to_directory('node_modules') + artifacts.go_to_directory("@#{registry_scope}") + expect(artifacts).to have_content("mypackage") + end + + project.visit! + Page::Project::Menu.perform(&:click_packages_link) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package.name) + + index.click_package(package.name) + end + + Page::Project::Packages::Show.perform do |show| + expect(show).to have_package_info(package.name, "1.0.0") + + show.click_delete + end + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_content("Package deleted successfully") + expect(index).not_to have_package(package.name) + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/nuget_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb similarity index 100% rename from qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb diff --git a/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb similarity index 98% rename from qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb rename to qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb index 9a45b072eed6af7d15fa15e4af6ed02cc3552e8c..45e44a2d9e0faf40f8405ab85f7195f8a606c083 100644 --- a/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb @@ -50,7 +50,7 @@ module QA push.project = project push.directory = Pathname .new(__dir__) - .join('../../../../fixtures/rubygems_package') + .join('../../../../../fixtures/rubygems_package') push.commit_message = 'RubyGems package' end