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
5e1c39cb
Commit
5e1c39cb
authored
Oct 13, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge tests to support Multiple LDAP groups
parent
01b79123
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
24 deletions
+31
-24
spec/factories.rb
spec/factories.rb
+5
-0
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+3
-4
spec/lib/gitlab/ldap/adapter_spec.rb
spec/lib/gitlab/ldap/adapter_spec.rb
+1
-1
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+3
-19
spec/models/user_spec.rb
spec/models/user_spec.rb
+19
-0
No files found.
spec/factories.rb
View file @
5e1c39cb
...
...
@@ -24,6 +24,11 @@ FactoryGirl.define do
admin
true
end
trait
:ldap
do
provider
'ldapmain'
extern_uid
'my-ldap-id'
end
factory
:admin
,
traits:
[
:admin
]
end
...
...
spec/lib/gitlab/auth_spec.rb
View file @
5e1c39cb
...
...
@@ -28,17 +28,16 @@ describe Gitlab::Auth do
end
context
"with ldap enabled"
do
before
{
Gitlab
.
config
.
ldap
[
'enabled'
]
=
true
}
after
{
Gitlab
.
config
.
ldap
[
'enabled'
]
=
false
}
before
{
Gitlab
::
LDAP
::
Config
.
stub
(
enabled?:
true
)
}
it
"tries to autheticate with db before ldap"
do
expect
(
Gitlab
::
LDAP
::
User
).
not_to
receive
(
:authenticate
)
expect
(
Gitlab
::
LDAP
::
Authentication
).
not_to
receive
(
:login
)
gl_auth
.
find
(
username
,
password
)
end
it
"uses ldap as fallback to for authentication"
do
expect
(
Gitlab
::
LDAP
::
User
).
to
receive
(
:authenticate
)
expect
(
Gitlab
::
LDAP
::
Authentication
).
to
receive
(
:login
)
gl_auth
.
find
(
'ldap_user'
,
'password'
)
end
...
...
spec/lib/gitlab/ldap/adapter_spec.rb
View file @
5e1c39cb
require
'spec_helper'
describe
Gitlab
::
LDAP
::
Adapter
do
let
(
:adapter
)
{
Gitlab
::
LDAP
::
Adapter
.
new
}
let
(
:adapter
)
{
Gitlab
::
LDAP
::
Adapter
.
new
'ldapmain'
}
describe
:dn_matches_filter?
do
let
(
:ldap
)
{
double
(
:ldap
)
}
...
...
spec/lib/gitlab/ldap/user_spec.rb
View file @
5e1c39cb
...
...
@@ -10,12 +10,12 @@ describe Gitlab::LDAP::User do
}
end
let
(
:auth_hash
)
do
double
(
uid:
'my-uid'
,
provider:
'ldap'
,
info:
double
(
info
))
double
(
uid:
'my-uid'
,
provider:
'ldap
main
'
,
info:
double
(
info
))
end
describe
:find_or_create
do
it
"finds the user if already existing"
do
existing_user
=
create
(
:user
,
extern_uid:
'my-uid'
,
provider:
'ldap'
)
existing_user
=
create
(
:user
,
extern_uid:
'my-uid'
,
provider:
'ldap
main
'
)
expect
{
gl_user
.
save
}.
to_not
change
{
User
.
count
}
end
...
...
@@ -26,27 +26,11 @@ describe Gitlab::LDAP::User do
existing_user
.
reload
expect
(
existing_user
.
extern_uid
).
to
eql
'my-uid'
expect
(
existing_user
.
provider
).
to
eql
'ldap'
expect
(
existing_user
.
provider
).
to
eql
'ldap
main
'
end
it
"creates a new user if not found"
do
expect
{
gl_user
.
save
}.
to
change
{
User
.
count
}.
by
(
1
)
end
end
describe
"authenticate"
do
let
(
:login
)
{
'john'
}
let
(
:password
)
{
'my-secret'
}
before
{
Gitlab
.
config
.
ldap
[
'enabled'
]
=
true
Gitlab
.
config
.
ldap
[
'user_filter'
]
=
'employeeType=developer'
}
after
{
Gitlab
.
config
.
ldap
[
'enabled'
]
=
false
}
it
"send an authentication request to ldap"
do
expect
(
Gitlab
::
LDAP
::
User
.
adapter
).
to
receive
(
:bind_as
)
Gitlab
::
LDAP
::
User
.
authenticate
(
login
,
password
)
end
end
end
spec/models/user_spec.rb
View file @
5e1c39cb
...
...
@@ -346,6 +346,25 @@ describe User do
end
end
describe
:ldap_user?
do
let
(
:user
)
{
build
(
:user
,
:ldap
)
}
it
"is true if provider name starts with ldap"
do
user
.
provider
=
'ldapmain'
expect
(
user
.
ldap_user?
).
to
be_true
end
it
"is false for other providers"
do
user
.
provider
=
'other-provider'
expect
(
user
.
ldap_user?
).
to
be_false
end
it
"is false if no extern_uid is provided"
do
user
.
extern_uid
=
nil
expect
(
user
.
ldap_user?
).
to
be_false
end
end
describe
'#full_website_url'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
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