Commit 8d4649d1 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'georgekoltsov/group-import-feature-flag' into 'master'

Add feature flag for Group Export API endpoint

Closes #36395

See merge request gitlab-org/gitlab!22423
parents e2a33054 371e1ec2
......@@ -3,6 +3,8 @@
module API
class GroupExport < Grape::API
before do
not_found! unless Feature.enabled?(:group_import_export, user_group, default_enabled: true)
authorize! :admin_group, user_group
end
......
......@@ -30,25 +30,39 @@ describe API::GroupExport do
group.add_owner(user)
end
context 'when export file exists' do
context 'group_import_export feature flag enabled' do
before do
upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz")
upload.save!
stub_feature_flags(group_import_export: true)
end
it 'downloads exported group archive' do
get api(download_path, user)
context 'when export file exists' do
before do
upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz")
upload.save!
end
expect(response).to have_gitlab_http_status(200)
end
it 'downloads exported group archive' do
get api(download_path, user)
context 'when export_file.file does not exist' do
before do
expect_next_instance_of(ImportExportUploader) do |uploader|
expect(uploader).to receive(:file).and_return(nil)
expect(response).to have_gitlab_http_status(200)
end
context 'when export_file.file does not exist' do
before do
expect_next_instance_of(ImportExportUploader) do |uploader|
expect(uploader).to receive(:file).and_return(nil)
end
end
it 'returns 404' do
get api(download_path, user)
expect(response).to have_gitlab_http_status(404)
end
end
end
context 'when export file does not exist' do
it 'returns 404' do
get api(download_path, user)
......@@ -57,8 +71,12 @@ describe API::GroupExport do
end
end
context 'when export file does not exist' do
it 'returns 404' do
context 'group_import_export feature flag disabled' do
before do
stub_feature_flags(group_import_export: false)
end
it 'responds with 404 Not Found' do
get api(download_path, user)
expect(response).to have_gitlab_http_status(404)
......@@ -67,27 +85,45 @@ describe API::GroupExport do
end
describe 'POST /groups/:group_id/export' do
context 'when user is a group owner' do
context 'group_import_export feature flag enabled' do
before do
group.add_owner(user)
stub_feature_flags(group_import_export: true)
end
it 'accepts download' do
post api(path, user)
context 'when user is a group owner' do
before do
group.add_owner(user)
end
it 'accepts download' do
post api(path, user)
expect(response).to have_gitlab_http_status(202)
end
end
context 'when user is not a group owner' do
before do
group.add_developer(user)
end
expect(response).to have_gitlab_http_status(202)
it 'forbids the request' do
post api(path, user)
expect(response).to have_gitlab_http_status(403)
end
end
end
context 'when user is not a group owner' do
context 'group_import_export feature flag disabled' do
before do
group.add_developer(user)
stub_feature_flags(group_import_export: false)
end
it 'forbids the request' do
it 'responds with 404 Not Found' do
post api(path, user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(404)
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