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
3457695b
Commit
3457695b
authored
Jun 24, 2019
by
Sam Battalio
Committed by
Nick Thomas
Jun 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change HTTP Status Code when repository disabled
parent
9e6c3f56
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
14 deletions
+29
-14
changelogs/unreleased/50834-change-http-status-code-when-repository-disabled.yml
...0834-change-http-status-code-when-repository-disabled.yml
+5
-0
lib/api/branches.rb
lib/api/branches.rb
+4
-1
lib/api/commits.rb
lib/api/commits.rb
+4
-1
lib/api/helpers.rb
lib/api/helpers.rb
+4
-0
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+5
-5
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+7
-7
No files found.
changelogs/unreleased/50834-change-http-status-code-when-repository-disabled.yml
0 → 100644
View file @
3457695b
---
title
:
"
Changed
HTTP
Status
Code
for
disabled
repository
on
/branches
and
/commits
to
404"
merge_request
:
29585
author
:
Sam Battalio
type
:
changed
lib/api/branches.rb
View file @
3457695b
...
@@ -8,7 +8,10 @@ module API
...
@@ -8,7 +8,10 @@ module API
BRANCH_ENDPOINT_REQUIREMENTS
=
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
.
merge
(
branch:
API
::
NO_SLASH_URL_PART_REGEX
)
BRANCH_ENDPOINT_REQUIREMENTS
=
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
.
merge
(
branch:
API
::
NO_SLASH_URL_PART_REGEX
)
before
{
authorize!
:download_code
,
user_project
}
before
do
require_repository_enabled!
authorize!
:download_code
,
user_project
end
helpers
do
helpers
do
params
:filter_params
do
params
:filter_params
do
...
...
lib/api/commits.rb
View file @
3457695b
...
@@ -6,7 +6,10 @@ module API
...
@@ -6,7 +6,10 @@ module API
class
Commits
<
Grape
::
API
class
Commits
<
Grape
::
API
include
PaginationParams
include
PaginationParams
before
{
authorize!
:download_code
,
user_project
}
before
do
require_repository_enabled!
authorize!
:download_code
,
user_project
end
helpers
do
helpers
do
def
user_access
def
user_access
...
...
lib/api/helpers.rb
View file @
3457695b
...
@@ -250,6 +250,10 @@ module API
...
@@ -250,6 +250,10 @@ module API
authorize!
:update_build
,
user_project
authorize!
:update_build
,
user_project
end
end
def
require_repository_enabled!
(
subject
=
:global
)
not_found!
(
"Repository"
)
unless
user_project
.
feature_available?
(
:repository
,
current_user
)
end
def
require_gitlab_workhorse!
def
require_gitlab_workhorse!
unless
env
[
'HTTP_GITLAB_WORKHORSE'
].
present?
unless
env
[
'HTTP_GITLAB_WORKHORSE'
].
present?
forbidden!
(
'Request should be executed via GitLab Workhorse'
)
forbidden!
(
'Request should be executed via GitLab Workhorse'
)
...
...
spec/requests/api/branches_spec.rb
View file @
3457695b
...
@@ -65,7 +65,7 @@ describe API::Branches do
...
@@ -65,7 +65,7 @@ describe API::Branches do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -175,7 +175,7 @@ describe API::Branches do
...
@@ -175,7 +175,7 @@ describe API::Branches do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -337,7 +337,7 @@ describe API::Branches do
...
@@ -337,7 +337,7 @@ describe API::Branches do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
put
api
(
route
,
current_user
)
}
let
(
:request
)
{
put
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -471,7 +471,7 @@ describe API::Branches do
...
@@ -471,7 +471,7 @@ describe API::Branches do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
put
api
(
route
,
current_user
)
}
let
(
:request
)
{
put
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -547,7 +547,7 @@ describe API::Branches do
...
@@ -547,7 +547,7 @@ describe API::Branches do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
post
api
(
route
,
current_user
)
}
let
(
:request
)
{
post
api
(
route
,
current_user
)
}
end
end
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
3457695b
...
@@ -736,7 +736,7 @@ describe API::Commits do
...
@@ -736,7 +736,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -825,7 +825,7 @@ describe API::Commits do
...
@@ -825,7 +825,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -968,7 +968,7 @@ describe API::Commits do
...
@@ -968,7 +968,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -1067,7 +1067,7 @@ describe API::Commits do
...
@@ -1067,7 +1067,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
end
end
...
@@ -1169,7 +1169,7 @@ describe API::Commits do
...
@@ -1169,7 +1169,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
branch:
'master'
}
}
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
branch:
'master'
}
}
end
end
end
end
...
@@ -1324,7 +1324,7 @@ describe API::Commits do
...
@@ -1324,7 +1324,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
}
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
branch:
branch
}
}
end
end
end
end
...
@@ -1435,7 +1435,7 @@ describe API::Commits do
...
@@ -1435,7 +1435,7 @@ describe API::Commits do
context
'when repository is disabled'
do
context
'when repository is disabled'
do
include_context
'disabled repository'
include_context
'disabled repository'
it_behaves_like
'40
3
response'
do
it_behaves_like
'40
4
response'
do
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
note:
'My comment'
}
}
let
(
:request
)
{
post
api
(
route
,
current_user
),
params:
{
note:
'My comment'
}
}
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