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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
fdfc9367
Commit
fdfc9367
authored
Oct 07, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API specs behaviour for invalid routing
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d6cfc004
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
20 deletions
+51
-20
CHANGELOG
CHANGELOG
+1
-0
doc/api/README.md
doc/api/README.md
+13
-0
spec/requests/api/project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+3
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+34
-18
No files found.
CHANGELOG
View file @
fdfc9367
...
@@ -82,6 +82,7 @@ v 8.13.0 (unreleased)
...
@@ -82,6 +82,7 @@ v 8.13.0 (unreleased)
- Add Container Registry on/off status to Admin Area !6638 (the-undefined)
- Add Container Registry on/off status to Admin Area !6638 (the-undefined)
- Grouped pipeline dropdown is a scrollable container
- Grouped pipeline dropdown is a scrollable container
- Fix a typo in doc/api/labels.md
- Fix a typo in doc/api/labels.md
- API: all unknown routing will be handled with 400 Bad Request
v 8.12.5 (unreleased)
v 8.12.5 (unreleased)
...
...
doc/api/README.md
View file @
fdfc9367
...
@@ -355,6 +355,19 @@ follows:
...
@@ -355,6 +355,19 @@ follows:
}
}
```
```
## Bad request
When you try to access API URL that does not exist you will receive 400 Bad Request.
```
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": "400 Bad Request"
}
```
## Clients
## Clients
There are many unofficial GitLab API Clients for most of the popular
There are many unofficial GitLab API Clients for most of the popular
...
...
spec/requests/api/project_hooks_spec.rb
View file @
fdfc9367
...
@@ -163,9 +163,10 @@ describe API::API, 'ProjectHooks', api: true do
...
@@ -163,9 +163,10 @@ describe API::API, 'ProjectHooks', api: true do
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
it
"returns a 40
5
error if hook id not given"
do
it
"returns a 40
0
error if hook id not given"
do
delete
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
)
expect
(
response
).
to
have_http_status
(
405
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
it
"returns a 404 if a user attempts to delete project hooks he/she does not own"
do
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 @
fdfc9367
...
@@ -92,6 +92,7 @@ describe API::API, api: true do
...
@@ -92,6 +92,7 @@ describe API::API, api: true do
it
"returns a 400 if invalid ID"
do
it
"returns a 400 if invalid ID"
do
get
api
(
"/users/1ASDF"
,
user
)
get
api
(
"/users/1ASDF"
,
user
)
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -340,8 +341,10 @@ describe API::API, api: true do
...
@@ -340,8 +341,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 if invalid ID"
do
expect
{
put
api
(
"/users/ASDF"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
put
api
(
"/users/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
it
'returns 400 error if user does not validate'
do
it
'returns 400 error if user does not validate'
do
...
@@ -525,9 +528,10 @@ describe API::API, api: true do
...
@@ -525,9 +528,10 @@ describe API::API, api: true do
expect
(
json_response
.
first
[
'email'
]).
to
eq
(
email
.
email
)
expect
(
json_response
.
first
[
'email'
]).
to
eq
(
email
.
email
)
end
end
it
"r
aises error
for invalid ID"
do
it
"r
eturns a 400
for invalid ID"
do
put
api
(
"/users/ASDF/emails"
,
admin
)
put
api
(
"/users/ASDF/emails"
,
admin
)
expect
(
response
).
to
have_http_status
(
405
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
end
end
...
@@ -566,8 +570,10 @@ describe API::API, api: true do
...
@@ -566,8 +570,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Email Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Email Not Found'
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 for invalid ID"
do
expect
{
delete
api
(
"/users/ASDF/emails/bar"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
delete
api
(
"/users/ASDF/emails/bar"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
end
end
...
@@ -600,8 +606,10 @@ describe API::API, api: true do
...
@@ -600,8 +606,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 for invalid ID"
do
expect
{
delete
api
(
"/users/ASDF"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
delete
api
(
"/users/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -667,9 +675,10 @@ describe API::API, api: true do
...
@@ -667,9 +675,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
it
"returns 40
4
for invalid ID"
do
it
"returns 40
0
for invalid ID"
do
get
api
(
"/users/keys/ASDF"
,
admin
)
get
api
(
"/users/keys/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -727,8 +736,10 @@ describe API::API, api: true do
...
@@ -727,8 +736,10 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 for invalid ID"
do
expect
{
delete
api
(
"/users/keys/ASDF"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
delete
api
(
"/users/keys/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -776,9 +787,10 @@ describe API::API, api: true do
...
@@ -776,9 +787,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
it
"returns 40
4
for invalid ID"
do
it
"returns 40
0
for invalid ID"
do
get
api
(
"/users/emails/ASDF"
,
admin
)
get
api
(
"/users/emails/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -825,8 +837,10 @@ describe API::API, api: true do
...
@@ -825,8 +837,10 @@ describe API::API, api: true do
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 for invalid ID"
do
expect
{
delete
api
(
"/users/emails/ASDF"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
delete
api
(
"/users/emails/ASDF"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
end
end
...
@@ -891,8 +905,10 @@ describe API::API, api: true do
...
@@ -891,8 +905,10 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 User Not Found'
)
end
end
it
"raises error for invalid ID"
do
it
"returns a 400 for invalid ID"
do
expect
{
put
api
(
"/users/ASDF/block"
,
admin
)
}.
to
raise_error
(
ActionController
::
RoutingError
)
put
api
(
"/users/ASDF/block"
,
admin
)
expect
(
response
).
to
have_http_status
(
400
)
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