Commit c30e32ef authored by Steve Abrams's avatar Steve Abrams Committed by Giorgenes Gelatti

Remove Package License

- Remote package license and
checks accordingly.
- Fix specs
parent 99d9728a
...@@ -11,8 +11,7 @@ module PackagesAccess ...@@ -11,8 +11,7 @@ module PackagesAccess
private private
def verify_packages_enabled! def verify_packages_enabled!
render_404 unless Gitlab.config.packages.enabled && render_404 unless Gitlab.config.packages.enabled
project.feature_available?(:packages)
end end
def verify_read_package! def verify_read_package!
......
...@@ -60,6 +60,10 @@ module EE ...@@ -60,6 +60,10 @@ module EE
attrs << :maintenance_mode_message attrs << :maintenance_mode_message
end end
if License.feature_available?(:package_forwarding)
attrs << :npm_package_requests_forwarding
end
attrs attrs
end end
......
...@@ -31,9 +31,7 @@ module EE ...@@ -31,9 +31,7 @@ module EE
nav_tabs += get_project_security_nav_tabs(project, current_user) nav_tabs += get_project_security_nav_tabs(project, current_user)
if ::Gitlab.config.packages.enabled && if ::Gitlab.config.packages.enabled && can?(current_user, :read_package, project)
project.feature_available?(:packages) &&
can?(current_user, :read_package, project)
nav_tabs << :packages nav_tabs << :packages
end end
...@@ -73,7 +71,7 @@ module EE ...@@ -73,7 +71,7 @@ module EE
override :project_permissions_panel_data override :project_permissions_panel_data
def project_permissions_panel_data(project) def project_permissions_panel_data(project)
super.merge( super.merge(
packagesAvailable: ::Gitlab.config.packages.enabled && project.feature_available?(:packages), packagesAvailable: ::Gitlab.config.packages.enabled,
packagesHelpPath: help_page_path('user/packages/index') packagesHelpPath: help_page_path('user/packages/index')
) )
end end
......
...@@ -94,7 +94,7 @@ class License < ApplicationRecord ...@@ -94,7 +94,7 @@ class License < ApplicationRecord
object_storage object_storage
operations_dashboard operations_dashboard
opsgenie_integration opsgenie_integration
packages package_forwarding
pages_size_limit pages_size_limit
productivity_analytics productivity_analytics
project_aliases project_aliases
......
...@@ -18,7 +18,7 @@ module EE ...@@ -18,7 +18,7 @@ module EE
expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) } expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) }
expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) } expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) } expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) }
expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:packages) } expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:package_forwarding) }
expose :group_owners_can_manage_default_branch_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_branch_protection_restriction_in_groups) } expose :group_owners_can_manage_default_branch_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_branch_protection_restriction_in_groups) }
expose :maintenance_mode, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) } expose :maintenance_mode, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) }
expose :maintenance_mode_message, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) } expose :maintenance_mode_message, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) }
......
...@@ -24,7 +24,7 @@ module EE ...@@ -24,7 +24,7 @@ module EE
expose :mirror_overwrites_diverged_branches, if: ->(project, _) { project.mirror? } expose :mirror_overwrites_diverged_branches, if: ->(project, _) { project.mirror? }
expose :external_authorization_classification_label, expose :external_authorization_classification_label,
if: ->(_, _) { License.feature_available?(:external_authorization_service_api_management) } if: ->(_, _) { License.feature_available?(:external_authorization_service_api_management) }
expose :packages_enabled, if: ->(project, _) { project.feature_available?(:packages) } expose :packages_enabled
expose :marked_for_deletion_at, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) } expose :marked_for_deletion_at, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :marked_for_deletion_on, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) } do |project, _| expose :marked_for_deletion_on, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) } do |project, _|
project.marked_for_deletion_at project.marked_for_deletion_at
......
...@@ -39,7 +39,7 @@ module EE ...@@ -39,7 +39,7 @@ module EE
attrs = attrs.except(*EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes) attrs = attrs.except(*EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes)
end end
unless License.feature_available?(:packages) unless License.feature_available?(:package_forwarding)
attrs = attrs.except(:npm_package_requests_forwarding) attrs = attrs.except(:npm_package_requests_forwarding)
end end
......
...@@ -120,7 +120,7 @@ RSpec.describe Admin::ApplicationSettingsController do ...@@ -120,7 +120,7 @@ RSpec.describe Admin::ApplicationSettingsController do
context 'updating npm packages request forwarding setting' do context 'updating npm packages request forwarding setting' do
let(:settings) { { npm_package_requests_forwarding: true } } let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages } let(:feature) { :package_forwarding }
it_behaves_like 'settings for licensed features' it_behaves_like 'settings for licensed features'
end end
......
...@@ -17,6 +17,8 @@ RSpec.describe 'Group navbar' do ...@@ -17,6 +17,8 @@ RSpec.describe 'Group navbar' do
stub_feature_flags(group_iterations: false) stub_feature_flags(group_iterations: false)
stub_feature_flags(group_wiki: false) stub_feature_flags(group_wiki: false)
sign_in(user) sign_in(user)
insert_package_nav(_('Kubernetes'))
end end
context 'when productivity analytics is available' do context 'when productivity analytics is available' do
...@@ -148,20 +150,10 @@ RSpec.describe 'Group navbar' do ...@@ -148,20 +150,10 @@ RSpec.describe 'Group navbar' do
context 'when packages are available' do context 'when packages are available' do
before do before do
stub_config(packages: { enabled: true }, registry: { enabled: false }) stub_config(packages: { enabled: true }, registry: { enabled: false })
stub_licensed_features(packages: true)
insert_after_nav_item(
_('Kubernetes'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
visit group_path(group) visit group_path(group)
end end
it_behaves_like 'verified navigation bar'
context 'when container registry is available' do context 'when container registry is available' do
before do before do
stub_config(registry: { enabled: true }) stub_config(registry: { enabled: true })
......
...@@ -10,22 +10,9 @@ RSpec.describe 'Group Packages' do ...@@ -10,22 +10,9 @@ RSpec.describe 'Group Packages' do
before do before do
sign_in(user) sign_in(user)
group.add_maintainer(user) group.add_maintainer(user)
stub_licensed_features(packages: true)
end end
context 'when feature is not available' do context 'when feature is not available' do
context 'packages feature is not available because of license' do
before do
stub_licensed_features(packages: false)
end
it 'gives 404' do
visit_group_packages
expect(page).to have_gitlab_http_status(:not_found)
end
end
context 'packages feature is disabled by config' do context 'packages feature is disabled by config' do
before do before do
allow(Gitlab.config.packages).to receive(:enabled).and_return(false) allow(Gitlab.config.packages).to receive(:enabled).and_return(false)
......
...@@ -11,6 +11,14 @@ RSpec.describe 'Project navbar' do ...@@ -11,6 +11,14 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
insert_after_sub_nav_item(
_('Labels'),
within: _('Issues'),
new_sub_nav_item_name: _('Service Desk')
)
insert_package_nav(_('Operations'))
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
...@@ -56,21 +64,10 @@ RSpec.describe 'Project navbar' do ...@@ -56,21 +64,10 @@ RSpec.describe 'Project navbar' do
context 'when packages are available' do context 'when packages are available' do
before do before do
stub_config(packages: { enabled: true }, registry: { enabled: false }) stub_config(packages: { enabled: true }, registry: { enabled: false })
stub_licensed_features(packages: true)
insert_after_nav_item(
_('Operations'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
visit project_path(project) visit project_path(project)
end end
it_behaves_like 'verified navigation bar'
context 'when container registry is available' do context 'when container registry is available' do
before do before do
stub_config(registry: { enabled: true }) stub_config(registry: { enabled: true })
......
...@@ -10,7 +10,6 @@ RSpec.describe 'PackageFiles' do ...@@ -10,7 +10,6 @@ RSpec.describe 'PackageFiles' do
before do before do
sign_in(user) sign_in(user)
stub_licensed_features(packages: true)
end end
context 'user with master role' do context 'user with master role' do
...@@ -40,14 +39,6 @@ RSpec.describe 'PackageFiles' do ...@@ -40,14 +39,6 @@ RSpec.describe 'PackageFiles' do
expect(status_code).to eq(404) expect(status_code).to eq(404)
end end
it 'gives 404 when packages feature is not available' do
stub_licensed_features(packages: false)
visit download_project_package_file_path(project, package_file)
expect(status_code).to eq(404)
end
end end
it 'does not allow direct download when no access to the project' do it 'does not allow direct download when no access to the project' do
......
...@@ -9,22 +9,9 @@ RSpec.describe 'Packages' do ...@@ -9,22 +9,9 @@ RSpec.describe 'Packages' do
before do before do
sign_in(user) sign_in(user)
project.add_maintainer(user) project.add_maintainer(user)
stub_licensed_features(packages: true)
end end
context 'when feature is not available' do context 'when feature is not available' do
context 'packages feature is not available because of license' do
before do
stub_licensed_features(packages: false)
end
it 'gives 404' do
visit_project_packages
expect(status_code).to eq(404)
end
end
context 'packages feature is disabled by config' do context 'packages feature is disabled by config' do
before do before do
allow(Gitlab.config.packages).to receive(:enabled).and_return(false) allow(Gitlab.config.packages).to receive(:enabled).and_return(false)
......
...@@ -16,11 +16,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do ...@@ -16,11 +16,7 @@ RSpec.describe 'Projects > Settings > Packages', :js do
allow(Gitlab.config.packages).to receive(:enabled).and_return(true) allow(Gitlab.config.packages).to receive(:enabled).and_return(true)
end end
context 'allowed by license' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
it 'displays the packages toggle button' do it 'displays the packages toggle button' do
visit edit_project_path(project) visit edit_project_path(project)
...@@ -28,18 +24,6 @@ RSpec.describe 'Projects > Settings > Packages', :js do ...@@ -28,18 +24,6 @@ RSpec.describe 'Projects > Settings > Packages', :js do
expect(page).to have_selector('input[name="project[packages_enabled]"] + button', visible: true) expect(page).to have_selector('input[name="project[packages_enabled]"] + button', visible: true)
end end
end end
context 'not allowed by license' do
before do
stub_licensed_features(packages: false)
end
it 'does not show up in UI' do
visit edit_project_path(project)
expect(page).not_to have_content('Packages')
end
end
end end
context 'Packages disabled in config' do context 'Packages disabled in config' do
......
...@@ -143,21 +143,11 @@ RSpec.describe API::Projects do ...@@ -143,21 +143,11 @@ RSpec.describe API::Projects do
end end
describe 'packages_enabled attribute' do describe 'packages_enabled attribute' do
it 'is exposed when the feature is available' do it 'is exposed' do
stub_licensed_features(packages: true)
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(json_response).to have_key 'packages_enabled' expect(json_response).to have_key 'packages_enabled'
end end
it 'is not exposed when the feature is not available' do
stub_licensed_features(packages: false)
get api("/projects/#{project.id}", user)
expect(json_response).not_to have_key 'packages_enabled'
end
end end
describe 'compliance_frameworks attribute' do describe 'compliance_frameworks attribute' do
...@@ -815,11 +805,7 @@ RSpec.describe API::Projects do ...@@ -815,11 +805,7 @@ RSpec.describe API::Projects do
expect(project.packages_enabled).to be true expect(project.packages_enabled).to be true
end end
context 'packages feature is allowed by license' do context 'without the need for a license' do
before do
stub_licensed_features(packages: true)
end
it 'disables project packages feature' do it 'disables project packages feature' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false }) put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
...@@ -828,20 +814,6 @@ RSpec.describe API::Projects do ...@@ -828,20 +814,6 @@ RSpec.describe API::Projects do
expect(json_response['packages_enabled']).to eq(false) expect(json_response['packages_enabled']).to eq(false)
end end
end end
context 'packages feature is not allowed by license' do
before do
stub_licensed_features(packages: false)
end
it 'disables project packages feature but does not return packages_enabled attribute' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages_enabled).to be false
expect(json_response['packages_enabled']).to be_nil
end
end
end end
describe 'updating approvals_before_merge attribute' do describe 'updating approvals_before_merge attribute' do
......
...@@ -186,7 +186,7 @@ RSpec.describe API::Settings, 'EE Settings' do ...@@ -186,7 +186,7 @@ RSpec.describe API::Settings, 'EE Settings' do
context 'updating npm packages request forwarding' do context 'updating npm packages request forwarding' do
let(:settings) { { npm_package_requests_forwarding: true } } let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages } let(:feature) { :package_forwarding }
it_behaves_like 'settings for licensed features' it_behaves_like 'settings for licensed features'
end end
......
...@@ -10,7 +10,6 @@ RSpec.describe Groups::TransferService, '#execute' do ...@@ -10,7 +10,6 @@ RSpec.describe Groups::TransferService, '#execute' do
let(:transfer_service) { described_class.new(group, user) } let(:transfer_service) { described_class.new(group, user) }
before do before do
stub_licensed_features(packages: true)
group.add_owner(user) group.add_owner(user)
new_group&.add_owner(user) new_group&.add_owner(user)
end end
......
...@@ -10,7 +10,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -10,7 +10,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
assign(:repository, project.repository) assign(:repository, project.repository)
allow(view).to receive(:current_ref).and_return('master') allow(view).to receive(:current_ref).and_return('master')
stub_licensed_features(tracing: true, packages: true) stub_licensed_features(tracing: true)
end end
describe 'issue boards' do describe 'issue boards' do
...@@ -253,31 +253,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -253,31 +253,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end end
end end
context 'when packages are disabled' do
before do
stub_licensed_features(packages: false)
end
it 'packages list link is not visible' do
render
expect(rendered).not_to have_link(package_entry_name, href: project_packages_path(project))
end
it 'top level packages link links to container registry' do
render
expect(rendered).to have_link(package_menu_name, href: project_container_registry_index_path(project))
end
it 'packages top level and container registry links are visible' do
render
expect(rendered).to have_link(package_menu_name, href: project_container_registry_index_path(project))
expect(rendered).to have_link('Container Registry', href: project_container_registry_index_path(project))
end
end
context 'when container registry is disabled' do context 'when container registry is disabled' do
before do before do
stub_container_registry_config(enabled: false) stub_container_registry_config(enabled: false)
...@@ -296,19 +271,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do ...@@ -296,19 +271,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).not_to have_link('Container Registry', href: project_container_registry_index_path(project)) expect(rendered).not_to have_link('Container Registry', href: project_container_registry_index_path(project))
end end
end end
context 'when both packages and container registry are disabled' do
before do
stub_licensed_features(packages: false)
stub_container_registry_config(enabled: false)
end
it 'packages top level item is not visible' do
render
expect(rendered).not_to have_link(package_menu_name, href: project_packages_path(project))
end
end
end end
describe 'Settings > Operations' do describe 'Settings > Operations' do
......
...@@ -45,6 +45,8 @@ RSpec.describe 'Group navbar' do ...@@ -45,6 +45,8 @@ RSpec.describe 'Group navbar' do
end end
before do before do
insert_package_nav(_('Kubernetes'))
stub_feature_flags(group_push_rules: false) stub_feature_flags(group_push_rules: false)
stub_feature_flags(group_iterations: false) stub_feature_flags(group_iterations: false)
stub_feature_flags(group_wiki: false) stub_feature_flags(group_wiki: false)
...@@ -62,13 +64,8 @@ RSpec.describe 'Group navbar' do ...@@ -62,13 +64,8 @@ RSpec.describe 'Group navbar' do
before do before do
stub_config(registry: { enabled: true }) stub_config(registry: { enabled: true })
insert_after_nav_item( insert_container_nav(_('Kubernetes'))
_('Kubernetes'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Container Registry')]
}
)
visit group_path(group) visit group_path(group)
end end
......
...@@ -186,7 +186,11 @@ RSpec.describe 'Edit Project Settings' do ...@@ -186,7 +186,11 @@ RSpec.describe 'Edit Project Settings' do
click_button "Save changes" click_button "Save changes"
end end
expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.is-disabled", count: 3) if ::Gitlab.ee?
expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.is-disabled", count: 4)
else
expect(find(".sharing-permissions")).to have_selector(".project-feature-toggle.is-disabled", count: 3)
end
end end
it "shows empty features project homepage" do it "shows empty features project homepage" do
......
...@@ -12,6 +12,19 @@ RSpec.describe 'Project navbar' do ...@@ -12,6 +12,19 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
# TODO - This can be moved into 'project navbar structure' shared
# context when service desk feature gets moved to core.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/215364
if Gitlab.ee?
insert_after_sub_nav_item(
_('Labels'),
within: _('Issues'),
new_sub_nav_item_name: _('Service Desk')
)
end
insert_package_nav(_('Operations'))
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
...@@ -58,13 +71,8 @@ RSpec.describe 'Project navbar' do ...@@ -58,13 +71,8 @@ RSpec.describe 'Project navbar' do
before do before do
stub_config(registry: { enabled: true }) stub_config(registry: { enabled: true })
insert_after_nav_item( insert_container_nav(_('Operations'))
_('Operations'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Container Registry')]
}
)
visit project_path(project) visit project_path(project)
end end
......
...@@ -18,4 +18,40 @@ module NavbarStructureHelper ...@@ -18,4 +18,40 @@ module NavbarStructureHelper
index = hash[:nav_sub_items].find_index(before_sub_nav_item_name) index = hash[:nav_sub_items].find_index(before_sub_nav_item_name)
hash[:nav_sub_items].insert(index + 1, new_sub_nav_item_name) hash[:nav_sub_items].insert(index + 1, new_sub_nav_item_name)
end end
# TODO - This can be moved into 'project navbar structure' shared
# context when package feature gets moved to core.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/221259
def insert_package_nav(within)
if ::Gitlab.ee?
insert_after_nav_item(
within,
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
end
end
# TODO - This ee? condition can be removed
# when package feature gets moved to core.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/221259
def insert_container_nav(within)
if ::Gitlab.ee?
insert_after_sub_nav_item(
_('Package Registry'),
within: _('Packages & Registries'),
new_sub_nav_item_name: _('Container Registry')
)
else
insert_after_nav_item(
within,
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Container Registry')]
}
)
end
end
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