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
Kazuhiko Shiozaki
gitlab-ce
Commits
0c34fa3e
Commit
0c34fa3e
authored
Sep 01, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for finding an oauth authenticated user
parent
4198b58a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
lib/gitlab/oauth/user.rb
lib/gitlab/oauth/user.rb
+1
-1
spec/lib/gitlab/oauth/user_spec.rb
spec/lib/gitlab/oauth/user_spec.rb
+26
-11
No files found.
lib/gitlab/oauth/user.rb
View file @
0c34fa3e
...
...
@@ -67,7 +67,7 @@ module Gitlab
end
def
uid
uid
=
auth
.
info
.
uid
||
auth
.
uid
uid
=
auth
.
info
.
try
(
:uid
)
||
auth
.
uid
uid
=
uid
.
to_s
unless
uid
.
nil?
uid
end
...
...
spec/lib/gitlab/oauth/user_spec.rb
View file @
0c34fa3e
...
...
@@ -2,39 +2,54 @@ require 'spec_helper'
describe
Gitlab
::
OAuth
::
User
do
let
(
:gl_auth
)
{
Gitlab
::
OAuth
::
User
}
before
do
Gitlab
.
config
.
stub
(
omniauth:
{})
@info
=
double
(
uid:
'12djsak321'
,
let
(
:info
)
do
double
(
uid:
'my-uid'
,
nickname:
'john'
,
name:
'John'
,
email:
'john@mail.com'
)
end
before
do
Gitlab
.
config
.
stub
(
omniauth:
{})
end
describe
:find
do
let!
(
:existing_user
)
{
create
(
:user
,
extern_uid:
'my-uid'
,
provider:
'my-provider'
)
}
it
"finds an existing user based on uid and provider (facebook)"
do
auth
=
double
(
info:
double
(
name:
'John'
),
uid:
'my-uid'
,
provider:
'my-provider'
)
assert
gl_auth
.
find
(
auth
)
end
it
"finds an existing user based on nested uid and provider"
do
auth
=
double
(
info:
info
,
provider:
'my-provider'
)
assert
gl_auth
.
find
(
auth
)
end
end
describe
:create
do
it
"should create user from LDAP"
do
@auth
=
double
(
info:
@
info
,
provider:
'ldap'
)
@auth
=
double
(
info:
info
,
provider:
'ldap'
)
user
=
gl_auth
.
create
(
@auth
)
user
.
should
be_valid
user
.
extern_uid
.
should
==
@
info
.
uid
user
.
extern_uid
.
should
==
info
.
uid
user
.
provider
.
should
==
'ldap'
end
it
"should create user from Omniauth"
do
@auth
=
double
(
info:
@
info
,
provider:
'twitter'
)
@auth
=
double
(
info:
info
,
provider:
'twitter'
)
user
=
gl_auth
.
create
(
@auth
)
user
.
should
be_valid
user
.
extern_uid
.
should
==
@
info
.
uid
user
.
extern_uid
.
should
==
info
.
uid
user
.
provider
.
should
==
'twitter'
end
it
"should apply defaults to user"
do
@auth
=
double
(
info:
@
info
,
provider:
'ldap'
)
@auth
=
double
(
info:
info
,
provider:
'ldap'
)
user
=
gl_auth
.
create
(
@auth
)
user
.
should
be_valid
...
...
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