Commit 137ebcfb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Replace undefined Grape routing code from 400 to 404

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent fdfc9367
...@@ -83,6 +83,7 @@ v 8.13.0 (unreleased) ...@@ -83,6 +83,7 @@ v 8.13.0 (unreleased)
- 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 - 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) v 8.12.5 (unreleased)
......
...@@ -357,13 +357,13 @@ follows: ...@@ -357,13 +357,13 @@ follows:
## Bad request ## Bad request
When you try to access API URL that does not exist you will receive 400 Bad Request. When you try to access API URL that does not exist you will receive 404 Not Found.
``` ```
HTTP/1.1 400 Bad Request HTTP/1.1 404 Not Found
Content-Type: application/json Content-Type: application/json
{ {
"error": "400 Bad Request" "error": "404 Not Found"
} }
``` ```
......
...@@ -75,7 +75,7 @@ module API ...@@ -75,7 +75,7 @@ module API
mount ::API::Variables mount ::API::Variables
route :any, '*path' do route :any, '*path' do
error!('400 Bad Request', 400) error!('404 Not Found', 404)
end end
end end
end end
...@@ -163,10 +163,10 @@ describe API::API, 'ProjectHooks', api: true do ...@@ -163,10 +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 400 error if hook id not given" do it "returns a 404 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(400) expect(response).to have_http_status(404)
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
......
...@@ -90,10 +90,10 @@ describe API::API, api: true do ...@@ -90,10 +90,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 a 400 if invalid ID" do it "returns a 404 for 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(404)
end end
end end
...@@ -341,10 +341,10 @@ describe API::API, api: true do ...@@ -341,10 +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 "returns a 400 if invalid ID" do it "returns a 404 if invalid ID" do
put api("/users/ASDF", admin) put api("/users/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
it 'returns 400 error if user does not validate' do it 'returns 400 error if user does not validate' do
...@@ -410,9 +410,9 @@ describe API::API, api: true do ...@@ -410,9 +410,9 @@ describe API::API, api: true do
end.to change{ user.keys.count }.by(1) end.to change{ user.keys.count }.by(1)
end end
it "returns 400 for invalid ID" do it "returns 404 for invalid ID" do
post api("/users/999999/keys", admin) post api("/users/999999/keys", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -496,9 +496,10 @@ describe API::API, api: true do ...@@ -496,9 +496,10 @@ describe API::API, api: true do
end.to change{ user.emails.count }.by(1) end.to change{ user.emails.count }.by(1)
end end
it "raises error for invalid ID" do it "returns a 404 for invalid ID" do
post api("/users/999999/emails", admin) post api("/users/999999/emails", admin)
expect(response).to have_http_status(400)
expect(response).to have_http_status(404)
end end
end end
...@@ -528,10 +529,10 @@ describe API::API, api: true do ...@@ -528,10 +529,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 "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
put api("/users/ASDF/emails", admin) put api("/users/ASDF/emails", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -570,10 +571,10 @@ describe API::API, api: true do ...@@ -570,10 +571,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 "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
delete api("/users/ASDF/emails/bar", admin) delete api("/users/ASDF/emails/bar", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
end end
...@@ -606,10 +607,10 @@ describe API::API, api: true do ...@@ -606,10 +607,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 "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
delete api("/users/ASDF", admin) delete api("/users/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -662,6 +663,7 @@ describe API::API, api: true do ...@@ -662,6 +663,7 @@ describe API::API, api: true do
it "returns 404 Not Found within invalid ID" do it "returns 404 Not Found within invalid ID" do
get api("/user/keys/42", user) get api("/user/keys/42", user)
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
...@@ -675,10 +677,10 @@ describe API::API, api: true do ...@@ -675,10 +677,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 400 for invalid ID" do it "returns 404 for invalid ID" do
get api("/users/keys/ASDF", admin) get api("/users/keys/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -736,10 +738,10 @@ describe API::API, api: true do ...@@ -736,10 +738,10 @@ describe API::API, api: true do
expect(response).to have_http_status(401) expect(response).to have_http_status(401)
end end
it "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
delete api("/users/keys/ASDF", admin) delete api("/users/keys/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -787,10 +789,10 @@ describe API::API, api: true do ...@@ -787,10 +789,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 400 for invalid ID" do it "returns 404 for invalid ID" do
get api("/users/emails/ASDF", admin) get api("/users/emails/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -837,10 +839,10 @@ describe API::API, api: true do ...@@ -837,10 +839,10 @@ describe API::API, api: true do
expect(response).to have_http_status(401) expect(response).to have_http_status(401)
end end
it "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
delete api("/users/emails/ASDF", admin) delete api("/users/emails/ASDF", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
...@@ -905,10 +907,10 @@ describe API::API, api: true do ...@@ -905,10 +907,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 "returns a 400 for invalid ID" do it "returns a 404 for invalid ID" do
put api("/users/ASDF/block", admin) put api("/users/ASDF/block", admin)
expect(response).to have_http_status(400) expect(response).to have_http_status(404)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment