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
442b2836
Commit
442b2836
authored
Oct 31, 2019
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Avoid #authenticate_user! in #route_not_found"
This reverts commit
00b3e372
.
parent
2fc77624
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
39 additions
and
68 deletions
+39
-68
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+2
-4
ee/spec/controllers/groups/boards_controller_spec.rb
ee/spec/controllers/groups/boards_controller_spec.rb
+0
-10
ee/spec/controllers/projects/boards_controller_spec.rb
ee/spec/controllers/projects/boards_controller_spec.rb
+0
-10
ee/spec/controllers/projects/managed_licenses_controller_spec.rb
.../controllers/projects/managed_licenses_controller_spec.rb
+10
-10
ee/spec/controllers/projects/settings/operations_controller_spec.rb
...ntrollers/projects/settings/operations_controller_spec.rb
+2
-2
ee/spec/support/shared_examples/controllers/recent_boards.rb
ee/spec/support/shared_examples/controllers/recent_boards.rb
+10
-0
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+1
-1
spec/controllers/projects/commits_controller_spec.rb
spec/controllers/projects/commits_controller_spec.rb
+2
-2
spec/controllers/projects/error_tracking_controller_spec.rb
spec/controllers/projects/error_tracking_controller_spec.rb
+1
-1
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+2
-2
spec/controllers/projects/tags_controller_spec.rb
spec/controllers/projects/tags_controller_spec.rb
+1
-1
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+1
-1
spec/features/projects/pipelines/pipelines_spec.rb
spec/features/projects/pipelines/pipelines_spec.rb
+1
-4
spec/features/projects/tags/user_views_tags_spec.rb
spec/features/projects/tags/user_views_tags_spec.rb
+1
-1
spec/support/controllers/sessionless_auth_controller_shared_examples.rb
...ontrollers/sessionless_auth_controller_shared_examples.rb
+4
-18
spec/support/shared_examples/controllers/todos_shared_examples.rb
...port/shared_examples/controllers/todos_shared_examples.rb
+1
-1
No files found.
app/controllers/application_controller.rb
View file @
442b2836
...
...
@@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base
include
Gitlab
::
Tracking
::
ControllerConcern
include
Gitlab
::
Experimentation
::
ControllerConcern
before_action
:authenticate_user!
,
except:
[
:route_not_found
]
before_action
:authenticate_user!
before_action
:enforce_terms!
,
if: :should_enforce_terms?
before_action
:validate_user_service_ticket!
before_action
:check_password_expiration
...
...
@@ -98,9 +98,7 @@ class ApplicationController < ActionController::Base
if
current_user
not_found
else
store_location_for
(
:user
,
request
.
fullpath
)
unless
request
.
xhr?
redirect_to
new_user_session_path
,
alert:
I18n
.
t
(
'devise.failure.unauthenticated'
)
authenticate_user!
end
end
...
...
ee/spec/controllers/groups/boards_controller_spec.rb
View file @
442b2836
...
...
@@ -56,16 +56,6 @@ describe Groups::BoardsController do
let
(
:parent
)
{
group
}
it_behaves_like
'returns recently visited boards'
context
'unauthenticated'
do
it
'returns a 401'
do
sign_out
(
user
)
list_boards
(
recent:
true
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
end
describe
'GET show'
do
...
...
ee/spec/controllers/projects/boards_controller_spec.rb
View file @
442b2836
...
...
@@ -31,16 +31,6 @@ describe Projects::BoardsController do
let
(
:parent
)
{
project
}
it_behaves_like
'returns recently visited boards'
context
'unauthenticated'
do
it
'returns a 302'
do
sign_out
(
user
)
list_boards
(
recent:
true
)
expect
(
response
).
to
have_gitlab_http_status
(
302
)
end
end
end
describe
'GET show'
do
...
...
ee/spec/controllers/projects/managed_licenses_controller_spec.rb
View file @
442b2836
...
...
@@ -72,10 +72,10 @@ describe Projects::ManagedLicensesController do
context
'with no logged in user'
do
let
(
:user
)
{
unlogged_user
}
it
'returns a
redirect
'
do
it
'returns a
n unauthorized status
'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
@@ -122,10 +122,10 @@ describe Projects::ManagedLicensesController do
context
'with no logged in user'
do
let
(
:user
)
{
unlogged_user
}
it
'returns a
redirect
'
do
it
'returns a
n unauthorized status
'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
@@ -235,10 +235,10 @@ describe Projects::ManagedLicensesController do
new_software_license_policy_attributes
end
it
'returns a
redirect
'
do
it
'returns a
n unauthorized status
'
do
expect
{
subject
}.
not_to
change
{
project
.
software_license_policies
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
@@ -347,10 +347,10 @@ describe Projects::ManagedLicensesController do
new_software_license_policy_attributes
end
it
'returns a
redirect
'
do
it
'returns a
n unauthorized status
'
do
expect
{
subject
}.
not_to
change
{
project
.
software_license_policies
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
@@ -452,10 +452,10 @@ describe Projects::ManagedLicensesController do
new_software_license_policy_attributes
end
it
'returns a
redirect
'
do
it
'returns a
n unauthorized status
'
do
expect
{
subject
}.
not_to
change
{
project
.
software_license_policies
.
count
}
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
ee/spec/controllers/projects/settings/operations_controller_spec.rb
View file @
442b2836
...
...
@@ -506,10 +506,10 @@ describe Projects::Settings::OperationsController do
sign_out
(
user
)
end
it
'returns
a redirect
'
do
it
'returns
unauthorized status
'
do
reset_alerting_token
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
ee/spec/support/shared_examples/controllers/recent_boards.rb
View file @
442b2836
...
...
@@ -5,6 +5,16 @@ require 'spec_helper'
shared_examples
'returns recently visited boards'
do
let
(
:boards
)
{
create_list
(
:board
,
8
,
resource_parent:
parent
)
}
context
'unauthenticated'
do
it
'returns a 401'
do
sign_out
(
user
)
list_boards
(
recent:
true
)
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
it
'returns last 4 visited boards'
do
[
0
,
2
,
5
,
3
,
7
,
1
].
each_with_index
do
|
board_index
,
i
|
visit_board
(
boards
[
board_index
],
Time
.
now
+
i
.
minutes
)
...
...
spec/controllers/application_controller_spec.rb
View file @
442b2836
...
...
@@ -186,7 +186,7 @@ describe ApplicationController do
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'redirects to login page if not authenticated'
do
it
'redirects to login page
via authenticate_user!
if not authenticated'
do
get
:index
expect
(
response
).
to
redirect_to
new_user_session_path
...
...
spec/controllers/projects/commits_controller_spec.rb
View file @
442b2836
...
...
@@ -142,7 +142,7 @@ describe Projects::CommitsController do
context
'token authentication'
do
context
'public project'
do
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
,
{
public:
true
,
ignore_incrementing:
true
}
do
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
,
public:
true
do
before
do
public_project
=
create
(
:project
,
:repository
,
:public
)
...
...
@@ -152,7 +152,7 @@ describe Projects::CommitsController do
end
context
'private project'
do
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
,
{
public:
false
,
ignore_incrementing:
true
}
do
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
,
public:
false
do
before
do
private_project
=
create
(
:project
,
:repository
,
:private
)
private_project
.
add_maintainer
(
user
)
...
...
spec/controllers/projects/error_tracking_controller_spec.rb
View file @
442b2836
...
...
@@ -146,7 +146,7 @@ describe Projects::ErrorTrackingController do
it
'redirects to sign-in page'
do
post
:list_projects
,
params:
list_projects_params
expect
(
response
).
to
have_gitlab_http_status
(
:
redirect
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
442b2836
...
...
@@ -1441,7 +1441,7 @@ describe Projects::IssuesController do
context
'private project with token authentication'
do
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
it_behaves_like
'authenticates sessionless user'
,
:index
,
:atom
,
ignore_incrementing:
true
do
it_behaves_like
'authenticates sessionless user'
,
:index
,
:atom
do
before
do
default_params
.
merge!
(
project_id:
private_project
,
namespace_id:
private_project
.
namespace
)
...
...
@@ -1449,7 +1449,7 @@ describe Projects::IssuesController do
end
end
it_behaves_like
'authenticates sessionless user'
,
:calendar
,
:ics
,
ignore_incrementing:
true
do
it_behaves_like
'authenticates sessionless user'
,
:calendar
,
:ics
do
before
do
default_params
.
merge!
(
project_id:
private_project
,
namespace_id:
private_project
.
namespace
)
...
...
spec/controllers/projects/tags_controller_spec.rb
View file @
442b2836
...
...
@@ -41,7 +41,7 @@ describe Projects::TagsController do
context
'private project with token authentication'
do
let
(
:private_project
)
{
create
(
:project
,
:repository
,
:private
)
}
it_behaves_like
'authenticates sessionless user'
,
:index
,
:atom
,
ignore_incrementing:
true
do
it_behaves_like
'authenticates sessionless user'
,
:index
,
:atom
do
before
do
default_params
.
merge!
(
project_id:
private_project
,
namespace_id:
private_project
.
namespace
)
...
...
spec/controllers/projects_controller_spec.rb
View file @
442b2836
...
...
@@ -1149,7 +1149,7 @@ describe ProjectsController do
context
'private project with token authentication'
do
let
(
:private_project
)
{
create
(
:project
,
:private
)
}
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
,
ignore_incrementing:
true
do
it_behaves_like
'authenticates sessionless user'
,
:show
,
:atom
do
before
do
default_params
.
merge!
(
id:
private_project
,
namespace_id:
private_project
.
namespace
)
...
...
spec/features/projects/pipelines/pipelines_spec.rb
View file @
442b2836
...
...
@@ -819,10 +819,7 @@ describe 'Pipelines', :js do
context
'when project is private'
do
let
(
:project
)
{
create
(
:project
,
:private
,
:repository
)
}
it
'redirects the user to sign_in and displays the flash alert'
do
expect
(
page
).
to
have_content
'You need to sign in'
expect
(
page
.
current_path
).
to
eq
(
"/users/sign_in"
)
end
it
{
expect
(
page
).
to
have_content
'You need to sign in'
}
end
end
...
...
spec/features/projects/tags/user_views_tags_spec.rb
View file @
442b2836
...
...
@@ -15,7 +15,7 @@ describe 'User views tags', :feature do
it
do
visit
project_tags_path
(
project
,
format: :atom
)
expect
(
page
.
current_path
).
to
eq
(
"/users/sign_in"
)
expect
(
page
).
to
have_gitlab_http_status
(
401
)
end
end
...
...
spec/support/controllers/sessionless_auth_controller_shared_examples.rb
View file @
442b2836
...
...
@@ -34,15 +34,8 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
context
'when the personal access token has no api scope'
,
unless:
params
[
:public
]
do
it
'does not log the user in'
do
# Several instances of where these specs are shared route the request
# through ApplicationController#route_not_found which does not involve
# the usual auth code from Devise, so does not increment the
# :user_unauthenticated_counter
#
unless
params
[
:ignore_incrementing
]
expect
(
authentication_metrics
)
.
to
increment
(
:user_unauthenticated_counter
)
end
expect
(
authentication_metrics
)
.
to
increment
(
:user_unauthenticated_counter
)
personal_access_token
.
update
(
scopes:
[
:read_user
])
...
...
@@ -91,15 +84,8 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
end
it
"doesn't log the user in otherwise"
,
unless:
params
[
:public
]
do
# Several instances of where these specs are shared route the request
# through ApplicationController#route_not_found which does not involve
# the usual auth code from Devise, so does not increment the
# :user_unauthenticated_counter
#
unless
params
[
:ignore_incrementing
]
expect
(
authentication_metrics
)
.
to
increment
(
:user_unauthenticated_counter
)
end
expect
(
authentication_metrics
)
.
to
increment
(
:user_unauthenticated_counter
)
get
path
,
params:
default_params
.
merge
(
private_token:
'token'
)
...
...
spec/support/shared_examples/controllers/todos_shared_examples.rb
View file @
442b2836
...
...
@@ -39,7 +39,7 @@ shared_examples 'todos actions' do
post_create
end
.
to
change
{
user
.
todos
.
count
}.
by
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
302
)
expect
(
response
).
to
have_gitlab_http_status
(
parent
.
is_a?
(
Group
)
?
401
:
302
)
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