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
5ff230a1
Commit
5ff230a1
authored
Aug 15, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more use cases for update_ldap_group_links to unit tests
parent
25415710
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+1
-1
spec/lib/gitlab/ldap/access_spec.rb
spec/lib/gitlab/ldap/access_spec.rb
+38
-2
No files found.
lib/gitlab/ldap/access.rb
View file @
5ff230a1
...
@@ -132,7 +132,7 @@ module Gitlab
...
@@ -132,7 +132,7 @@ module Gitlab
active_group_links
=
group
.
ldap_group_links
.
where
(
cn:
cns_with_access
(
get_ldap_user
(
user
)))
active_group_links
=
group
.
ldap_group_links
.
where
(
cn:
cns_with_access
(
get_ldap_user
(
user
)))
if
active_group_links
.
any?
if
active_group_links
.
any?
group
.
add_user
(
user
,
fetch_group_access
(
group
,
user
,
active_group_links
))
group
.
add_user
s
([
user
.
id
]
,
fetch_group_access
(
group
,
user
,
active_group_links
))
else
else
group
.
users
.
delete
(
user
)
group
.
users
.
delete
(
user
)
end
end
...
...
spec/lib/gitlab/ldap/access_spec.rb
View file @
5ff230a1
...
@@ -253,17 +253,53 @@ objectclass: posixGroup
...
@@ -253,17 +253,53 @@ objectclass: posixGroup
access
.
stub
(
cns_with_access:
cns_with_access
)
access
.
stub
(
cns_with_access:
cns_with_access
)
end
end
context
"non existing access for group-1, allowed via ldap-group1 as
DEVELOP
ER"
do
context
"non existing access for group-1, allowed via ldap-group1 as
MAST
ER"
do
before
do
before
do
gitlab_group_1
.
ldap_group_links
.
create
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
gitlab_group_1
.
ldap_group_links
.
create
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
end
end
it
"gives the user master access for group 1"
do
it
"gives the user master access for group 1"
do
access
.
update_ldap_group_links
(
user
)
access
.
update_ldap_group_links
(
user
)
expect
(
gitlab_group_1
.
has_master?
(
user
)
).
to
be_true
expect
(
gitlab_group_1
.
has_master?
(
user
)
).
to
be_true
end
end
end
end
context
"existing access as guest for group-1, allowed via ldap-group1 as DEVELOPER"
do
before
do
gitlab_group_1
.
users_groups
.
guests
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
ldap_group_links
.
create
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
end
it
"upgrades the users access to master for group 1"
do
expect
{
access
.
update_ldap_group_links
(
user
)
}.
to
\
change
{
gitlab_group_1
.
has_master?
(
user
)
}.
from
(
false
).
to
(
true
)
end
end
context
"existing access as MASTER for group-1, allowed via ldap-group1 as DEVELOPER"
do
before
do
gitlab_group_1
.
users_groups
.
masters
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
ldap_group_links
.
create
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
DEVELOPER
end
it
"keeps the users master access for group 1"
do
expect
{
access
.
update_ldap_group_links
(
user
)
}.
not_to
\
change
{
gitlab_group_1
.
has_master?
(
user
)
}
end
end
context
"existing access as master for group-1, not allowed"
do
before
do
gitlab_group_1
.
users_groups
.
masters
.
create
(
user_id:
user
.
id
)
gitlab_group_1
.
ldap_group_links
.
create
cn:
'ldap-group1'
,
group_access:
Gitlab
::
Access
::
MASTER
access
.
stub
(
cns_with_access:
[
'ldap-group2'
])
end
it
"removes user from gitlab_group_1"
do
expect
{
access
.
update_ldap_group_links
(
user
)
}.
to
\
change
{
gitlab_group_1
.
members
.
where
(
user_id:
user
).
any?
}.
from
(
true
).
to
(
false
)
end
end
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