Return 404 in project issues API endpoint when project cannot be found
Closes #29631
This commit is contained in:
parent
a1a04828e3
commit
8ab347b392
5 changed files with 18 additions and 2 deletions
4
changelogs/unreleased/api-project-issues-404.yml
Normal file
4
changelogs/unreleased/api-project-issues-404.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Return 404 in project issues API endpoint when project cannot be found
|
||||
merge_request: 10093
|
||||
author:
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue