Return 404 in project issues API endpoint when project cannot be found

Closes #29631
This commit is contained in:
Adam Niedzielski 2017-03-20 18:03:29 +01:00
parent a1a04828e3
commit 8ab347b392
5 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,4 @@
---
title: Return 404 in project issues API endpoint when project cannot be found
merge_request: 10093
author:

View file

@ -91,7 +91,7 @@ module API
use :issues_params
end
get ":id/issues" do
project = find_project(params[:id])
project = find_project!(params[:id])
issues = find_issues(project_id: project.id)

View file

@ -103,7 +103,7 @@ module API
use :issues_params
end
get ":id/issues" do
project = find_project(params[:id])
project = find_project!(params[:id])
issues = find_issues(project_id: project.id)

View file

@ -534,6 +534,12 @@ describe API::Issues, api: true do
describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" }
it 'returns 404 when project does not exist' do
get api('/projects/1000/issues', non_member)
expect(response).to have_http_status(404)
end
it "returns 404 on private projects for other users" do
private_project = create(:empty_project, :private)
create(:issue, project: private_project)

View file

@ -439,6 +439,12 @@ describe API::V3::Issues, api: true do
describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" }
it 'returns 404 when project does not exist' do
get v3_api('/projects/1000/issues', non_member)
expect(response).to have_http_status(404)
end
it "returns 404 on private projects for other users" do
private_project = create(:empty_project, :private)
create(:issue, project: private_project)