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
Hide 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'
describe
Gitlab
::
LDAP
::
User
do
let
(
:gl_auth
)
{
Gitlab
::
LDAP
::
User
}
before
do
Gitlab
.
config
.
stub
(
omniauth:
{})
@info
=
double
(
uid:
'12djsak321'
,
let
(
:info
)
do
double
(
name:
'John'
,
email:
'john@
mail
.com'
,
email:
'john@
example
.com'
,
nickname:
'john'
)
end
before
{
Gitlab
.
config
.
stub
(
omniauth:
{})
}
describe
:find_or_create
do
let
(
:auth
)
do
double
(
info:
info
,
provider:
'ldap'
,
uid:
'my-uid'
)
end
it
"finds the user if already existing"
do
existing_user
=
create
(
:user
,
extern_uid:
'my-uid'
,
provider:
'ldap'
)
describe
:find_for_ldap_auth
do
before
do
@auth
=
double
(
uid:
'12djsak321'
,
info:
@info
,
provider:
'ldap'
)
expect
{
gl_auth
.
find_or_create
(
auth
)
}.
to_not
change
{
User
.
count
}
end
it
"should update credentials by email if missing uid"
do
user
=
double
(
'User'
)
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
(
:find_by
).
with
(
hash_including
(
email:
anything
()))
{
user
}
user
.
should_receive
:update_attributes
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
it
"should not update credentials by username if missing uid and Gitlab.config.ldap.allow_username_or_email_login is false"
do
user
=
double
(
'User'
)
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
it
"creates a new user if not found"
do
expect
{
gl_auth
.
find_or_create
(
auth
)
}.
to
change
{
User
.
count
}.
by
(
1
)
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