Commit f2a7b509 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'verify_project_id_in_api' into 'master'

Verify project id presence in API requests

See merge request gitlab-org/gitlab!80086
parents dbb52509 f059837f
......@@ -117,6 +117,8 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
return unless id
projects = Project.without_deleted
if id.is_a?(Integer) || id =~ /^\d+$/
......
......@@ -76,6 +76,12 @@ RSpec.describe API::Helpers do
expect(subject.find_project(non_existing_id)).to be_nil
end
end
context 'when project id is not provided' do
it 'returns nil' do
expect(subject.find_project(nil)).to be_nil
end
end
end
context 'when ID is used as an argument' do
......
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