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
1832e516
Commit
1832e516
authored
Mar 05, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow project admin to read approval rules
even if project is archived / merge requests not allowed.
parent
876f3c35
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
4 deletions
+61
-4
ee/changelogs/unreleased/27934-approval-settings-api-fix.yml
ee/changelogs/unreleased/27934-approval-settings-api-fix.yml
+5
-0
ee/lib/api/helpers/project_approval_rules_helpers.rb
ee/lib/api/helpers/project_approval_rules_helpers.rb
+3
-1
ee/lib/api/project_approval_rules.rb
ee/lib/api/project_approval_rules.rb
+2
-2
ee/lib/api/project_approval_settings.rb
ee/lib/api/project_approval_settings.rb
+1
-1
ee/spec/requests/api/project_approval_rules_spec.rb
ee/spec/requests/api/project_approval_rules_spec.rb
+25
-0
ee/spec/requests/api/project_approval_settings_spec.rb
ee/spec/requests/api/project_approval_settings_spec.rb
+25
-0
No files found.
ee/changelogs/unreleased/27934-approval-settings-api-fix.yml
0 → 100644
View file @
1832e516
---
title
:
Allow project admin to read approval rules from archived projects
merge_request
:
55929
author
:
type
:
fixed
ee/lib/api/helpers/project_approval_rules_helpers.rb
View file @
1832e516
...
...
@@ -28,7 +28,9 @@ module API
requires
:approval_rule_id
,
type:
Integer
,
desc:
'The ID of an approval_rule'
end
def
authorize_create_merge_request_in_project
def
authorize_read_project_approval_rule!
return
if
can?
(
current_user
,
:admin_project
,
user_project
)
authorize!
:create_merge_request_in
,
user_project
end
...
...
ee/lib/api/project_approval_rules.rb
View file @
1832e516
...
...
@@ -17,7 +17,7 @@ module API
success
EE
::
API
::
Entities
::
ProjectApprovalRule
end
get
do
authorize_
create_merge_request_in_project
authorize_
read_project_approval_rule!
present
user_project
.
visible_approval_rules
,
with:
EE
::
API
::
Entities
::
ProjectApprovalRule
,
current_user:
current_user
end
...
...
@@ -37,7 +37,7 @@ module API
success
EE
::
API
::
Entities
::
ProjectApprovalRule
end
get
do
authorize_
create_merge_request_in_project
authorize_
read_project_approval_rule!
approval_rule
=
user_project
.
approval_rules
.
find
(
params
[
:approval_rule_id
])
...
...
ee/lib/api/project_approval_settings.rb
View file @
1832e516
...
...
@@ -21,7 +21,7 @@ module API
optional
:target_branch
,
type:
String
,
desc:
'Branch that scoped approval rules apply to'
end
get
do
authorize_
create_merge_request_in_project
authorize_
read_project_approval_rule!
present
(
user_project
,
...
...
ee/spec/requests/api/project_approval_rules_spec.rb
View file @
1832e516
...
...
@@ -115,6 +115,31 @@ RSpec.describe API::ProjectApprovalRules do
end
end
end
context
'when project is archived'
do
let_it_be
(
:archived_project
)
{
create
(
:project
,
:archived
,
creator:
user
)
}
let
(
:url
)
{
"/projects/
#{
archived_project
.
id
}
/approval_rules"
}
context
'when user has normal permissions'
do
it
'returns 403'
do
archived_project
.
add_guest
(
user2
)
get
api
(
url
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when user has project admin permissions'
do
it
'allows access'
do
archived_project
.
add_maintainer
(
user2
)
get
api
(
url
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
describe
'POST /projects/:id/approval_rules'
do
...
...
ee/spec/requests/api/project_approval_settings_spec.rb
View file @
1832e516
...
...
@@ -116,6 +116,31 @@ RSpec.describe API::ProjectApprovalSettings do
end
end
end
context
'when project is archived'
do
let_it_be
(
:archived_project
)
{
create
(
:project
,
:archived
,
creator:
user
)
}
let
(
:url
)
{
"/projects/
#{
archived_project
.
id
}
/approval_settings"
}
context
'when user has normal permissions'
do
it
'returns 403'
do
archived_project
.
add_guest
(
user2
)
get
api
(
url
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when user has project admin permissions'
do
it
'allows access'
do
archived_project
.
add_maintainer
(
user2
)
get
api
(
url
,
user2
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
describe
'POST /projects/:id/approval_settings/rules'
do
...
...
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