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
0e6d55cc
Commit
0e6d55cc
authored
May 10, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put access_levels in a local variable
parent
66df7e20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
lib/gitlab/ldap/group_sync.rb
lib/gitlab/ldap/group_sync.rb
+5
-8
spec/lib/gitlab/ldap/group_sync_spec.rb
spec/lib/gitlab/ldap/group_sync_spec.rb
+3
-1
No files found.
lib/gitlab/ldap/group_sync.rb
View file @
0e6d55cc
...
...
@@ -67,6 +67,7 @@ module Gitlab
logger
.
debug
{
"Syncing '
#{
group
.
name
}
' group"
}
access_levels
=
Gitlab
::
LDAP
::
AccessLevels
.
new
# Only iterate over group links for the current provider
group
.
ldap_group_links
.
with_provider
(
provider
).
each
do
|
group_link
|
if
member_dns
=
dns_for_group_cn
(
group_link
.
cn
)
...
...
@@ -77,8 +78,8 @@ module Gitlab
end
end
update_existing_group_membership
(
group
)
add_new_members
(
group
)
update_existing_group_membership
(
group
,
access_levels
)
add_new_members
(
group
,
access_levels
)
group
.
update
(
last_ldap_sync_at:
Time
.
now
)
...
...
@@ -142,10 +143,6 @@ module Gitlab
@config
||=
Gitlab
::
LDAP
::
Config
.
new
(
provider
)
end
def
access_levels
@access_levels
||=
Gitlab
::
LDAP
::
AccessLevels
.
new
end
def
group_base
config
.
group_base
end
...
...
@@ -227,7 +224,7 @@ module Gitlab
identity
.
save
end
def
update_existing_group_membership
(
group
)
def
update_existing_group_membership
(
group
,
access_levels
)
logger
.
debug
{
"Updating existing membership for '
#{
group
.
name
}
' group"
}
select_and_preload_group_members
(
group
).
each
do
|
member
|
...
...
@@ -270,7 +267,7 @@ module Gitlab
end
end
def
add_new_members
(
group
)
def
add_new_members
(
group
,
access_levels
)
logger
.
debug
{
"Adding new members to '
#{
group
.
name
}
' group"
}
access_levels
.
each
do
|
member_dn
,
access_level
|
...
...
spec/lib/gitlab/ldap/group_sync_spec.rb
View file @
0e6d55cc
...
...
@@ -291,14 +291,16 @@ describe Gitlab::LDAP::GroupSync, lib: true do
group2
.
ldap_group_links
.
destroy_all
group2
.
ldap_group_links
.
create
(
cn:
'ldap_group2'
,
group_access:
Gitlab
::
Access
::
OWN
ER
,
group_access:
Gitlab
::
Access
::
MAST
ER
,
provider:
'ldapmain'
)
group_sync
.
sync_groups
expect
(
group1
.
members
.
pluck
(
:user_id
).
sort
).
to
eq
([
user1
.
id
,
user2
.
id
].
sort
)
expect
(
group1
.
members
.
pluck
(
:access_level
).
uniq
).
to
eq
([
Gitlab
::
Access
::
DEVELOPER
])
expect
(
group2
.
members
.
pluck
(
:user_id
)).
to
eq
([
user2
.
id
])
expect
(
group2
.
members
.
pluck
(
:access_level
).
uniq
).
to
eq
([
Gitlab
::
Access
::
MASTER
])
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