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
3bd306dd
Commit
3bd306dd
authored
Dec 19, 2018
by
Luke Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show the correct error page when access is denied
parent
8fecf976
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
4 deletions
+18
-4
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+7
-1
changelogs/unreleased/fix-403-page-is-rendered-but-404-is-the-response.yml
...ased/fix-403-page-is-rendered-but-404-is-the-response.yml
+5
-0
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+2
-0
spec/features/projects/pipelines/pipeline_spec.rb
spec/features/projects/pipelines/pipeline_spec.rb
+4
-3
No files found.
app/controllers/application_controller.rb
View file @
3bd306dd
...
@@ -177,11 +177,17 @@ class ApplicationController < ActionController::Base
...
@@ -177,11 +177,17 @@ class ApplicationController < ActionController::Base
# hide existence of the resource, rather tell them they cannot access it using
# hide existence of the resource, rather tell them they cannot access it using
# the provided message
# the provided message
status
||=
message
.
present?
?
:forbidden
:
:not_found
status
||=
message
.
present?
?
:forbidden
:
:not_found
template
=
if
status
==
:not_found
"errors/not_found"
else
"errors/access_denied"
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
any
{
head
status
}
format
.
any
{
head
status
}
format
.
html
do
format
.
html
do
render
"errors/access_denied"
,
render
template
,
layout:
"errors"
,
layout:
"errors"
,
status:
status
,
status:
status
,
locals:
{
message:
message
}
locals:
{
message:
message
}
...
...
changelogs/unreleased/fix-403-page-is-rendered-but-404-is-the-response.yml
0 → 100644
View file @
3bd306dd
---
title
:
Show the correct error page when access is denied
merge_request
:
23932
author
:
type
:
fixed
spec/controllers/application_controller_spec.rb
View file @
3bd306dd
...
@@ -519,12 +519,14 @@ describe ApplicationController do
...
@@ -519,12 +519,14 @@ describe ApplicationController do
get
:index
get
:index
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
render_template
(
'errors/not_found'
)
end
end
it
'renders a 403 when a message is passed to access denied'
do
it
'renders a 403 when a message is passed to access denied'
do
get
:index
,
params:
{
message:
'None shall pass'
}
get
:index
,
params:
{
message:
'None shall pass'
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
render_template
(
'errors/access_denied'
)
end
end
it
'renders a status passed to access denied'
do
it
'renders a status passed to access denied'
do
...
...
spec/features/projects/pipelines/pipeline_spec.rb
View file @
3bd306dd
...
@@ -477,10 +477,11 @@ describe 'Pipeline', :js do
...
@@ -477,10 +477,11 @@ describe 'Pipeline', :js do
end
end
context
'when accessing failed jobs page'
do
context
'when accessing failed jobs page'
do
it
'
fails to access the
page'
do
it
'
renders a 404
page'
do
subject
requests
=
inspect_requests
{
subject
}
expect
(
page
).
to
have_title
(
'Access Denied'
)
expect
(
page
).
to
have_title
(
'Not Found'
)
expect
(
requests
.
first
.
status_code
).
to
eq
(
404
)
end
end
end
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