Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
371e1ec2
Commit
371e1ec2
authored
Jan 03, 2020
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag for Group Import Export
parent
24f16072
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
22 deletions
+60
-22
lib/api/group_export.rb
lib/api/group_export.rb
+2
-0
spec/requests/api/group_export_spec.rb
spec/requests/api/group_export_spec.rb
+58
-22
No files found.
lib/api/group_export.rb
View file @
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
...
...
spec/requests/api/group_export_spec.rb
View file @
371e1ec2
...
...
@@ -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
(
40
3
)
expect
(
response
).
to
have_gitlab_http_status
(
40
4
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment