Commit 9ae07dbd authored by David Fernandez's avatar David Fernandez

Remove forward npm package request feature flag

Remove `forward_npm_package_registry_requests` feature flag
parent f67998b2
- if Feature.enabled?(:forward_npm_package_registry_requests, default_enabled: true) && Gitlab.config.packages.enabled - if Gitlab.config.packages.enabled
%section.settings.as-package.no-animate#js-package-settings{ class: ('expanded' if expanded_by_default?) } %section.settings.as-package.no-animate#js-package-settings{ class: ('expanded' if expanded_by_default?) }
.settings-header .settings-header
%h4 %h4
......
...@@ -9,7 +9,7 @@ module API ...@@ -9,7 +9,7 @@ module API
}.freeze }.freeze
def redirect_registry_request(forward_to_registry, package_type, options) def redirect_registry_request(forward_to_registry, package_type, options)
if redirect_registry_request_available? && forward_to_registry if forward_to_registry && redirect_registry_request_available?
redirect(registry_url(package_type, options)) redirect(registry_url(package_type, options))
else else
yield yield
...@@ -28,8 +28,7 @@ module API ...@@ -28,8 +28,7 @@ module API
end end
def redirect_registry_request_available? def redirect_registry_request_available?
Feature.enabled?(:forward_npm_package_registry_requests, default_enabled: true) && ::Gitlab::CurrentSettings.current_application_settings.npm_package_requests_forwarding
::Gitlab::CurrentSettings.current_application_settings.npm_package_requests_forwarding
end end
end end
end end
......
...@@ -35,20 +35,15 @@ describe API::Helpers::Packages::DependencyProxyHelpers do ...@@ -35,20 +35,15 @@ describe API::Helpers::Packages::DependencyProxyHelpers do
context 'with npm packages' do context 'with npm packages' do
let(:package_type) { :npm } let(:package_type) { :npm }
where(:feature_flag, :application_setting, :forward_to_registry, :example_name) do where(:application_setting, :forward_to_registry, :example_name) do
true | true | true | 'executing redirect' true | true | 'executing redirect'
true | true | false | 'executing fallback' true | false | 'executing fallback'
true | false | true | 'executing fallback' false | true | 'executing fallback'
true | false | false | 'executing fallback' false | false | 'executing fallback'
false | true | true | 'executing fallback'
false | true | false | 'executing fallback'
false | false | true | 'executing fallback'
false | false | false | 'executing fallback'
end end
with_them do with_them do
before do before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: feature_flag })
stub_application_setting(npm_package_requests_forwarding: application_setting) stub_application_setting(npm_package_requests_forwarding: application_setting)
end end
...@@ -60,7 +55,6 @@ describe API::Helpers::Packages::DependencyProxyHelpers do ...@@ -60,7 +55,6 @@ describe API::Helpers::Packages::DependencyProxyHelpers do
let(:forward_to_registry) { true } let(:forward_to_registry) { true }
before do before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: true })
stub_application_setting(npm_package_requests_forwarding: true) stub_application_setting(npm_package_requests_forwarding: true)
end end
......
...@@ -63,42 +63,26 @@ describe API::NpmPackages do ...@@ -63,42 +63,26 @@ describe API::NpmPackages do
context 'a public project' do context 'a public project' do
it_behaves_like 'returning the npm package info' it_behaves_like 'returning the npm package info'
context 'with forward_npm_package_registry_requests enabled' do context 'with application setting enabled' do
before do before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: true }) stub_application_setting(npm_package_requests_forwarding: true)
end end
context 'with application setting enabled' do it_behaves_like 'returning the npm package info'
before do
stub_application_setting(npm_package_requests_forwarding: true)
end
it_behaves_like 'returning the npm package info'
context 'with unknown package' do context 'with unknown package' do
it 'returns a redirect' do it 'returns a redirect' do
get api("/packages/npm/unknown") get api("/packages/npm/unknown")
expect(response).to have_gitlab_http_status(:found) expect(response).to have_gitlab_http_status(:found)
expect(response.headers['Location']).to eq('https://registry.npmjs.org/unknown') expect(response.headers['Location']).to eq('https://registry.npmjs.org/unknown')
end
end end
end end
context 'with application setting disabled' do
before do
stub_application_setting(npm_package_requests_forwarding: false)
end
it_behaves_like 'returning the npm package info'
it_behaves_like 'returning forbidden for unknown package'
end
end end
context 'with forward_npm_package_registry_requests disabled' do context 'with application setting disabled' do
before do before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: false }) stub_application_setting(npm_package_requests_forwarding: false)
end end
it_behaves_like 'returning the npm package info' it_behaves_like 'returning the npm package info'
......
...@@ -14,7 +14,7 @@ RSpec.shared_examples 'returns package tags' do |user_type| ...@@ -14,7 +14,7 @@ RSpec.shared_examples 'returns package tags' do |user_type|
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
before do before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: false }) stub_application_setting(npm_package_requests_forwarding: false)
project.send("add_#{user_type}", user) unless user_type == :no_type project.send("add_#{user_type}", user) unless user_type == :no_type
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