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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
92a99649
Commit
92a99649
authored
Sep 01, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic find / create specs for LDAP user
parent
ca17e4b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
30 deletions
+22
-30
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+22
-30
No files found.
spec/lib/gitlab/ldap/user_spec.rb
View file @
92a99649
...
@@ -2,45 +2,37 @@ require 'spec_helper'
...
@@ -2,45 +2,37 @@ require 'spec_helper'
describe
Gitlab
::
LDAP
::
User
do
describe
Gitlab
::
LDAP
::
User
do
let
(
:gl_auth
)
{
Gitlab
::
LDAP
::
User
}
let
(
:gl_auth
)
{
Gitlab
::
LDAP
::
User
}
let
(
:info
)
do
before
do
double
(
Gitlab
.
config
.
stub
(
omniauth:
{})
@info
=
double
(
uid:
'12djsak321'
,
name:
'John'
,
name:
'John'
,
email:
'john@
mail
.com'
,
email:
'john@
example
.com'
,
nickname:
'john'
nickname:
'john'
)
)
end
end
before
{
Gitlab
.
config
.
stub
(
omniauth:
{})
}
describe
:find_for_ldap_auth
do
describe
:find_or_create
do
before
do
let
(
:auth
)
do
@auth
=
double
(
double
(
info:
info
,
provider:
'ldap'
,
uid:
'my-uid'
)
uid:
'12djsak321'
,
info:
@info
,
provider:
'ldap'
)
end
end
it
"should update credentials by email if missing uid"
do
it
"finds the user if already existing"
do
user
=
double
(
'User'
)
existing_user
=
create
(
:user
,
extern_uid:
'my-uid'
,
provider:
'ldap'
)
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
(
:find_by
).
with
(
hash_including
(
email:
anything
()))
{
user
}
expect
{
gl_auth
.
find_or_create
(
auth
)
}.
to_not
change
{
User
.
count
}
user
.
should_receive
:update_attributes
end
gl_auth
.
find_or_create
(
@auth
)
it
"connects to existing non-ldap user if the email matches"
do
existing_user
=
create
(
:user
,
email:
'john@example.com'
)
expect
{
gl_auth
.
find_or_create
(
auth
)
}.
to_not
change
{
User
.
count
}
existing_user
.
reload
expect
(
existing_user
.
extern_uid
).
to
eql
'my-uid'
expect
(
existing_user
.
provider
).
to
eql
'ldap'
end
end
it
"should not update credentials by username if missing uid and Gitlab.config.ldap.allow_username_or_email_login is false"
do
it
"creates a new user if not found"
do
user
=
double
(
'User'
)
expect
{
gl_auth
.
find_or_create
(
auth
)
}.
to
change
{
User
.
count
}.
by
(
1
)
value
=
Gitlab
.
config
.
ldap
.
allow_username_or_email_login
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
false
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
(
:find_by
).
with
(
hash_including
(
email:
anything
()))
{
nil
}
User
.
stub
(
:find_by
).
with
(
hash_including
(
username:
anything
()))
{
user
}
user
.
should_not_receive
:update_attributes
gl_auth
.
find_or_create
(
@auth
)
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
value
end
end
end
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