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
c16dbbf0
Commit
c16dbbf0
authored
Jul 28, 2020
by
Shreyas Agarwal
Committed by
Douglas Barbosa Alexandre
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent certain policies at MR level when namespace is read only
parent
3632e508
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
0 deletions
+45
-0
ee/app/policies/ee/merge_request_policy.rb
ee/app/policies/ee/merge_request_policy.rb
+10
-0
ee/changelogs/unreleased/228617-prevent-mr-policies.yml
ee/changelogs/unreleased/228617-prevent-mr-policies.yml
+5
-0
ee/spec/policies/merge_request_policy_spec.rb
ee/spec/policies/merge_request_policy_spec.rb
+30
-0
No files found.
ee/app/policies/ee/merge_request_policy.rb
View file @
c16dbbf0
...
...
@@ -10,10 +10,20 @@ module EE
@subject
.
target_project
&
.
can_override_approvers?
end
condition
(
:over_storage_limit
,
scope: :subject
)
{
@subject
.
target_project
&
.
namespace
&
.
over_storage_limit?
}
rule
{
~
can_override_approvers
}.
prevent
:update_approvers
rule
{
can?
(
:update_merge_request
)
}.
policy
do
enable
:update_approvers
end
rule
{
over_storage_limit
}.
policy
do
prevent
:approve_merge_request
prevent
:update_merge_request
prevent
:reopen_merge_request
prevent
:create_note
prevent
:resolve_note
end
end
end
end
ee/changelogs/unreleased/228617-prevent-mr-policies.yml
0 → 100644
View file @
c16dbbf0
---
title
:
Prevent certain policies at Merge Request level when namespace exceeds storage limit
merge_request
:
36713
author
:
type
:
added
ee/spec/policies/merge_request_policy_spec.rb
View file @
c16dbbf0
...
...
@@ -134,4 +134,34 @@ RSpec.describe MergeRequestPolicy do
end
end
end
context
'when checking for namespace whether exceeding storage limit'
do
context
'when namespace does exceeds storage limit'
do
before
do
allow
(
merge_request
.
target_project
.
namespace
).
to
receive
(
:over_storage_limit?
).
and_return
(
true
)
end
it
'does not allow few policies for all users including maintainer'
do
expect
(
policy_for
(
maintainer
)).
to
be_disallowed
(
:approve_merge_request
,
:update_merge_request
,
:reopen_merge_request
,
:create_note
,
:resolve_note
)
end
end
context
'when namespace does not exceeds storage limit'
do
before
do
allow
(
merge_request
.
target_project
.
namespace
).
to
receive
(
:over_storage_limit?
).
and_return
(
false
)
end
it
'does not lock basic policies for any user'
do
expect
(
policy_for
(
maintainer
)).
to
be_allowed
(
:approve_merge_request
,
:update_merge_request
,
:reopen_merge_request
,
:create_note
,
:resolve_note
)
end
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