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
bb93dfb2
Commit
bb93dfb2
authored
Aug 14, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old code
parent
d8103cba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
40 deletions
+6
-40
lib/gitlab/ldap/access.rb
lib/gitlab/ldap/access.rb
+1
-16
spec/lib/gitlab/ldap/access_spec.rb
spec/lib/gitlab/ldap/access_spec.rb
+5
-24
No files found.
lib/gitlab/ldap/access.rb
View file @
bb93dfb2
...
@@ -85,21 +85,6 @@ module Gitlab
...
@@ -85,21 +85,6 @@ module Gitlab
end
end
end
end
# Add user to GitLab group
# In case user already exists: update his access level
# only if existing permissions are lower than ldap one.
def
add_user_to_groups
(
user_id
,
group_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
group_cn
)
groups
.
each
do
|
group
|
next
unless
group
.
ldap_access
.
present?
group_access
=
group
.
users_groups
.
find_by_user_id
(
user_id
)
next
if
group_access
&&
group_access
.
group_access
>=
group
.
ldap_access
group
.
add_users
([
user_id
],
group
.
ldap_access
)
end
end
# Remove user from GitLab group
# Remove user from GitLab group
def
remove_user_from_groups
(
user_id
,
group_cn
)
def
remove_user_from_groups
(
user_id
,
group_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
group_cn
)
groups
=
::
Group
.
where
(
ldap_cn:
group_cn
)
...
@@ -149,7 +134,7 @@ module Gitlab
...
@@ -149,7 +134,7 @@ module Gitlab
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
(
user
,
fetch_group_access
(
group
,
user
,
active_group_links
))
else
else
group
.
users
.
delete
(
user
)
#ensure this is the nice way to do it
group
.
users
.
delete
(
user
)
end
end
end
end
end
end
...
...
spec/lib/gitlab/ldap/access_spec.rb
View file @
bb93dfb2
...
@@ -9,29 +9,6 @@ describe Gitlab::LDAP::Access do
...
@@ -9,29 +9,6 @@ describe Gitlab::LDAP::Access do
group
group
end
end
describe
:add_user_to_groups
do
it
"should add user to group"
do
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
member
=
group
.
members
.
first
member
.
user
.
should
==
user
member
.
group_access
.
should
==
Gitlab
::
Access
::
DEVELOPER
end
it
"should respect higher permissions"
do
group
.
add_owner
(
user
)
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
group
.
owners
.
should
include
(
user
)
end
it
"should update lower permissions"
do
group
.
add_user
(
user
,
Gitlab
::
Access
::
REPORTER
)
access
.
add_user_to_groups
(
user
.
id
,
"oss"
)
member
=
group
.
members
.
first
member
.
user
.
should
==
user
member
.
group_access
.
should
==
Gitlab
::
Access
::
DEVELOPER
end
end
describe
:update_user_email
do
describe
:update_user_email
do
let
(
:user_ldap
)
{
create
(
:user
,
provider:
'ldap'
,
extern_uid:
"66048"
)}
let
(
:user_ldap
)
{
create
(
:user
,
provider:
'ldap'
,
extern_uid:
"66048"
)}
...
@@ -229,7 +206,7 @@ objectclass: posixGroup
...
@@ -229,7 +206,7 @@ objectclass: posixGroup
end
end
end
end
describe
"cns_with_access"
do
describe
:cns_with_access
do
let
(
:ldap_group_response_1
)
do
let
(
:ldap_group_response_1
)
do
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
Net
::
LDAP
::
Entry
.
from_single_ldif_string
(
%Q{dn: cn=group1,ou=groups,dc=bar,dc=com
%Q{dn: cn=group1,ou=groups,dc=bar,dc=com
...
@@ -269,5 +246,9 @@ objectclass: posixGroup
...
@@ -269,5 +246,9 @@ objectclass: posixGroup
expect
(
access
.
cns_with_access
(
ldap_user
)).
to
eql
[
'group1'
]
expect
(
access
.
cns_with_access
(
ldap_user
)).
to
eql
[
'group1'
]
end
end
end
end
describe
:update_ldap_group_links
do
pending
(
"I really need some test code!"
)
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