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
2424df1f
Commit
2424df1f
authored
Sep 26, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more specs, fixed some errors
parent
25059dd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
app/models/group.rb
app/models/group.rb
+9
-1
app/models/ldap_group_link.rb
app/models/ldap_group_link.rb
+1
-1
spec/factories/groups.rb
spec/factories/groups.rb
+22
-8
No files found.
app/models/group.rb
View file @
2424df1f
...
...
@@ -230,12 +230,20 @@ class Group < Namespace
ldap_group_links
.
first
.
try
(
:cn
)
end
def
ldap_filter
ldap_group_links
.
first
.
try
(
:filter
)
end
def
ldap_access
ldap_group_links
.
first
.
try
(
:group_access
)
end
def
ldap_cn_or_filter_present?
ldap_cn
.
present?
||
ldap_filter
.
present?
end
def
ldap_synced?
Gitlab
.
config
.
ldap
.
enabled
&&
ldap_cn
.
present?
Gitlab
.
config
.
ldap
.
enabled
&&
ldap_cn
_or_filter_
present?
end
def
post_create_hook
...
...
app/models/ldap_group_link.rb
View file @
2424df1f
...
...
@@ -8,7 +8,7 @@ class LdapGroupLink < ActiveRecord::Base
validates
:cn
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
},
unless: :filter
validates
:filter
,
:group_access
,
:group_id
,
presence:
true
,
unless: :cn
validates
:filter
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
},
unless: :cn
validates
:filter
,
ldap_filter:
true
,
if: :filter
validates
:filter
,
ldap_filter:
true
,
unless: :cn
validates
:group_access
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
validates
:provider
,
presence:
true
...
...
spec/factories/groups.rb
View file @
2424df1f
...
...
@@ -27,20 +27,34 @@ FactoryGirl.define do
end
end
factory
:group_with_ldap
_group_link
do
factory
:group_with_ldap
do
transient
do
cn
'group1'
group_access
Gitlab
::
Access
::
GUEST
provider
'ldapmain'
end
after
(
:create
)
do
|
group
,
evaluator
|
group
.
ldap_group_links
<<
create
(
:ldap_group_link
,
cn:
evaluator
.
cn
,
group_access:
evaluator
.
group_access
,
provider:
evaluator
.
provider
)
factory
:group_with_ldap_group_link
do
after
(
:create
)
do
|
group
,
evaluator
|
group
.
ldap_group_links
<<
create
(
:ldap_group_link
,
cn:
evaluator
.
cn
,
group_access:
evaluator
.
group_access
,
provider:
evaluator
.
provider
)
end
end
factory
:group_with_ldap_group_filter_link
do
after
(
:create
)
do
|
group
,
evaluator
|
group
.
ldap_group_links
<<
create
(
:ldap_group_link
,
filter:
'(a=b)'
,
cn:
nil
,
group_access:
evaluator
.
group_access
,
provider:
evaluator
.
provider
)
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