Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
omniauth-msunet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MSU Middleware Group
omniauth-msunet
Commits
35cc5a46
Commit
35cc5a46
authored
8 years ago
by
Tomaka, Andrew
Browse files
Options
Downloads
Patches
Plain Diff
Add specs
parent
0bf88375
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/omniauth/strategies/msunet_spec.rb
+82
-0
82 additions, 0 deletions
spec/omniauth/strategies/msunet_spec.rb
spec/spec_helper.rb
+2
-0
2 additions, 0 deletions
spec/spec_helper.rb
with
84 additions
and
0 deletions
spec/omniauth/strategies/msunet_spec.rb
0 → 100644
+
82
−
0
View file @
35cc5a46
require
'spec_helper'
require
'omniauth-msunet'
describe
OmniAuth
::
Strategies
::
MSUnet
do
let
(
:request
)
{
double
(
'Request'
,
params:
{},
cookies:
{},
env:
{})
}
let
(
:app
)
{
lambda
{
[
200
,
{},
[
"Hello."
]]
}
}
subject
do
OmniAuth
::
Strategies
::
MSUnet
.
new
(
app
,
'appid'
,
'secret'
,
@options
||
{}).
tap
do
|
strategy
|
allow
(
strategy
).
to
receive
(
:request
)
{
request
}
end
end
before
do
OmniAuth
.
config
.
test_mode
=
true
end
after
do
OmniAuth
.
config
.
test_mode
=
false
end
describe
'#client_options'
do
it
'has correct site'
do
expect
(
subject
.
client
.
site
).
to
eq
(
'https://oauth.ais.msu.edu'
)
end
it
'has correct authorize_url'
do
expect
(
subject
.
client
.
options
[
:authorize_url
]).
to
eq
(
'/oauth/authorize'
)
end
it
'has correct token_url'
do
expect
(
subject
.
client
.
options
[
:token_url
]).
to
eq
(
'/oauth/token'
)
end
context
'overrides'
do
it
'should allow overriding the site'
do
@options
=
{
client_options:
{
site:
'https://domain.com'
}}
expect
(
subject
.
client
.
site
).
to
eq
(
'https://domain.com'
)
end
it
'should allow overriding the authorize_url'
do
@options
=
{
client_options:
{
authorize_url:
'https://domain.com'
}}
expect
(
subject
.
client
.
authorize_url
).
to
eq
(
'https://domain.com'
)
end
it
'should allow overriding the token_url'
do
@options
=
{
client_options:
{
token_url:
'https://domain.com'
}}
expect
(
subject
.
client
.
token_url
).
to
eq
(
'https://domain.com'
)
end
end
end
describe
'#extra'
do
let
(
:client
)
do
OAuth2
::
Client
.
new
(
'abc'
,
'def'
)
do
|
builder
|
builder
.
request
:url_encoded
builder
.
adapter
:test
do
|
stub
|
stub
.
get
(
'/oauth/me?access_token='
)
{
|
env
|
[
200
,
{
'content-type'
=>
'application/json'
},
'{"email": "user@domain.com"}'
]}
end
end
end
let
(
:access_token
)
{
OAuth2
::
AccessToken
.
from_hash
(
client
,
{})
}
before
{
allow
(
subject
).
to
receive
(
:access_token
).
and_return
(
access_token
)
}
describe
'#raw_info'
do
it
'should include raw_info'
do
expect
(
subject
.
raw_info
).
to
eq
(
'email'
=>
'user@domain.com'
)
end
end
end
describe
'#callback_path'
do
it
'has the correct default callback path'
do
expect
(
subject
.
callback_path
).
to
eq
(
'/auth/msunet/callback'
)
end
it
'should set the callback_path parameter if present'
do
@options
=
{
callback_path:
'/login'
}
expect
(
subject
.
callback_path
).
to
eq
(
'/login'
)
end
end
end
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
0 → 100644
+
2
−
0
View file @
35cc5a46
require
File
.
join
(
'bundler'
,
'setup'
)
require
'rspec'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment