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