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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
982d4d51
Commit
982d4d51
authored
May 14, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport Adapter#dn_matches_filter? from EE
parent
f4bca105
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
lib/gitlab/ldap/adapter.rb
lib/gitlab/ldap/adapter.rb
+4
-0
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
+31
-0
No files found.
lib/gitlab/ldap/adapter.rb
View file @
982d4d51
...
@@ -77,6 +77,10 @@ module Gitlab
...
@@ -77,6 +77,10 @@ module Gitlab
users
(
*
args
).
first
users
(
*
args
).
first
end
end
def
dn_matches_filter?
(
dn
,
filter
)
ldap_search
(
base:
dn
,
filter:
filter
,
scope:
Net
::
LDAP
::
SearchScope_BaseObject
,
attributes:
%w{dn}
).
any?
end
def
ldap_search
(
*
args
)
def
ldap_search
(
*
args
)
results
=
ldap
.
search
(
*
args
)
results
=
ldap
.
search
(
*
args
)
...
...
spec/lib/gitlab/ldap/ldap_adapter_spec.rb
0 → 100644
View file @
982d4d51
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Adapter
do
let
(
:adapter
)
{
Gitlab
::
LDAP
::
Adapter
.
new
}
describe
:dn_matches_filter?
do
let
(
:ldap
)
{
double
(
:ldap
)
}
subject
{
adapter
.
dn_matches_filter?
(
:dn
,
:filter
)
}
before
{
adapter
.
stub
(
ldap:
ldap
)
}
context
"when the search is successful"
do
context
"and the result is non-empty"
do
before
{
ldap
.
stub
(
search:
[
:foo
])
}
it
{
should
be_true
}
end
context
"and the result is empty"
do
before
{
ldap
.
stub
(
search:
[])
}
it
{
should
be_false
}
end
end
context
"when the search encounters an error"
do
before
{
ldap
.
stub
(
search:
nil
,
get_operation_result:
double
(
code:
1
,
message:
'some error'
))
}
it
{
should
be_false
}
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