Commit 79d3bd34 authored by James Fargher's avatar James Fargher

Merge branch '213929-move-package-apis-to-core' into 'master'

Move package APIS to core [RUN AS-IF-FOSS]

Closes #213929

See merge request gitlab-org/gitlab!35919
parents 1047ae11 62cf1104
...@@ -790,8 +790,8 @@ Style/RedundantSelf: ...@@ -790,8 +790,8 @@ Style/RedundantSelf:
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/RedundantSort: Style/RedundantSort:
Exclude: Exclude:
- 'ee/app/presenters/packages/nuget/search_results_presenter.rb' - 'app/presenters/packages/nuget/search_results_presenter.rb'
- 'ee/spec/presenters/packages/nuget/search_results_presenter_spec.rb' - 'spec/presenters/packages/nuget/search_results_presenter_spec.rb'
# Offense count: 120 # Offense count: 120
# Cop supports --auto-correct. # Cop supports --auto-correct.
...@@ -976,21 +976,17 @@ Rails/SaveBang: ...@@ -976,21 +976,17 @@ Rails/SaveBang:
- 'ee/spec/policies/vulnerabilities/feedback_policy_spec.rb' - 'ee/spec/policies/vulnerabilities/feedback_policy_spec.rb'
- 'ee/spec/presenters/audit_event_presenter_spec.rb' - 'ee/spec/presenters/audit_event_presenter_spec.rb'
- 'ee/spec/presenters/epic_presenter_spec.rb' - 'ee/spec/presenters/epic_presenter_spec.rb'
- 'ee/spec/presenters/packages/conan/package_presenter_spec.rb'
- 'ee/spec/requests/api/boards_spec.rb' - 'ee/spec/requests/api/boards_spec.rb'
- 'ee/spec/requests/api/conan_packages_spec.rb'
- 'ee/spec/requests/api/epic_issues_spec.rb' - 'ee/spec/requests/api/epic_issues_spec.rb'
- 'ee/spec/requests/api/epic_links_spec.rb' - 'ee/spec/requests/api/epic_links_spec.rb'
- 'ee/spec/requests/api/epics_spec.rb' - 'ee/spec/requests/api/epics_spec.rb'
- 'ee/spec/requests/api/geo_nodes_spec.rb' - 'ee/spec/requests/api/geo_nodes_spec.rb'
- 'ee/spec/requests/api/geo_spec.rb' - 'ee/spec/requests/api/geo_spec.rb'
- 'ee/spec/requests/api/go_proxy_spec.rb'
- 'ee/spec/requests/api/graphql/group/epics_spec.rb' - 'ee/spec/requests/api/graphql/group/epics_spec.rb'
- 'ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb' - 'ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb'
- 'ee/spec/requests/api/groups_spec.rb' - 'ee/spec/requests/api/groups_spec.rb'
- 'ee/spec/requests/api/issues_spec.rb' - 'ee/spec/requests/api/issues_spec.rb'
- 'ee/spec/requests/api/ldap_group_links_spec.rb' - 'ee/spec/requests/api/ldap_group_links_spec.rb'
- 'ee/spec/requests/api/maven_packages_spec.rb'
- 'ee/spec/requests/api/merge_request_approval_rules_spec.rb' - 'ee/spec/requests/api/merge_request_approval_rules_spec.rb'
- 'ee/spec/requests/api/merge_request_approvals_spec.rb' - 'ee/spec/requests/api/merge_request_approvals_spec.rb'
- 'ee/spec/requests/api/merge_requests_spec.rb' - 'ee/spec/requests/api/merge_requests_spec.rb'
...@@ -1059,9 +1055,7 @@ Rails/SaveBang: ...@@ -1059,9 +1055,7 @@ Rails/SaveBang:
- 'ee/spec/support/shared_examples/models/mentionable_shared_examples.rb' - 'ee/spec/support/shared_examples/models/mentionable_shared_examples.rb'
- 'ee/spec/support/shared_examples/policies/protected_environments_shared_examples.rb' - 'ee/spec/support/shared_examples/policies/protected_environments_shared_examples.rb'
- 'ee/spec/support/shared_examples/requests/api/graphql/geo/registries_shared_examples.rb' - 'ee/spec/support/shared_examples/requests/api/graphql/geo/registries_shared_examples.rb'
- 'ee/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb'
- 'ee/spec/support/shared_examples/requests/api/project_approval_rules_api_shared_examples.rb' - 'ee/spec/support/shared_examples/requests/api/project_approval_rules_api_shared_examples.rb'
- 'ee/spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb'
- 'ee/spec/support/shared_examples/services/build_execute_shared_examples.rb' - 'ee/spec/support/shared_examples/services/build_execute_shared_examples.rb'
- 'ee/spec/support/shared_examples/services/issue_epic_shared_examples.rb' - 'ee/spec/support/shared_examples/services/issue_epic_shared_examples.rb'
- 'ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb' - 'ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb'
...@@ -1434,13 +1428,16 @@ Rails/SaveBang: ...@@ -1434,13 +1428,16 @@ Rails/SaveBang:
- 'spec/policies/project_policy_spec.rb' - 'spec/policies/project_policy_spec.rb'
- 'spec/presenters/ci/build_runner_presenter_spec.rb' - 'spec/presenters/ci/build_runner_presenter_spec.rb'
- 'spec/presenters/ci/trigger_presenter_spec.rb' - 'spec/presenters/ci/trigger_presenter_spec.rb'
- 'spec/presenters/packages/conan/package_presenter_spec.rb'
- 'spec/requests/api/access_requests_spec.rb' - 'spec/requests/api/access_requests_spec.rb'
- 'spec/requests/api/boards_spec.rb' - 'spec/requests/api/boards_spec.rb'
- 'spec/requests/api/branches_spec.rb' - 'spec/requests/api/branches_spec.rb'
- 'spec/requests/api/ci/runner_spec.rb' - 'spec/requests/api/ci/runner_spec.rb'
- 'spec/requests/api/commit_statuses_spec.rb' - 'spec/requests/api/commit_statuses_spec.rb'
- 'spec/requests/api/conan_packages_spec.rb'
- 'spec/requests/api/deployments_spec.rb' - 'spec/requests/api/deployments_spec.rb'
- 'spec/requests/api/environments_spec.rb' - 'spec/requests/api/environments_spec.rb'
- 'spec/requests/api/go_proxy_spec.rb'
- 'spec/requests/api/graphql/mutations/merge_requests/set_labels_spec.rb' - 'spec/requests/api/graphql/mutations/merge_requests/set_labels_spec.rb'
- 'spec/requests/api/graphql/user_query_spec.rb' - 'spec/requests/api/graphql/user_query_spec.rb'
- 'spec/requests/api/graphql_spec.rb' - 'spec/requests/api/graphql_spec.rb'
...@@ -1451,6 +1448,7 @@ Rails/SaveBang: ...@@ -1451,6 +1448,7 @@ Rails/SaveBang:
- 'spec/requests/api/issues/post_projects_issues_spec.rb' - 'spec/requests/api/issues/post_projects_issues_spec.rb'
- 'spec/requests/api/jobs_spec.rb' - 'spec/requests/api/jobs_spec.rb'
- 'spec/requests/api/labels_spec.rb' - 'spec/requests/api/labels_spec.rb'
- 'spec/requests/api/maven_packages_spec.rb'
- 'spec/requests/api/members_spec.rb' - 'spec/requests/api/members_spec.rb'
- 'spec/requests/api/merge_request_diffs_spec.rb' - 'spec/requests/api/merge_request_diffs_spec.rb'
- 'spec/requests/api/merge_requests_spec.rb' - 'spec/requests/api/merge_requests_spec.rb'
...@@ -1573,6 +1571,8 @@ Rails/SaveBang: ...@@ -1573,6 +1571,8 @@ Rails/SaveBang:
- 'spec/support/shared_examples/requests/api/award_emoji_todo_shared_examples.rb' - 'spec/support/shared_examples/requests/api/award_emoji_todo_shared_examples.rb'
- 'spec/support/shared_examples/requests/api/boards_shared_examples.rb' - 'spec/support/shared_examples/requests/api/boards_shared_examples.rb'
- 'spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb' - 'spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb'
- 'spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb'
- 'spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb'
- 'spec/support/shared_examples/serializers/note_entity_shared_examples.rb' - 'spec/support/shared_examples/serializers/note_entity_shared_examples.rb'
- 'spec/support/shared_examples/services/common_system_notes_shared_examples.rb' - 'spec/support/shared_examples/services/common_system_notes_shared_examples.rb'
- 'spec/support/shared_examples/services/issuable_shared_examples.rb' - 'spec/support/shared_examples/services/issuable_shared_examples.rb'
......
...@@ -5,15 +5,15 @@ module Resolvers ...@@ -5,15 +5,15 @@ module Resolvers
type Types::PackageType, null: true type Types::PackageType, null: true
def resolve(**args) def resolve(**args)
return unless packages_available?(object, current_user) return unless packages_available?
::Packages::PackagesFinder.new(object).execute ::Packages::PackagesFinder.new(object).execute
end end
private private
def packages_available?(object, user) def packages_available?
::Gitlab.config.packages.enabled && object.feature_available?(:packages) ::Gitlab.config.packages.enabled
end end
end end
end end
...@@ -169,6 +169,10 @@ module Types ...@@ -169,6 +169,10 @@ module Types
description: 'A single issue of the project', description: 'A single issue of the project',
resolver: Resolvers::IssuesResolver.single resolver: Resolvers::IssuesResolver.single
field :packages, Types::PackageType.connection_type, null: true,
description: 'Packages of the project',
resolver: Resolvers::PackagesResolver
field :pipelines, field :pipelines,
Types::Ci::PipelineType.connection_type, Types::Ci::PipelineType.connection_type,
null: true, null: true,
......
...@@ -45,7 +45,7 @@ class Packages::PackageFile < ApplicationRecord ...@@ -45,7 +45,7 @@ class Packages::PackageFile < ApplicationRecord
end end
def download_path def download_path
Gitlab::Routing.url_helpers.download_project_package_file_path(project, self) Gitlab::Routing.url_helpers.download_project_package_file_path(project, self) if ::Gitlab.ee?
end end
def local? def local?
......
...@@ -843,6 +843,14 @@ ...@@ -843,6 +843,14 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: package_repositories:packages_nuget_extraction
:feature_category: :package_registry
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:tags: []
- :name: pipeline_background:archive_trace - :name: pipeline_background:archive_trace
:feature_category: :continuous_integration :feature_category: :continuous_integration
:has_external_dependencies: :has_external_dependencies:
......
---
title: Package APIs moved to core
merge_request: 35919
author:
type: changed
...@@ -48,10 +48,6 @@ module EE ...@@ -48,10 +48,6 @@ module EE
Hash.new(0).merge(project.requirements.counts_by_state) Hash.new(0).merge(project.requirements.counts_by_state)
end end
field :packages, ::Types::PackageType.connection_type, null: true,
description: 'Packages of the project',
resolver: ::Resolvers::PackagesResolver
field :compliance_frameworks, ::Types::ComplianceManagement::ComplianceFrameworkType.connection_type, field :compliance_frameworks, ::Types::ComplianceManagement::ComplianceFrameworkType.connection_type,
description: 'Compliance frameworks associated with the project', description: 'Compliance frameworks associated with the project',
resolver: ::Resolvers::ComplianceFrameworksResolver, resolver: ::Resolvers::ComplianceFrameworksResolver,
......
...@@ -491,14 +491,6 @@ ...@@ -491,14 +491,6 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: package_repositories:packages_nuget_extraction
:feature_category: :package_registry
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:tags: []
- :name: personal_access_tokens:personal_access_tokens_groups_policy - :name: personal_access_tokens:personal_access_tokens_groups_policy
:feature_category: :authentication_and_authorization :feature_category: :authentication_and_authorization
:has_external_dependencies: :has_external_dependencies:
......
...@@ -32,18 +32,8 @@ module EE ...@@ -32,18 +32,8 @@ module EE
mount ::API::License mount ::API::License
mount ::API::ProjectMirror mount ::API::ProjectMirror
mount ::API::ProjectPushRule mount ::API::ProjectPushRule
mount ::API::NugetPackages
mount ::API::PypiPackages
mount ::API::ComposerPackages
mount ::API::ConanPackages
mount ::API::MavenPackages
mount ::API::NpmPackages
mount ::API::GoProxy
mount ::API::MergeTrains mount ::API::MergeTrains
mount ::API::ProjectPackages
mount ::API::GroupPackages
mount ::API::GroupHooks mount ::API::GroupHooks
mount ::API::PackageFiles
mount ::API::Scim mount ::API::Scim
mount ::API::ManagedLicenses mount ::API::ManagedLicenses
mount ::API::ProjectApprovals mount ::API::ProjectApprovals
......
# frozen_string_literal: true
module EE
module API
module Entities
class GoModuleVersion < Grape::Entity
expose :name, as: 'Version'
expose :time, as: 'Time'
end
end
end
end
...@@ -37,9 +37,5 @@ module EE ...@@ -37,9 +37,5 @@ module EE
def stub_elasticsearch_setting(messages) def stub_elasticsearch_setting(messages)
allow(::Gitlab.config.elasticsearch).to receive_messages(to_settings(messages)) allow(::Gitlab.config.elasticsearch).to receive_messages(to_settings(messages))
end end
def stub_packages_setting(messages)
allow(::Gitlab.config.packages).to receive_messages(to_settings(messages))
end
end end
end end
...@@ -182,6 +182,16 @@ module API ...@@ -182,6 +182,16 @@ module API
mount ::API::ResourceMilestoneEvents mount ::API::ResourceMilestoneEvents
mount ::API::ResourceStateEvents mount ::API::ResourceStateEvents
mount ::API::NotificationSettings mount ::API::NotificationSettings
mount ::API::ProjectPackages
mount ::API::GroupPackages
mount ::API::PackageFiles
mount ::API::NugetPackages
mount ::API::PypiPackages
mount ::API::ComposerPackages
mount ::API::ConanPackages
mount ::API::MavenPackages
mount ::API::NpmPackages
mount ::API::GoProxy
mount ::API::Pages mount ::API::Pages
mount ::API::PagesDomains mount ::API::PagesDomains
mount ::API::ProjectClusters mount ::API::ProjectClusters
......
...@@ -54,7 +54,7 @@ module API ...@@ -54,7 +54,7 @@ module API
resource :group, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :group, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
authorize_packages_feature!(user_group) user_group
end end
desc 'Composer packages endpoint at group level' desc 'Composer packages endpoint at group level'
...@@ -98,7 +98,7 @@ module API ...@@ -98,7 +98,7 @@ module API
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
authorize_packages_feature!(unauthorized_user_project!) unauthorized_user_project!
end end
desc 'Composer packages endpoint for registering packages' desc 'Composer packages endpoint for registering packages'
......
# frozen_string_literal: true
module API
module Entities
class GoModuleVersion < Grape::Entity
expose :name, as: 'Version'
expose :time, as: 'Time'
end
end
end
...@@ -13,8 +13,10 @@ module API ...@@ -13,8 +13,10 @@ module API
expose :_links do expose :_links do
expose :web_path do |package| expose :web_path do |package|
if ::Gitlab.ee?
::Gitlab::Routing.url_helpers.project_package_path(package.project, package) ::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end end
end
expose :delete_api_path, if: can_destroy(:package, &:project) do |package| expose :delete_api_path, if: can_destroy(:package, &:project) do |package|
expose_url api_v4_projects_packages_path(package_id: package.id, id: package.project_id) expose_url api_v4_projects_packages_path(package_id: package.id, id: package.project_id)
......
...@@ -74,7 +74,6 @@ module API ...@@ -74,7 +74,6 @@ module API
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
authorize_read_package! authorize_read_package!
authorize_packages_feature!
end end
namespace ':id/packages/go/*module_name/@v' do namespace ':id/packages/go/*module_name/@v' do
...@@ -90,7 +89,7 @@ module API ...@@ -90,7 +89,7 @@ module API
desc 'Get information about the given module version' do desc 'Get information about the given module version' do
detail 'See `go help goproxy`, GET $GOPROXY/<module>/@v/<version>.info. This feature was introduced in GitLab 13.1.' detail 'See `go help goproxy`, GET $GOPROXY/<module>/@v/<version>.info. This feature was introduced in GitLab 13.1.'
success EE::API::Entities::GoModuleVersion success ::API::Entities::GoModuleVersion
end end
params do params do
requires :module_version, type: String, desc: 'Module version' requires :module_version, type: String, desc: 'Module version'
...@@ -98,7 +97,7 @@ module API ...@@ -98,7 +97,7 @@ module API
get ':module_version.info', requirements: MODULE_VERSION_REQUIREMENTS do get ':module_version.info', requirements: MODULE_VERSION_REQUIREMENTS do
ver = find_version ver = find_version
present ::Packages::Go::ModuleVersionPresenter.new(ver), with: EE::API::Entities::GoModuleVersion present ::Packages::Go::ModuleVersionPresenter.new(ver), with: ::API::Entities::GoModuleVersion
end end
desc 'Get the module file of the given module version' do desc 'Get the module file of the given module version' do
......
...@@ -125,7 +125,7 @@ module API ...@@ -125,7 +125,7 @@ module API
end end
def track_push_package_event def track_push_package_event
if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY && params['file.size'].positive? if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY && params['file.size'] > 0
track_event('push_package') track_event('push_package')
end end
end end
......
...@@ -13,10 +13,6 @@ module API ...@@ -13,10 +13,6 @@ module API
not_found! unless ::Gitlab.config.dependency_proxy.enabled not_found! unless ::Gitlab.config.dependency_proxy.enabled
end end
def authorize_packages_feature!(subject = user_project)
forbidden! unless subject.feature_available?(:packages)
end
def authorize_read_package!(subject = user_project) def authorize_read_package!(subject = user_project)
authorize!(:read_package, subject) authorize!(:read_package, subject)
end end
...@@ -31,7 +27,6 @@ module API ...@@ -31,7 +27,6 @@ module API
def authorize_packages_access!(subject = user_project) def authorize_packages_access!(subject = user_project)
require_packages_enabled! require_packages_enabled!
authorize_packages_feature!(subject)
authorize_read_package!(subject) authorize_read_package!(subject)
end end
......
...@@ -98,8 +98,6 @@ module API ...@@ -98,8 +98,6 @@ module API
package = ::Packages::Maven::PackageFinder package = ::Packages::Maven::PackageFinder
.new(params[:path], current_user, project: project).execute! .new(params[:path], current_user, project: project).execute!
authorize_packages_feature!(package.project)
package_file = ::Packages::PackageFileFinder package_file = ::Packages::PackageFileFinder
.new(package, file_name).execute! .new(package, file_name).execute!
...@@ -136,7 +134,6 @@ module API ...@@ -136,7 +134,6 @@ module API
package = ::Packages::Maven::PackageFinder package = ::Packages::Maven::PackageFinder
.new(params[:path], current_user, group: group).execute! .new(params[:path], current_user, group: group).execute!
authorize_packages_feature!(package.project)
authorize_read_package!(package.project) authorize_read_package!(package.project)
package_file = ::Packages::PackageFileFinder package_file = ::Packages::PackageFileFinder
...@@ -159,10 +156,6 @@ module API ...@@ -159,10 +156,6 @@ module API
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do
authorize_packages_feature!(user_project)
end
desc 'Download the maven package file' do desc 'Download the maven package file' do
detail 'This feature was introduced in GitLab 11.3' detail 'This feature was introduced in GitLab 11.3'
end end
......
...@@ -38,7 +38,6 @@ module API ...@@ -38,7 +38,6 @@ module API
bad_request!('Package Name') if package_name.blank? bad_request!('Package Name') if package_name.blank?
authorize_read_package!(project_by_package_name) authorize_read_package!(project_by_package_name)
authorize_packages_feature!(project_by_package_name)
packages = ::Packages::Npm::PackageFinder.new(project_by_package_name, package_name) packages = ::Packages::Npm::PackageFinder.new(project_by_package_name, package_name)
.execute .execute
...@@ -112,7 +111,6 @@ module API ...@@ -112,7 +111,6 @@ module API
redirect_registry_request(project_by_package_name.blank?, :npm, package_name: package_name) do redirect_registry_request(project_by_package_name.blank?, :npm, package_name: package_name) do
authorize_read_package!(project_by_package_name) authorize_read_package!(project_by_package_name)
authorize_packages_feature!(project_by_package_name)
packages = ::Packages::Npm::PackageFinder packages = ::Packages::Npm::PackageFinder
.new(project_by_package_name, package_name).execute .new(project_by_package_name, package_name).execute
...@@ -126,10 +124,6 @@ module API ...@@ -126,10 +124,6 @@ module API
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do
authorize_packages_feature!(user_project)
end
desc 'Download the NPM tarball' do desc 'Download the NPM tarball' do
detail 'This feature was introduced in GitLab 11.8' detail 'This feature was introduced in GitLab 11.8'
end end
......
...@@ -57,7 +57,7 @@ module API ...@@ -57,7 +57,7 @@ module API
route_setting :authentication, deploy_token_allowed: true route_setting :authentication, deploy_token_allowed: true
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
authorize_packages_feature!(authorized_user_project) authorized_user_project
end end
namespace ':id/packages/nuget' do namespace ':id/packages/nuget' do
......
...@@ -55,7 +55,7 @@ module API ...@@ -55,7 +55,7 @@ module API
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
authorize_packages_feature!(unauthorized_user_project!) unauthorized_user_project!
end end
namespace ':id/packages/pypi' do namespace ':id/packages/pypi' do
......
...@@ -12,34 +12,6 @@ RSpec.describe Resolvers::PackagesResolver do ...@@ -12,34 +12,6 @@ RSpec.describe Resolvers::PackagesResolver do
describe '#resolve' do describe '#resolve' do
subject(:packages) { resolve(described_class, ctx: { current_user: user }, obj: project) } subject(:packages) { resolve(described_class, ctx: { current_user: user }, obj: project) }
context 'when the package feature is enabled' do
before do
stub_licensed_features(packages: true)
end
context 'when the project has the package feature enabled' do
before do
allow(project).to receive(:feature_available?).with(:packages).and_return(true)
end
it { is_expected.to contain_exactly(package) } it { is_expected.to contain_exactly(package) }
end end
context 'when the project has the package feature disabled' do
before do
allow(project).to receive(:feature_available?).with(:packages).and_return(false)
end
it { is_expected.to be_nil }
end
end
context 'when the package feature is not enabled' do
before do
stub_licensed_features(packages: false)
end
it { is_expected.to be_nil }
end
end
end end
...@@ -11,41 +11,12 @@ RSpec.describe API::Helpers::PackagesHelpers do ...@@ -11,41 +11,12 @@ RSpec.describe API::Helpers::PackagesHelpers do
it 'authorizes packages access' do it 'authorizes packages access' do
expect(helper).to receive(:require_packages_enabled!) expect(helper).to receive(:require_packages_enabled!)
expect(helper).to receive(:authorize_packages_feature!).with(project)
expect(helper).to receive(:authorize_read_package!).with(project) expect(helper).to receive(:authorize_read_package!).with(project)
expect(subject).to eq nil expect(subject).to eq nil
end end
end end
describe 'authorize_packages_feature!' do
let(:feature_enabled) { true }
subject { helper.authorize_packages_feature!(project) }
before do
allow(project).to receive(:feature_available?).with(:packages).and_return(feature_enabled)
end
context 'with feature enabled' do
it "doesn't call forbidden!" do
expect(helper).to receive(:forbidden!).never
expect(subject).to eq nil
end
end
context 'with feature disabled' do
let(:feature_enabled) { false }
it 'calls forbidden!' do
expect(helper).to receive(:forbidden!).once
subject
end
end
end
%i[read_package create_package destroy_package].each do |action| %i[read_package create_package destroy_package].each do |action|
describe "authorize_#{action}!" do describe "authorize_#{action}!" do
subject { helper.send("authorize_#{action}!", project) } subject { helper.send("authorize_#{action}!", project) }
......
...@@ -16,11 +16,7 @@ RSpec.describe API::ComposerPackages do ...@@ -16,11 +16,7 @@ RSpec.describe API::ComposerPackages do
subject { get api(url), headers: headers } subject { get api(url), headers: headers }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
let!(:package) { create(:composer_package, :with_metadatum, project: project) } let!(:package) { create(:composer_package, :with_metadatum, project: project) }
...@@ -56,8 +52,6 @@ RSpec.describe API::ComposerPackages do ...@@ -56,8 +52,6 @@ RSpec.describe API::ComposerPackages do
it_behaves_like 'rejects Composer access with unknown group id' it_behaves_like 'rejects Composer access with unknown group id'
end end
it_behaves_like 'rejects Composer packages access with packages features disabled'
end end
describe 'GET /api/v4/group/:id/-/packages/composer/p/:sha.json' do describe 'GET /api/v4/group/:id/-/packages/composer/p/:sha.json' do
...@@ -67,11 +61,7 @@ RSpec.describe API::ComposerPackages do ...@@ -67,11 +61,7 @@ RSpec.describe API::ComposerPackages do
subject { get api(url), headers: headers } subject { get api(url), headers: headers }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -105,8 +95,6 @@ RSpec.describe API::ComposerPackages do ...@@ -105,8 +95,6 @@ RSpec.describe API::ComposerPackages do
it_behaves_like 'rejects Composer access with unknown group id' it_behaves_like 'rejects Composer access with unknown group id'
end end
it_behaves_like 'rejects Composer packages access with packages features disabled'
end end
describe 'GET /api/v4/group/:id/-/packages/composer/*package_name.json' do describe 'GET /api/v4/group/:id/-/packages/composer/*package_name.json' do
...@@ -115,18 +103,14 @@ RSpec.describe API::ComposerPackages do ...@@ -115,18 +103,14 @@ RSpec.describe API::ComposerPackages do
subject { get api(url), headers: headers } subject { get api(url), headers: headers }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with no packages' do context 'with no packages' do
include_context 'Composer user type', :developer, true do include_context 'Composer user type', :developer, true do
it_behaves_like 'returning response status', :not_found it_behaves_like 'returning response status', :not_found
end end
end end
context 'with valid project and packages' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let!(:package) { create(:composer_package, :with_metadatum, name: package_name, project: project) } let!(:package) { create(:composer_package, :with_metadatum, name: package_name, project: project) }
...@@ -161,8 +145,6 @@ RSpec.describe API::ComposerPackages do ...@@ -161,8 +145,6 @@ RSpec.describe API::ComposerPackages do
it_behaves_like 'rejects Composer access with unknown group id' it_behaves_like 'rejects Composer access with unknown group id'
end end
it_behaves_like 'rejects Composer packages access with packages features disabled'
end end
describe 'POST /api/v4/projects/:id/packages/composer' do describe 'POST /api/v4/projects/:id/packages/composer' do
...@@ -176,11 +158,7 @@ RSpec.describe API::ComposerPackages do ...@@ -176,11 +158,7 @@ RSpec.describe API::ComposerPackages do
subject { post api(url), headers: headers, params: params } subject { post api(url), headers: headers, params: params }
shared_examples 'composer package publish' do shared_examples 'composer package publish' do
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -216,15 +194,9 @@ RSpec.describe API::ComposerPackages do ...@@ -216,15 +194,9 @@ RSpec.describe API::ComposerPackages do
end end
end end
it_behaves_like 'rejects Composer packages access with packages features disabled'
context 'with no tag or branch params' do context 'with no tag or branch params' do
let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) } let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) }
before do
stub_licensed_features(packages: true)
end
it_behaves_like 'process Composer api request', :developer, :bad_request it_behaves_like 'process Composer api request', :developer, :bad_request
end end
...@@ -239,10 +211,6 @@ RSpec.describe API::ComposerPackages do ...@@ -239,10 +211,6 @@ RSpec.describe API::ComposerPackages do
let(:params) { { tag: 'non-existing-tag' } } let(:params) { { tag: 'non-existing-tag' } }
let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) } let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) }
before do
stub_licensed_features(packages: true)
end
it_behaves_like 'process Composer api request', :developer, :not_found it_behaves_like 'process Composer api request', :developer, :not_found
end end
end end
...@@ -258,10 +226,6 @@ RSpec.describe API::ComposerPackages do ...@@ -258,10 +226,6 @@ RSpec.describe API::ComposerPackages do
let(:params) { { branch: 'non-existing-branch' } } let(:params) { { branch: 'non-existing-branch' } }
let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) } let(:headers) { build_basic_auth_header(user.username, personal_access_token.token) }
before do
stub_licensed_features(packages: true)
end
it_behaves_like 'process Composer api request', :developer, :not_found it_behaves_like 'process Composer api request', :developer, :not_found
end end
end end
...@@ -274,11 +238,7 @@ RSpec.describe API::ComposerPackages do ...@@ -274,11 +238,7 @@ RSpec.describe API::ComposerPackages do
subject { get api(url), headers: headers, params: params } subject { get api(url), headers: headers, params: params }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
let!(:package) { create(:composer_package, :with_metadatum, name: package_name, project: project) } let!(:package) { create(:composer_package, :with_metadatum, name: package_name, project: project) }
...@@ -338,7 +298,5 @@ RSpec.describe API::ComposerPackages do ...@@ -338,7 +298,5 @@ RSpec.describe API::ComposerPackages do
it_behaves_like 'rejects Composer access with unknown project id' it_behaves_like 'rejects Composer access with unknown project id'
end end
it_behaves_like 'rejects Composer packages access with packages features disabled'
end end
end end
...@@ -31,7 +31,6 @@ RSpec.describe API::ConanPackages do ...@@ -31,7 +31,6 @@ RSpec.describe API::ConanPackages do
before do before do
project.add_developer(user) project.add_developer(user)
stub_licensed_features(packages: true)
allow(Settings).to receive(:attr_encrypted_db_key_base).and_return(base_secret) allow(Settings).to receive(:attr_encrypted_db_key_base).and_return(base_secret)
end end
......
...@@ -30,7 +30,6 @@ RSpec.describe API::GoProxy do ...@@ -30,7 +30,6 @@ RSpec.describe API::GoProxy do
before do before do
project.add_developer(user) project.add_developer(user)
stub_licensed_features(packages: true)
stub_feature_flags(go_proxy_disable_gomod_validation: false) stub_feature_flags(go_proxy_disable_gomod_validation: false)
modules modules
......
...@@ -28,11 +28,7 @@ RSpec.describe 'getting a package list for a project' do ...@@ -28,11 +28,7 @@ RSpec.describe 'getting a package list for a project' do
) )
end end
context 'when package feature is available' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'when user has access to the project' do context 'when user has access to the project' do
before do before do
project.add_reporter(current_user) project.add_reporter(current_user)
...@@ -70,18 +66,4 @@ RSpec.describe 'getting a package list for a project' do ...@@ -70,18 +66,4 @@ RSpec.describe 'getting a package list for a project' do
end end
end end
end end
context 'when package feature is not available' do
before do
stub_licensed_features(packages: false)
project.add_reporter(current_user)
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
it 'returns nil' do
expect(graphql_data['project']['packages']).to be_nil
end
end
end end
...@@ -13,11 +13,7 @@ RSpec.describe API::GroupPackages do ...@@ -13,11 +13,7 @@ RSpec.describe API::GroupPackages do
let(:url) { "/groups/#{group.id}/packages" } let(:url) { "/groups/#{group.id}/packages" }
let(:package_schema) { 'public_api/v4/packages/group_packages' } let(:package_schema) { 'public_api/v4/packages/group_packages' }
context 'with packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with sorting' do context 'with sorting' do
let_it_be(:package1) { create(:npm_package, project: project, version: '3.1.0', name: "@#{project.root_namespace.path}/foo1") } let_it_be(:package1) { create(:npm_package, project: project, version: '3.1.0', name: "@#{project.root_namespace.path}/foo1") }
let_it_be(:package2) { create(:nuget_package, project: project, version: '2.0.4') } let_it_be(:package2) { create(:nuget_package, project: project, version: '2.0.4') }
...@@ -147,13 +143,5 @@ RSpec.describe API::GroupPackages do ...@@ -147,13 +143,5 @@ RSpec.describe API::GroupPackages do
it_behaves_like 'returning response status', :bad_request it_behaves_like 'returning response status', :bad_request
end end
end end
context 'with packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'rejects packages access', :group, :no_type, :forbidden
end
end end
end end
...@@ -30,7 +30,6 @@ RSpec.describe API::MavenPackages do ...@@ -30,7 +30,6 @@ RSpec.describe API::MavenPackages do
before do before do
project.add_developer(user) project.add_developer(user)
stub_licensed_features(packages: true)
end end
shared_examples 'tracking the file download event' do shared_examples 'tracking the file download event' do
...@@ -196,14 +195,6 @@ RSpec.describe API::MavenPackages do ...@@ -196,14 +195,6 @@ RSpec.describe API::MavenPackages do
it_behaves_like 'downloads with a deploy token' it_behaves_like 'downloads with a deploy token'
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
download_file(package_file.file_name)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'project name is different from a package name' do context 'project name is different from a package name' do
before do before do
maven_metadatum.update!(path: "wrong_name/#{package.version}") maven_metadatum.update!(path: "wrong_name/#{package.version}")
...@@ -321,14 +312,6 @@ RSpec.describe API::MavenPackages do ...@@ -321,14 +312,6 @@ RSpec.describe API::MavenPackages do
it_behaves_like 'downloads with a deploy token' it_behaves_like 'downloads with a deploy token'
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
download_file(package_file.file_name)
expect(response).to have_gitlab_http_status(:forbidden)
end
def download_file(file_name, params = {}, request_headers = headers) def download_file(file_name, params = {}, request_headers = headers)
get api("/groups/#{group.id}/-/packages/maven/#{maven_metadatum.path}/#{file_name}"), params: params, headers: request_headers get api("/groups/#{group.id}/-/packages/maven/#{maven_metadatum.path}/#{file_name}"), params: params, headers: request_headers
end end
...@@ -401,14 +384,6 @@ RSpec.describe API::MavenPackages do ...@@ -401,14 +384,6 @@ RSpec.describe API::MavenPackages do
it_behaves_like 'downloads with a deploy token' it_behaves_like 'downloads with a deploy token'
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
download_file(package_file.file_name)
expect(response).to have_gitlab_http_status(:forbidden)
end
def download_file(file_name, params = {}, request_headers = headers) def download_file(file_name, params = {}, request_headers = headers)
get api("/projects/#{project.id}/packages/maven/" \ get api("/projects/#{project.id}/packages/maven/" \
"#{maven_metadatum.path}/#{file_name}"), params: params, headers: request_headers "#{maven_metadatum.path}/#{file_name}"), params: params, headers: request_headers
...@@ -508,14 +483,6 @@ RSpec.describe API::MavenPackages do ...@@ -508,14 +483,6 @@ RSpec.describe API::MavenPackages do
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
upload_file_with_token
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'without workhorse rewritten field' do context 'without workhorse rewritten field' do
let(:send_rewritten_field) { false } let(:send_rewritten_field) { false }
......
...@@ -17,7 +17,6 @@ RSpec.describe API::NpmPackages do ...@@ -17,7 +17,6 @@ RSpec.describe API::NpmPackages do
before do before do
project.add_developer(user) project.add_developer(user)
stub_licensed_features(packages: true)
end end
shared_examples 'a package that requires auth' do shared_examples 'a package that requires auth' do
...@@ -134,14 +133,6 @@ RSpec.describe API::NpmPackages do ...@@ -134,14 +133,6 @@ RSpec.describe API::NpmPackages do
end end
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
get_package(package)
expect(response).to have_gitlab_http_status(:forbidden)
end
def get_package(package, params = {}, headers = {}) def get_package(package, params = {}, headers = {})
get api("/packages/npm/#{package.name}"), params: params, headers: headers get api("/packages/npm/#{package.name}"), params: params, headers: headers
end end
...@@ -221,14 +212,6 @@ RSpec.describe API::NpmPackages do ...@@ -221,14 +212,6 @@ RSpec.describe API::NpmPackages do
it_behaves_like 'a package file that requires auth' it_behaves_like 'a package file that requires auth'
end end
it 'rejects request if feature is not in the license' do
stub_licensed_features(packages: false)
get_file(package_file)
expect(response).to have_gitlab_http_status(:forbidden)
end
def get_file(package_file, params = {}) def get_file(package_file, params = {})
get api("/projects/#{project.id}/packages/npm/" \ get api("/projects/#{project.id}/packages/npm/" \
"#{package_file.package.name}/-/#{package_file.file_name}"), params: params "#{package_file.package.name}/-/#{package_file.file_name}"), params: params
...@@ -424,11 +407,7 @@ RSpec.describe API::NpmPackages do ...@@ -424,11 +407,7 @@ RSpec.describe API::NpmPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with public project' do context 'with public project' do
context 'with authenticated user' do context 'with authenticated user' do
subject { get api(url, personal_access_token: personal_access_token) } subject { get api(url, personal_access_token: personal_access_token) }
...@@ -463,14 +442,6 @@ RSpec.describe API::NpmPackages do ...@@ -463,14 +442,6 @@ RSpec.describe API::NpmPackages do
end end
end end
end end
context 'with packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'rejects package tags access', :no_type, :forbidden
end
end end
describe 'PUT /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do describe 'PUT /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do
...@@ -482,11 +453,7 @@ RSpec.describe API::NpmPackages do ...@@ -482,11 +453,7 @@ RSpec.describe API::NpmPackages do
subject { put api(url), env: { 'api.request.body': version } } subject { put api(url), env: { 'api.request.body': version } }
context 'with packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with public project' do context 'with public project' do
context 'with authenticated user' do context 'with authenticated user' do
subject { put api(url, personal_access_token: personal_access_token), env: { 'api.request.body': version } } subject { put api(url, personal_access_token: personal_access_token), env: { 'api.request.body': version } }
...@@ -521,14 +488,6 @@ RSpec.describe API::NpmPackages do ...@@ -521,14 +488,6 @@ RSpec.describe API::NpmPackages do
end end
end end
end end
context 'with packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'rejects package tags access', :no_type, :unauthorized
end
end end
describe 'DELETE /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do describe 'DELETE /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do
...@@ -540,11 +499,7 @@ RSpec.describe API::NpmPackages do ...@@ -540,11 +499,7 @@ RSpec.describe API::NpmPackages do
subject { delete api(url) } subject { delete api(url) }
context 'with packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with public project' do context 'with public project' do
context 'with authenticated user' do context 'with authenticated user' do
subject { delete api(url, personal_access_token: personal_access_token) } subject { delete api(url, personal_access_token: personal_access_token) }
...@@ -579,14 +534,6 @@ RSpec.describe API::NpmPackages do ...@@ -579,14 +534,6 @@ RSpec.describe API::NpmPackages do
end end
end end
end end
context 'with packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'rejects package tags access', :no_type, :unauthorized
end
end end
def expect_a_valid_package_response def expect_a_valid_package_response
......
...@@ -16,11 +16,7 @@ RSpec.describe API::NugetPackages do ...@@ -16,11 +16,7 @@ RSpec.describe API::NugetPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -65,8 +61,6 @@ RSpec.describe API::NugetPackages do ...@@ -65,8 +61,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'PUT /api/v4/projects/:id/packages/nuget/authorize' do describe 'PUT /api/v4/projects/:id/packages/nuget/authorize' do
...@@ -77,11 +71,7 @@ RSpec.describe API::NugetPackages do ...@@ -77,11 +71,7 @@ RSpec.describe API::NugetPackages do
subject { put api(url), headers: headers } subject { put api(url), headers: headers }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -125,8 +115,6 @@ RSpec.describe API::NugetPackages do ...@@ -125,8 +115,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'PUT /api/v4/projects/:id/packages/nuget' do describe 'PUT /api/v4/projects/:id/packages/nuget' do
...@@ -150,11 +138,7 @@ RSpec.describe API::NugetPackages do ...@@ -150,11 +138,7 @@ RSpec.describe API::NugetPackages do
) )
end end
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -198,8 +182,6 @@ RSpec.describe API::NugetPackages do ...@@ -198,8 +182,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/nuget/metadata/*package_name/index' do describe 'GET /api/v4/projects/:id/packages/nuget/metadata/*package_name/index' do
...@@ -216,11 +198,7 @@ RSpec.describe API::NugetPackages do ...@@ -216,11 +198,7 @@ RSpec.describe API::NugetPackages do
packages.each { |pkg| create_dependencies_for(pkg) } packages.each { |pkg| create_dependencies_for(pkg) }
end end
context 'with packages features enabled' do context 'without the need for license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -265,8 +243,6 @@ RSpec.describe API::NugetPackages do ...@@ -265,8 +243,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/nuget/metadata/*package_name/*package_version' do describe 'GET /api/v4/projects/:id/packages/nuget/metadata/*package_name/*package_version' do
...@@ -283,11 +259,7 @@ RSpec.describe API::NugetPackages do ...@@ -283,11 +259,7 @@ RSpec.describe API::NugetPackages do
create_dependencies_for(package) create_dependencies_for(package)
end end
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -334,8 +306,6 @@ RSpec.describe API::NugetPackages do ...@@ -334,8 +306,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget packages access', :developer, :not_found it_behaves_like 'rejects nuget packages access', :developer, :not_found
end end
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/nuget/download/*package_name/index' do describe 'GET /api/v4/projects/:id/packages/nuget/download/*package_name/index' do
...@@ -345,11 +315,7 @@ RSpec.describe API::NugetPackages do ...@@ -345,11 +315,7 @@ RSpec.describe API::NugetPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -394,8 +360,6 @@ RSpec.describe API::NugetPackages do ...@@ -394,8 +360,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/nuget/download/*package_name/*package_version/*package_filename' do describe 'GET /api/v4/projects/:id/packages/nuget/download/*package_name/*package_version/*package_filename' do
...@@ -406,11 +370,7 @@ RSpec.describe API::NugetPackages do ...@@ -406,11 +370,7 @@ RSpec.describe API::NugetPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -455,8 +415,6 @@ RSpec.describe API::NugetPackages do ...@@ -455,8 +415,6 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/nuget/query' do describe 'GET /api/v4/projects/:id/packages/nuget/query' do
...@@ -475,11 +433,7 @@ RSpec.describe API::NugetPackages do ...@@ -475,11 +433,7 @@ RSpec.describe API::NugetPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -524,7 +478,5 @@ RSpec.describe API::NugetPackages do ...@@ -524,7 +478,5 @@ RSpec.describe API::NugetPackages do
it_behaves_like 'rejects nuget access with invalid project id' it_behaves_like 'rejects nuget access with invalid project id'
end end
it_behaves_like 'rejects nuget packages access with packages features disabled'
end end
end end
...@@ -14,11 +14,7 @@ RSpec.describe API::PackageFiles do ...@@ -14,11 +14,7 @@ RSpec.describe API::PackageFiles do
describe 'GET /projects/:id/packages/:package_id/package_files' do describe 'GET /projects/:id/packages/:package_id/package_files' do
let(:url) { "/projects/#{project.id}/packages/#{package.id}/package_files" } let(:url) { "/projects/#{project.id}/packages/#{package.id}/package_files" }
context 'packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'project is public' do context 'project is public' do
it 'returns 200' do it 'returns 200' do
get api(url) get api(url)
...@@ -64,10 +60,6 @@ RSpec.describe API::PackageFiles do ...@@ -64,10 +60,6 @@ RSpec.describe API::PackageFiles do
let!(:package_file_2) { package.package_files[1] } let!(:package_file_2) { package.package_files[1] }
let!(:package_file_3) { package.package_files[2] } let!(:package_file_3) { package.package_files[2] }
before do
stub_licensed_features(packages: true)
end
context 'when viewing the first page' do context 'when viewing the first page' do
it 'returns first 2 packages' do it 'returns first 2 packages' do
get api(url, user), params: { page: 1, per_page: per_page } get api(url, user), params: { page: 1, per_page: per_page }
...@@ -85,17 +77,5 @@ RSpec.describe API::PackageFiles do ...@@ -85,17 +77,5 @@ RSpec.describe API::PackageFiles do
end end
end end
end end
context 'packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it 'returns 403' do
get api(url, user)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end end
end end
...@@ -18,11 +18,7 @@ RSpec.describe API::ProjectPackages do ...@@ -18,11 +18,7 @@ RSpec.describe API::ProjectPackages do
subject { get api(url) } subject { get api(url) }
context 'packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'project is public' do context 'project is public' do
it_behaves_like 'returns packages', :project, :no_type it_behaves_like 'returns packages', :project, :no_type
end end
...@@ -109,18 +105,6 @@ RSpec.describe API::ProjectPackages do ...@@ -109,18 +105,6 @@ RSpec.describe API::ProjectPackages do
end end
end end
end end
context 'packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it 'returns 403' do
get api(url, user)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end end
describe 'GET /projects/:id/packages/:package_id' do describe 'GET /projects/:id/packages/:package_id' do
...@@ -142,11 +126,7 @@ RSpec.describe API::ProjectPackages do ...@@ -142,11 +126,7 @@ RSpec.describe API::ProjectPackages do
end end
end end
context 'packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'project is public' do context 'project is public' do
it 'returns 200 and the package information' do it 'returns 200 and the package information' do
subject subject
...@@ -222,26 +202,10 @@ RSpec.describe API::ProjectPackages do ...@@ -222,26 +202,10 @@ RSpec.describe API::ProjectPackages do
end end
end end
end end
context 'packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it 'returns 403' do
subject
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end end
describe 'DELETE /projects/:id/packages/:package_id' do describe 'DELETE /projects/:id/packages/:package_id' do
context 'packages feature enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'project is public' do context 'project is public' do
it 'returns 403 for non authenticated user' do it 'returns 403 for non authenticated user' do
delete api(package_url) delete api(package_url)
...@@ -304,17 +268,5 @@ RSpec.describe API::ProjectPackages do ...@@ -304,17 +268,5 @@ RSpec.describe API::ProjectPackages do
end end
end end
end end
context 'packages feature disabled' do
before do
stub_licensed_features(packages: false)
end
it 'returns 403' do
delete api(package_url, user)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end end
end end
...@@ -17,11 +17,7 @@ RSpec.describe API::PypiPackages do ...@@ -17,11 +17,7 @@ RSpec.describe API::PypiPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -64,8 +60,6 @@ RSpec.describe API::PypiPackages do ...@@ -64,8 +60,6 @@ RSpec.describe API::PypiPackages do
it_behaves_like 'rejects PyPI access with unknown project id' it_behaves_like 'rejects PyPI access with unknown project id'
end end
it_behaves_like 'rejects PyPI packages access with packages features disabled'
end end
describe 'POST /api/v4/projects/:id/packages/pypi/authorize' do describe 'POST /api/v4/projects/:id/packages/pypi/authorize' do
...@@ -76,11 +70,7 @@ RSpec.describe API::PypiPackages do ...@@ -76,11 +70,7 @@ RSpec.describe API::PypiPackages do
subject { post api(url), headers: headers } subject { post api(url), headers: headers }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -122,8 +112,6 @@ RSpec.describe API::PypiPackages do ...@@ -122,8 +112,6 @@ RSpec.describe API::PypiPackages do
it_behaves_like 'rejects PyPI access with unknown project id' it_behaves_like 'rejects PyPI access with unknown project id'
end end
it_behaves_like 'rejects PyPI packages access with packages features disabled'
end end
describe 'POST /api/v4/projects/:id/packages/pypi' do describe 'POST /api/v4/projects/:id/packages/pypi' do
...@@ -147,11 +135,7 @@ RSpec.describe API::PypiPackages do ...@@ -147,11 +135,7 @@ RSpec.describe API::PypiPackages do
) )
end end
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -206,8 +190,6 @@ RSpec.describe API::PypiPackages do ...@@ -206,8 +190,6 @@ RSpec.describe API::PypiPackages do
it_behaves_like 'rejects PyPI access with unknown project id' it_behaves_like 'rejects PyPI access with unknown project id'
end end
it_behaves_like 'rejects PyPI packages access with packages features disabled'
end end
describe 'GET /api/v4/projects/:id/packages/pypi/files/:sha256/*file_identifier' do describe 'GET /api/v4/projects/:id/packages/pypi/files/:sha256/*file_identifier' do
...@@ -218,11 +200,7 @@ RSpec.describe API::PypiPackages do ...@@ -218,11 +200,7 @@ RSpec.describe API::PypiPackages do
subject { get api(url) } subject { get api(url) }
context 'with packages features enabled' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
context 'with valid project' do context 'with valid project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -277,7 +255,5 @@ RSpec.describe API::PypiPackages do ...@@ -277,7 +255,5 @@ RSpec.describe API::PypiPackages do
it_behaves_like 'rejects PyPI access with unknown project id' it_behaves_like 'rejects PyPI access with unknown project id'
end end
it_behaves_like 'rejects PyPI packages access with packages features disabled'
end end
end end
...@@ -117,6 +117,10 @@ module StubConfiguration ...@@ -117,6 +117,10 @@ module StubConfiguration
allow(::Gitlab.config.service_desk_email).to receive_messages(to_settings(messages)) allow(::Gitlab.config.service_desk_email).to receive_messages(to_settings(messages))
end end
def stub_packages_setting(messages)
allow(::Gitlab.config.packages).to receive_messages(to_settings(messages))
end
private private
# Modifies stubbed messages to also stub possible predicate versions # Modifies stubbed messages to also stub possible predicate versions
......
...@@ -121,16 +121,6 @@ RSpec.shared_examples 'rejects Composer access with unknown group id' do ...@@ -121,16 +121,6 @@ RSpec.shared_examples 'rejects Composer access with unknown group id' do
end end
end end
RSpec.shared_examples 'rejects Composer packages access with packages features disabled' do
context 'with packages features disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'process Composer api request', :anonymous, :forbidden
end
end
RSpec.shared_examples 'rejects Composer access with unknown project id' do RSpec.shared_examples 'rejects Composer access with unknown project id' do
context 'with an unknown project' do context 'with an unknown project' do
let(:project) { double(id: non_existing_record_id) } let(:project) { double(id: non_existing_record_id) }
......
...@@ -18,16 +18,6 @@ RSpec.shared_examples 'rejects nuget packages access' do |user_type, status, add ...@@ -18,16 +18,6 @@ RSpec.shared_examples 'rejects nuget packages access' do |user_type, status, add
end end
end end
RSpec.shared_examples 'rejects nuget packages access with packages features disabled' do
context 'with packages features disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'rejects nuget packages access', :anonymous, :forbidden
end
end
RSpec.shared_examples 'process nuget service index request' do |user_type, status, add_member = true| RSpec.shared_examples 'process nuget service index request' do |user_type, status, add_member = true|
context "for user type #{user_type}" do context "for user type #{user_type}" do
before do before do
......
...@@ -150,13 +150,3 @@ RSpec.shared_examples 'rejects PyPI access with unknown project id' do ...@@ -150,13 +150,3 @@ RSpec.shared_examples 'rejects PyPI access with unknown project id' do
end end
end end
end end
RSpec.shared_examples 'rejects PyPI packages access with packages features disabled' do
context 'with packages features disabled' do
before do
stub_licensed_features(packages: false)
end
it_behaves_like 'process PyPi api request', :anonymous, :forbidden
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment