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
Léo-Paul Géneau
gitlab-ce
Commits
75b2ff8f
Commit
75b2ff8f
authored
Sep 16, 2013
by
Izaak Alpert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ldap tests
Change-Id: Ifd77615b3b92d7d8bca92b8875aa8204356cfd85
parent
4fcc17e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
46 deletions
+5
-46
spec/lib/gitlab/ldap/ldap_user_auth_spec.rb
spec/lib/gitlab/ldap/ldap_user_auth_spec.rb
+5
-46
No files found.
spec/lib/
auth_o
auth_spec.rb
→
spec/lib/
gitlab/ldap/ldap_user_
auth_spec.rb
View file @
75b2ff8f
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Auth
do
describe
Gitlab
::
LDAP
do
let
(
:gl_auth
)
{
Gitlab
::
Auth
.
new
}
let
(
:gl_auth
)
{
Gitlab
::
LDAP
::
User
}
before
do
before
do
Gitlab
.
config
.
stub
(
omniauth:
{})
Gitlab
.
config
.
stub
(
omniauth:
{})
...
@@ -22,17 +22,12 @@ describe Gitlab::Auth do
...
@@ -22,17 +22,12 @@ describe Gitlab::Auth do
)
)
end
end
it
"should find by uid & provider"
do
User
.
should_receive
:find_by_extern_uid_and_provider
gl_auth
.
find_for_ldap_auth
(
@auth
)
end
it
"should update credentials by email if missing uid"
do
it
"should update credentials by email if missing uid"
do
user
=
double
(
'User'
)
user
=
double
(
'User'
)
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
find_by_email:
user
User
.
stub
find_by_email:
user
user
.
should_receive
:update_attributes
user
.
should_receive
:update_attributes
gl_auth
.
find_
for_ldap_auth
(
@auth
)
gl_auth
.
find_
or_create
(
@auth
)
end
end
it
"should update credentials by username if missing uid and Gitlab.config.ldap.allow_username_or_email_login is true"
do
it
"should update credentials by username if missing uid and Gitlab.config.ldap.allow_username_or_email_login is true"
do
...
@@ -43,7 +38,7 @@ describe Gitlab::Auth do
...
@@ -43,7 +38,7 @@ describe Gitlab::Auth do
User
.
stub
find_by_email:
nil
User
.
stub
find_by_email:
nil
User
.
stub
find_by_username:
user
User
.
stub
find_by_username:
user
user
.
should_receive
:update_attributes
user
.
should_receive
:update_attributes
gl_auth
.
find_
for_ldap_auth
(
@auth
)
gl_auth
.
find_
or_create
(
@auth
)
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
value
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
value
end
end
...
@@ -55,44 +50,8 @@ describe Gitlab::Auth do
...
@@ -55,44 +50,8 @@ describe Gitlab::Auth do
User
.
stub
find_by_email:
nil
User
.
stub
find_by_email:
nil
User
.
stub
find_by_username:
user
User
.
stub
find_by_username:
user
user
.
should_not_receive
:update_attributes
user
.
should_not_receive
:update_attributes
gl_auth
.
find_
for_ldap_auth
(
@auth
)
gl_auth
.
find_
or_create
(
@auth
)
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
value
Gitlab
.
config
.
ldap
[
'allow_username_or_email_login'
]
=
value
end
end
it
"should create from auth if user does not exist"
do
User
.
stub
find_by_extern_uid_and_provider:
nil
User
.
stub
find_by_email:
nil
gl_auth
.
should_receive
:create_from_omniauth
gl_auth
.
find_for_ldap_auth
(
@auth
)
end
end
describe
:find_or_new_for_omniauth
do
before
do
@auth
=
mock
(
info:
@info
,
provider:
'twitter'
,
uid:
'12djsak321'
,
)
end
it
"should find user"
do
User
.
should_receive
:find_by_provider_and_extern_uid
gl_auth
.
should_not_receive
:create_from_omniauth
gl_auth
.
find_or_new_for_omniauth
(
@auth
)
end
it
"should not create user"
do
User
.
stub
find_by_provider_and_extern_uid:
nil
gl_auth
.
should_not_receive
:create_from_omniauth
gl_auth
.
find_or_new_for_omniauth
(
@auth
)
end
it
"should create user if single_sing_on"
do
Gitlab
.
config
.
omniauth
[
'allow_single_sign_on'
]
=
true
User
.
stub
find_by_provider_and_extern_uid:
nil
gl_auth
.
should_receive
:create_from_omniauth
gl_auth
.
find_or_new_for_omniauth
(
@auth
)
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