BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c7e17abd
Commit
c7e17abd
authored
Sep 05, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix “Share lock” policy for deeply nested groups
parent
e0fb7766
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
group_policy.rb
app/policies/group_policy.rb
+2
-2
group_policy_spec.rb
spec/policies/group_policy_spec.rb
+27
-1
No files found.
app/policies/group_policy.rb
View file @
c7e17abd
...
@@ -16,7 +16,7 @@ class GroupPolicy < BasePolicy
...
@@ -16,7 +16,7 @@ class GroupPolicy < BasePolicy
condition
(
:nested_groups_supported
,
scope: :global
)
{
Group
.
supports_nested_groups?
}
condition
(
:nested_groups_supported
,
scope: :global
)
{
Group
.
supports_nested_groups?
}
condition
(
:parent_share_locked
)
{
@subject
.
has_parent?
&&
@subject
.
parent
.
share_with_group_lock?
}
condition
(
:parent_share_locked
)
{
@subject
.
has_parent?
&&
@subject
.
parent
.
share_with_group_lock?
}
condition
(
:
parent_owner
)
{
@subject
.
has_parent?
&&
@subject
.
parent
.
has_owner?
(
@user
)
}
condition
(
:
can_change_parent_share_with_group_lock
)
{
@subject
.
has_parent?
&&
can?
(
:change_share_with_group_lock
,
@subject
.
parent
)
}
condition
(
:has_projects
)
do
condition
(
:has_projects
)
do
GroupProjectsFinder
.
new
(
group:
@subject
,
current_user:
@user
).
execute
.
any?
GroupProjectsFinder
.
new
(
group:
@subject
,
current_user:
@user
).
execute
.
any?
...
@@ -57,7 +57,7 @@ class GroupPolicy < BasePolicy
...
@@ -57,7 +57,7 @@ class GroupPolicy < BasePolicy
rule
{
~
can?
(
:view_globally
)
}.
prevent
:request_access
rule
{
~
can?
(
:view_globally
)
}.
prevent
:request_access
rule
{
has_access
}.
prevent
:request_access
rule
{
has_access
}.
prevent
:request_access
rule
{
owner
&
(
~
parent_share_locked
|
parent_owner
)
}.
enable
:change_share_with_group_lock
rule
{
owner
&
(
~
parent_share_locked
|
can_change_parent_share_with_group_lock
)
}.
enable
:change_share_with_group_lock
def
access_level
def
access_level
return
GroupMember
::
NO_ACCESS
if
@user
.
nil?
return
GroupMember
::
NO_ACCESS
if
@user
.
nil?
...
...
spec/policies/group_policy_spec.rb
View file @
c7e17abd
...
@@ -248,9 +248,34 @@ describe GroupPolicy do
...
@@ -248,9 +248,34 @@ describe GroupPolicy do
let
(
:group
)
{
create
(
:group
,
parent:
parent
)
}
let
(
:group
)
{
create
(
:group
,
parent:
parent
)
}
context
'when the parent share_with_group_lock is enabled'
do
context
'when the parent share_with_group_lock is enabled'
do
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
let
(
:current_user
)
{
owner
}
let
(
:current_user
)
{
owner
}
context
'when the group has a grandparent'
do
let
(
:grandparent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
,
parent:
grandparent
)
}
context
'and the grandparent share_with_group_lock is enabled'
do
context
'when current_user owns the grandparent'
do
before
do
grandparent
.
add_owner
(
owner
)
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
context
'when current_user owns the parent but not the grandparent'
do
before
do
parent
.
add_owner
(
owner
)
end
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
end
context
'when the group does not have a grandparent'
do
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
context
'when current_user owns the parent'
do
context
'when current_user owns the parent'
do
before
do
before
do
parent
.
add_owner
(
owner
)
parent
.
add_owner
(
owner
)
...
@@ -263,6 +288,7 @@ describe GroupPolicy do
...
@@ -263,6 +288,7 @@ describe GroupPolicy do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
end
end
end
context
'when the parent share_with_group_lock is disabled'
do
context
'when the parent share_with_group_lock is disabled'
do
let
(
:parent
)
{
create
(
:group
)
}
let
(
:parent
)
{
create
(
:group
)
}
...
...
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