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
d042751c
Commit
d042751c
authored
Mar 18, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage for Oauth::GeoAuthController
parent
91ec7343
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
11 deletions
+57
-11
ee/spec/controllers/oauth/geo_auth_controller_spec.rb
ee/spec/controllers/oauth/geo_auth_controller_spec.rb
+57
-11
No files found.
ee/spec/controllers/oauth/geo_auth_controller_spec.rb
View file @
d042751c
...
...
@@ -27,12 +27,34 @@ describe Oauth::GeoAuthController do
expect
(
response
).
to
redirect_to
(
root_url
)
end
it
"redirects to primary node's oauth endpoint"
do
oauth_endpoint
=
Gitlab
::
Geo
::
Oauth
::
Session
.
new
.
authorize_url
(
redirect_uri:
oauth_geo_callback_url
,
state:
login_state
)
shared_examples
"a valid redirect to to primary node's oauth endpoint"
do
it
"redirects to primary node's oauth endpoint"
do
oauth_endpoint
=
Gitlab
::
Geo
::
Oauth
::
Session
.
new
.
authorize_url
(
redirect_uri:
oauth_geo_callback_url
,
state:
login_state
)
get
:auth
,
params:
{
state:
login_state
}
get
:auth
,
params:
{
state:
login_state
}
expect
(
response
).
to
redirect_to
(
oauth_endpoint
)
end
end
context
'without a tampered header'
do
it_behaves_like
"a valid redirect to to primary node's oauth endpoint"
end
context
'with a tampered HOST header'
do
before
do
request
.
headers
[
'HOST'
]
=
'http://this.is.not.my.host'
end
it_behaves_like
"a valid redirect to to primary node's oauth endpoint"
end
context
'with a tampered X-Forwarded-Host header'
do
before
do
request
.
headers
[
'X-Forwarded-Host'
]
=
'http://this.is.not.my.host'
end
expect
(
response
).
to
redirect_to
(
oauth_endpoint
)
it_behaves_like
"a valid redirect to to primary node's oauth endpoint"
end
end
...
...
@@ -55,16 +77,40 @@ describe Oauth::GeoAuthController do
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
it
'redirects to redirect_url if state is valid'
do
get
:callback
,
params:
{
state:
login_state
}
context
'with a valid state'
do
shared_examples
'a valid redirect to redirect_url'
do
it
"redirects to primary node's oauth endpoint"
do
get
:callback
,
params:
{
state:
login_state
}
expect
(
response
).
to
redirect_to
(
'/'
)
end
expect
(
response
).
to
redirect_to
(
'/'
)
end
end
it
'does not display a flash message if state is valid'
do
get
:callback
,
params:
{
state:
login_state
}
context
'without a tampered header'
do
it_behaves_like
'a valid redirect to redirect_url'
end
context
'with a tampered HOST header'
do
before
do
request
.
headers
[
'HOST'
]
=
'http://this.is.not.my.host'
end
it_behaves_like
'a valid redirect to redirect_url'
end
context
'with a tampered X-Forwarded-Host header'
do
before
do
request
.
headers
[
'X-Forwarded-Host'
]
=
'http://this.is.not.my.host'
end
it_behaves_like
'a valid redirect to redirect_url'
end
it
'does not display a flash message'
do
get
:callback
,
params:
{
state:
login_state
}
expect
(
controller
).
to
set_flash
[
:alert
].
to
(
nil
)
expect
(
controller
).
to
set_flash
[
:alert
].
to
(
nil
)
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