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
4be20ba9
Commit
4be20ba9
authored
Feb 22, 2018
by
Michael Kozono
Committed by
Stan Hu
Feb 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respond 404 when repo does not exist
parent
b9ed721b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
5 deletions
+23
-5
changelogs/unreleased/mk-fix-error-code-for-repo-does-not-exist.yml
.../unreleased/mk-fix-error-code-for-repo-does-not-exist.yml
+5
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+1
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+13
-0
spec/lib/gitlab/git_access_wiki_spec.rb
spec/lib/gitlab/git_access_wiki_spec.rb
+1
-1
spec/requests/git_http_spec.rb
spec/requests/git_http_spec.rb
+3
-3
No files found.
changelogs/unreleased/mk-fix-error-code-for-repo-does-not-exist.yml
0 → 100644
View file @
4be20ba9
---
title
:
Return a 404 instead of 403 if the repository does not exist on disk
merge_request
:
17341
author
:
type
:
fixed
lib/gitlab/git_access.rb
View file @
4be20ba9
...
...
@@ -199,7 +199,7 @@ module Gitlab
def
check_repository_existence!
unless
repository
.
exists?
raise
Unauthorize
dError
,
ERROR_MESSAGES
[
:no_repo
]
raise
NotFoun
dError
,
ERROR_MESSAGES
[
:no_repo
]
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
4be20ba9
...
...
@@ -534,6 +534,19 @@ describe Gitlab::GitAccess do
expect
{
pull_access_check
}.
to
raise_unauthorized
(
'Your account has been blocked.'
)
end
context
'when the project repository does not exist'
do
it
'returns not found'
do
project
.
add_guest
(
user
)
repo
=
project
.
repository
FileUtils
.
rm_rf
(
repo
.
path
)
# Sanity check for rm_rf
expect
(
repo
.
exists?
).
to
eq
(
false
)
expect
{
pull_access_check
}.
to
raise_error
(
Gitlab
::
GitAccess
::
NotFoundError
,
'A repository for this project does not exist yet.'
)
end
end
describe
'without access to project'
do
context
'pull code'
do
it
{
expect
{
pull_access_check
}.
to
raise_not_found
}
...
...
spec/lib/gitlab/git_access_wiki_spec.rb
View file @
4be20ba9
...
...
@@ -57,7 +57,7 @@ describe Gitlab::GitAccessWiki do
# Sanity check for rm_rf
expect
(
wiki_repo
.
exists?
).
to
eq
(
false
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
Unauthorize
dError
,
'A repository for this project does not exist yet.'
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
NotFoun
dError
,
'A repository for this project does not exist yet.'
)
end
end
end
...
...
spec/requests/git_http_spec.rb
View file @
4be20ba9
...
...
@@ -597,7 +597,7 @@ describe 'Git HTTP requests' do
context
"when a gitlab ci token is provided"
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:build
)
{
create
(
:ci_build
,
:running
)
}
let
(
:other_project
)
{
create
(
:project
)
}
let
(
:other_project
)
{
create
(
:project
,
:repository
)
}
before
do
build
.
update!
(
project:
project
)
# can't associate it on factory create
...
...
@@ -648,10 +648,10 @@ describe 'Git HTTP requests' do
context
'when the repo does not exist'
do
let
(
:project
)
{
create
(
:project
)
}
it
'rejects pulls with 40
3 Forbidden
'
do
it
'rejects pulls with 40
4 Not Found
'
do
clone_get
path
,
env
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
not_found
)
expect
(
response
.
body
).
to
eq
(
git_access_error
(
:no_repo
))
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