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
1668f555
Commit
1668f555
authored
Jan 21, 2020
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Groups::ImportExport::ExportService to require admin_group permission
parent
28fc6536
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
app/services/groups/import_export/export_service.rb
app/services/groups/import_export/export_service.rb
+6
-0
changelogs/unreleased/fix_group_export_permission.yml
changelogs/unreleased/fix_group_export_permission.yml
+5
-0
spec/services/groups/import_export/export_service_spec.rb
spec/services/groups/import_export/export_service_spec.rb
+16
-0
No files found.
app/services/groups/import_export/export_service.rb
View file @
1668f555
...
...
@@ -11,6 +11,12 @@ module Groups
end
def
execute
unless
@current_user
.
can?
(
:admin_group
,
@group
)
raise
::
Gitlab
::
ImportExport
::
Error
.
new
(
"User with ID: %s does not have permission to Group %s with ID: %s."
%
[
@current_user
.
id
,
@group
.
name
,
@group
.
id
])
end
save!
end
...
...
changelogs/unreleased/fix_group_export_permission.yml
0 → 100644
View file @
1668f555
---
title
:
Groups::ImportExport::ExportService to require admin_group permission
merge_request
:
23434
author
:
type
:
changed
spec/services/groups/import_export/export_service_spec.rb
View file @
1668f555
...
...
@@ -10,6 +10,10 @@ describe Groups::ImportExport::ExportService do
let
(
:export_path
)
{
shared
.
export_path
}
let
(
:service
)
{
described_class
.
new
(
group:
group
,
user:
user
,
params:
{
shared:
shared
})
}
before
do
group
.
add_owner
(
user
)
end
after
do
FileUtils
.
rm_rf
(
export_path
)
end
...
...
@@ -30,6 +34,18 @@ describe Groups::ImportExport::ExportService do
end
end
context
'when user does not have admin_group permission'
do
let!
(
:another_user
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
group:
group
,
user:
another_user
,
params:
{
shared:
shared
})
}
it
'fails'
do
expected_message
=
"User with ID: %s does not have permission to Group %s with ID: %s."
%
[
another_user
.
id
,
group
.
name
,
group
.
id
]
expect
{
service
.
execute
}.
to
raise_error
(
Gitlab
::
ImportExport
::
Error
).
with_message
(
expected_message
)
end
end
context
'when saving services fail'
do
before
do
allow
(
service
).
to
receive_message_chain
(
:tree_exporter
,
:save
).
and_return
(
false
)
...
...
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