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?) }
.settings-header
%h4
......
......@@ -9,7 +9,7 @@ module API
}.freeze
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))
else
yield
......@@ -28,8 +28,7 @@ module API
end
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
......
......@@ -35,20 +35,15 @@ describe API::Helpers::Packages::DependencyProxyHelpers do
context 'with npm packages' do
let(:package_type) { :npm }
where(:feature_flag, :application_setting, :forward_to_registry, :example_name) do
true | true | true | 'executing redirect'
true | true | false | 'executing fallback'
true | false | true | 'executing fallback'
true | false | false | 'executing fallback'
false | true | true | 'executing fallback'
false | true | false | 'executing fallback'
false | false | true | 'executing fallback'
false | false | false | 'executing fallback'
where(:application_setting, :forward_to_registry, :example_name) do
true | true | 'executing redirect'
true | false | 'executing fallback'
false | true | 'executing fallback'
false | false | 'executing fallback'
end
with_them do
before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: feature_flag })
stub_application_setting(npm_package_requests_forwarding: application_setting)
end
......@@ -60,7 +55,6 @@ describe API::Helpers::Packages::DependencyProxyHelpers do
let(:forward_to_registry) { true }
before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: true })
stub_application_setting(npm_package_requests_forwarding: true)
end
......
......@@ -63,42 +63,26 @@ describe API::NpmPackages do
context 'a public project' do
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
stub_feature_flags(forward_npm_package_registry_requests: { enabled: true })
stub_application_setting(npm_package_requests_forwarding: true)
end
context 'with application setting enabled' do
before do
stub_application_setting(npm_package_requests_forwarding: true)
end
it_behaves_like 'returning the npm package info'
it_behaves_like 'returning the npm package info'
context 'with unknown package' do
it 'returns a redirect' do
get api("/packages/npm/unknown")
context 'with unknown package' do
it 'returns a redirect' do
get api("/packages/npm/unknown")
expect(response).to have_gitlab_http_status(:found)
expect(response.headers['Location']).to eq('https://registry.npmjs.org/unknown')
end
expect(response).to have_gitlab_http_status(:found)
expect(response.headers['Location']).to eq('https://registry.npmjs.org/unknown')
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
context 'with forward_npm_package_registry_requests disabled' do
context 'with application setting disabled' do
before do
stub_feature_flags(forward_npm_package_registry_requests: { enabled: false })
stub_application_setting(npm_package_requests_forwarding: false)
end
it_behaves_like 'returning the npm package info'
......
......@@ -14,7 +14,7 @@ RSpec.shared_examples 'returns package tags' do |user_type|
using RSpec::Parameterized::TableSyntax
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
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