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
ea04b019
Commit
ea04b019
authored
Apr 11, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added default setting for `external_providers`
parent
12e60846
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
spec/lib/gitlab/o_auth/user_spec.rb
spec/lib/gitlab/o_auth/user_spec.rb
+28
-9
No files found.
spec/lib/gitlab/o_auth/user_spec.rb
View file @
ea04b019
...
...
@@ -15,20 +15,20 @@ describe Gitlab::OAuth::User, lib: true do
end
let
(
:ldap_user
)
{
Gitlab
::
LDAP
::
Person
.
new
(
Net
::
LDAP
::
Entry
.
new
,
'ldapmain'
)
}
describe
:persisted?
do
describe
'#persisted?'
do
let!
(
:existing_user
)
{
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
'my-provider'
)
}
it
"finds an existing user based on uid and provider (facebook)"
do
expect
(
oauth_user
.
persisted?
).
to
be_truthy
end
it
"returns false if use is not found in database"
do
it
'returns false if user is not found in database'
do
allow
(
auth_hash
).
to
receive
(
:uid
).
and_return
(
'non-existing'
)
expect
(
oauth_user
.
persisted?
).
to
be_falsey
end
end
describe
:save
do
describe
'#save'
do
def
stub_omniauth_config
(
messages
)
allow
(
Gitlab
.
config
.
omniauth
).
to
receive_messages
(
messages
)
end
...
...
@@ -40,8 +40,27 @@ describe Gitlab::OAuth::User, lib: true do
let
(
:provider
)
{
'twitter'
}
describe
'signup'
do
shared_examples
"to verify compliance with allow_single_sign_on"
do
context
"with new allow_single_sign_on enabled syntax"
do
shared_examples
'to verify compliance with allow_single_sign_on'
do
context
'provider is marked as external'
do
it
'should mark user as external'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'twitter'
])
oauth_user
.
save
expect
(
gl_user
).
to
be_valid
expect
(
gl_user
.
external
).
to
be_truthy
end
end
context
'provider was external, now has been removed'
do
it
'should mark existing user internal'
do
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
'twitter'
,
external:
true
)
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'facebook'
])
oauth_user
.
save
expect
(
gl_user
).
to
be_valid
expect
(
gl_user
.
external
).
to
be_falsey
end
end
context
'with new allow_single_sign_on enabled syntax'
do
before
{
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
])
}
it
"creates a user from Omniauth"
do
...
...
@@ -67,16 +86,16 @@ describe Gitlab::OAuth::User, lib: true do
end
end
context
"with new allow_single_sign_on disabled syntax"
do
context
'with new allow_single_sign_on disabled syntax'
do
before
{
stub_omniauth_config
(
allow_single_sign_on:
[])
}
it
"throws an error"
do
it
'throws an error'
do
expect
{
oauth_user
.
save
}.
to
raise_error
StandardError
end
end
context
"with old allow_single_sign_on disabled (Default)"
do
context
'with old allow_single_sign_on disabled (Default)'
do
before
{
stub_omniauth_config
(
allow_single_sign_on:
false
)
}
it
"throws an error"
do
it
'throws an error'
do
expect
{
oauth_user
.
save
}.
to
raise_error
StandardError
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