Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
6f826c0793
commit
f8025904da
|
|
@ -158,7 +158,8 @@ class Import::BulkImportsController < ApplicationController
|
|||
end
|
||||
|
||||
def ensure_bulk_import_enabled
|
||||
render_404 unless Gitlab::CurrentSettings.bulk_import_enabled?
|
||||
render_404 unless Gitlab::CurrentSettings.bulk_import_enabled? ||
|
||||
Feature.enabled?(:override_bulk_import_disabled, current_user, type: :ops)
|
||||
end
|
||||
|
||||
def access_token_key
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
- bulk_imports_enabled = Gitlab::CurrentSettings.bulk_import_enabled?
|
||||
- bulk_imports_enabled = Gitlab::CurrentSettings.bulk_import_enabled? || Feature.enabled?(:override_bulk_import_disabled, current_user, type: :ops)
|
||||
|
||||
.gl-flex.gl-flex-col.gl-gap-5
|
||||
- if !bulk_imports_enabled
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
name: override_bulk_import_disabled
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/132431
|
||||
rollout_issue_url:
|
||||
milestone: '16.5'
|
||||
type: ops
|
||||
group: group::import and integrate
|
||||
default_enabled: false
|
||||
|
|
@ -33,7 +33,8 @@ module API
|
|||
end
|
||||
|
||||
before do
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled?
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled? ||
|
||||
Feature.enabled?(:override_bulk_import_disabled, current_user, type: :ops)
|
||||
|
||||
authenticate!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ module API
|
|||
|
||||
resource do
|
||||
before do
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled?
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled? ||
|
||||
Feature.enabled?(:override_bulk_import_disabled, current_user, type: :ops)
|
||||
end
|
||||
|
||||
desc 'Start relations export' do
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ module API
|
|||
|
||||
resource do
|
||||
before do
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled?
|
||||
not_found! unless Gitlab::CurrentSettings.bulk_import_enabled? ||
|
||||
Feature.enabled?(:override_bulk_import_disabled, current_user, type: :ops)
|
||||
|
||||
authorize_admin_project
|
||||
end
|
||||
|
|
|
|||
|
|
@ -514,6 +514,7 @@ RSpec.describe Import::BulkImportsController, feature_category: :importers do
|
|||
context 'when importing groups and projects by direct transfer is disabled' do
|
||||
before do
|
||||
stub_application_setting(bulk_import_enabled: false)
|
||||
stub_feature_flags(override_bulk_import_disabled: false)
|
||||
|
||||
allow_next_instance_of(BulkImports::Clients::HTTP) do |instance|
|
||||
allow(instance).to receive(:validate_instance_version!).and_return(true)
|
||||
|
|
@ -538,6 +539,31 @@ RSpec.describe Import::BulkImportsController, feature_category: :importers do
|
|||
expect(response).to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the override_bulk_import_disabled feature flag is enabled' do
|
||||
before do
|
||||
stub_feature_flags(override_bulk_import_disabled: true)
|
||||
end
|
||||
|
||||
context 'POST configure' do
|
||||
it 'does not return 404' do
|
||||
post :configure, params: {
|
||||
bulk_import_gitlab_access_token: 'token', bulk_import_gitlab_url: 'https://gitlab.example'
|
||||
}
|
||||
|
||||
expect(response).to have_gitlab_http_status(:found)
|
||||
expect(response).to redirect_to(status_import_bulk_imports_url)
|
||||
end
|
||||
end
|
||||
|
||||
context 'GET status' do
|
||||
it 'does not return 404' do
|
||||
get :status
|
||||
|
||||
expect(response).to have_gitlab_http_status(:ok)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -80,14 +80,34 @@ RSpec.describe 'Import/Export - Connect to another instance', :js, feature_categ
|
|||
context 'when importing groups and projects by direct transfer is disabled' do
|
||||
before do
|
||||
stub_application_setting(bulk_import_enabled: false)
|
||||
|
||||
open_import_group
|
||||
end
|
||||
|
||||
it "doesn't render fields and button" do
|
||||
expect(page).not_to have_field('GitLab source instance base URL')
|
||||
expect(page).not_to have_field('Personal access token')
|
||||
expect(page).not_to have_button('Connect instance')
|
||||
context 'when the override_bulk_import_disabled feature flag is disabled' do
|
||||
before do
|
||||
stub_feature_flags(override_bulk_import_disabled: false)
|
||||
|
||||
open_import_group
|
||||
end
|
||||
|
||||
it 'renders fields and button disabled' do
|
||||
expect(page).to have_field('GitLab source instance base URL', disabled: true)
|
||||
expect(page).to have_field('Personal access token', disabled: true)
|
||||
expect(page).to have_button('Connect instance', disabled: true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the override_bulk_import_disabled feature flag is enabled' do
|
||||
before do
|
||||
stub_feature_flags(override_bulk_import_disabled: true)
|
||||
|
||||
open_import_group
|
||||
end
|
||||
|
||||
it 'renders fields and button enabled' do
|
||||
expect(page).to have_field('GitLab source instance base URL', disabled: false)
|
||||
expect(page).to have_field('Personal access token', disabled: false)
|
||||
expect(page).to have_button('Connect instance', disabled: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,29 @@ RSpec.describe API::BulkImports, feature_category: :importers do
|
|||
shared_examples 'disabled feature' do
|
||||
before do
|
||||
stub_application_setting(bulk_import_enabled: false)
|
||||
stub_feature_flags(override_bulk_import_disabled: false)
|
||||
end
|
||||
|
||||
it_behaves_like '404 response' do
|
||||
let(:message) { '404 Not Found' }
|
||||
end
|
||||
|
||||
it 'enables the feature when override flag is enabled for the user' do
|
||||
stub_feature_flags(override_bulk_import_disabled: user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).not_to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'does not enable the feature when override flag is enabled for another user' do
|
||||
other_user = create(:user)
|
||||
stub_feature_flags(override_bulk_import_disabled: other_user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /bulk_imports' do
|
||||
|
|
|
|||
|
|
@ -423,11 +423,29 @@ RSpec.describe API::GroupExport, feature_category: :importers do
|
|||
|
||||
before do
|
||||
stub_application_setting(bulk_import_enabled: false)
|
||||
stub_feature_flags(override_bulk_import_disabled: false)
|
||||
end
|
||||
|
||||
it_behaves_like '404 response' do
|
||||
let(:message) { '404 Not Found' }
|
||||
end
|
||||
|
||||
it 'enables the feature when override flag is enabled for the user' do
|
||||
stub_feature_flags(override_bulk_import_disabled: user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).to have_gitlab_http_status(:accepted)
|
||||
end
|
||||
|
||||
it 'does not enable the feature when override flag is enabled for another user' do
|
||||
other_user = create(:user)
|
||||
stub_feature_flags(override_bulk_import_disabled: other_user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -735,37 +735,63 @@ RSpec.describe API::ProjectExport, :aggregate_failures, :clean_gitlab_redis_cach
|
|||
context 'with bulk_import is disabled' do
|
||||
before do
|
||||
stub_application_setting(bulk_import_enabled: false)
|
||||
stub_feature_flags(override_bulk_import_disabled: false)
|
||||
end
|
||||
|
||||
shared_examples 'flag override' do |expected_http_status:|
|
||||
it 'enables the feature when override flag is enabled for the user' do
|
||||
stub_feature_flags(override_bulk_import_disabled: user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).to have_gitlab_http_status(expected_http_status)
|
||||
end
|
||||
|
||||
it 'does not enable the feature when override flag is enabled for another user' do
|
||||
other_user = create(:user)
|
||||
stub_feature_flags(override_bulk_import_disabled: other_user)
|
||||
|
||||
request
|
||||
|
||||
expect(response).to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /projects/:id/export_relations' do
|
||||
subject(:request) { post api(path, user) }
|
||||
|
||||
it_behaves_like '404 response' do
|
||||
let(:message) { '404 Not Found' }
|
||||
|
||||
subject(:request) { post api(path, user) }
|
||||
end
|
||||
|
||||
it_behaves_like 'flag override', expected_http_status: :accepted
|
||||
end
|
||||
|
||||
describe 'GET /projects/:id/export_relations/download' do
|
||||
let_it_be(:export) { create(:bulk_import_export, project: project, relation: 'labels', user: user) }
|
||||
let_it_be(:upload) { create(:bulk_import_export_upload, export: export) }
|
||||
|
||||
subject(:request) { get api(download_path, user) }
|
||||
|
||||
before do
|
||||
upload.update!(export_file: fixture_file_upload('spec/fixtures/bulk_imports/gz/labels.ndjson.gz'))
|
||||
end
|
||||
|
||||
it_behaves_like '404 response' do
|
||||
let(:message) { '404 Not Found' }
|
||||
|
||||
subject(:request) { get api(download_path, user) }
|
||||
end
|
||||
|
||||
it_behaves_like 'flag override', expected_http_status: :ok
|
||||
end
|
||||
|
||||
describe 'GET /projects/:id/export_relations/status' do
|
||||
subject(:request) { get api(status_path, user) }
|
||||
|
||||
it_behaves_like '404 response' do
|
||||
let(:message) { '404 Not Found' }
|
||||
|
||||
subject(:request) { get api(status_path, user) }
|
||||
end
|
||||
|
||||
it_behaves_like 'flag override', expected_http_status: :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue