BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
137ebcfb
Commit
137ebcfb
authored
Oct 07, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace undefined Grape routing code from 400 to 404
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
fdfc9367
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
30 deletions
+33
-30
CHANGELOG
CHANGELOG
+1
-0
README.md
doc/api/README.md
+3
-3
api.rb
lib/api/api.rb
+1
-1
project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+2
-2
users_spec.rb
spec/requests/api/users_spec.rb
+26
-24
No files found.
CHANGELOG
View file @
137ebcfb
...
...
@@ -83,6 +83,7 @@ v 8.13.0 (unreleased)
- Grouped pipeline dropdown is a scrollable container
- Fix a typo in doc/api/labels.md
- API: all unknown routing will be handled with 400 Bad Request
- API: all unknown routing will be handled with 404 Not Found
v 8.12.5 (unreleased)
...
...
doc/api/README.md
View file @
137ebcfb
...
...
@@ -357,13 +357,13 @@ follows:
## Bad request
When you try to access API URL that does not exist you will receive 40
0 Bad Request.
When you try to access API URL that does not exist you will receive 40
4 Not Found.
```
HTTP/1.1 40
0 Bad Request
HTTP/1.1 40
4 Not Found
Content-Type: application/json
{
"error": "40
0 Bad Request
"
"error": "40
4 Not Found
"
}
```
...
...
lib/api/api.rb
View file @
137ebcfb
...
...
@@ -75,7 +75,7 @@ module API
mount
::
API
::
Variables
route
:any
,
'*path'
do
error!
(
'40
0 Bad Request'
,
400
)
error!
(
'40
4 Not Found'
,
404
)
end
end
end
spec/requests/api/project_hooks_spec.rb
View file @
137ebcfb
...
...
@@ -163,10 +163,10 @@ describe API::API, 'ProjectHooks', api: true do
expect
(
response
).
to
have_http_status
(
404
)
end
it
"returns a 40
0
error if hook id not given"
do
it
"returns a 40
4
error if hook id not given"
do
delete
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
it
"returns a 404 if a user attempts to delete project hooks he/she does not own"
do
...
...
spec/requests/api/users_spec.rb
View file @
137ebcfb
...
...
@@ -90,10 +90,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
it
"returns a 40
0 if
invalid ID"
do
it
"returns a 40
4 for
invalid ID"
do
get
api
(
"/users/1ASDF"
,
user
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -341,10 +341,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
it
"returns a 40
0
if invalid ID"
do
it
"returns a 40
4
if invalid ID"
do
put
api
(
"/users/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
it
'returns 400 error if user does not validate'
do
...
...
@@ -410,9 +410,9 @@ describe API::API, api: true do
end
.
to
change
{
user
.
keys
.
count
}.
by
(
1
)
end
it
"returns 40
0
for invalid ID"
do
it
"returns 40
4
for invalid ID"
do
post
api
(
"/users/999999/keys"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -496,9 +496,10 @@ describe API::API, api: true do
end
.
to
change
{
user
.
emails
.
count
}.
by
(
1
)
end
it
"r
aises error
for invalid ID"
do
it
"r
eturns a 404
for invalid ID"
do
post
api
(
"/users/999999/emails"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
...
...
@@ -528,10 +529,10 @@ describe API::API, api: true do
expect
(
json_response
.
first
[
'email'
]).
to
eq
(
email
.
email
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
put
api
(
"/users/ASDF/emails"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
end
...
...
@@ -570,10 +571,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Email Not Found'
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
delete
api
(
"/users/ASDF/emails/bar"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
end
...
...
@@ -606,10 +607,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
delete
api
(
"/users/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -662,6 +663,7 @@ describe API::API, api: true do
it
"returns 404 Not Found within invalid ID"
do
get
api
(
"/user/keys/42"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
...
...
@@ -675,10 +677,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
it
"returns 40
0
for invalid ID"
do
it
"returns 40
4
for invalid ID"
do
get
api
(
"/users/keys/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -736,10 +738,10 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
401
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
delete
api
(
"/users/keys/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -787,10 +789,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
it
"returns 40
0
for invalid ID"
do
it
"returns 40
4
for invalid ID"
do
get
api
(
"/users/emails/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -837,10 +839,10 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
401
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
delete
api
(
"/users/emails/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
end
end
...
...
@@ -905,10 +907,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
it
"returns a 40
0
for invalid ID"
do
it
"returns a 40
4
for invalid ID"
do
put
api
(
"/users/ASDF/block"
,
admin
)
expect
(
response
).
to
have_http_status
(
40
0
)
expect
(
response
).
to
have_http_status
(
40
4
)
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