Skip to content
Snippets Groups Projects
Verified Commit 6d1cb1f2 authored by Matija Čupić's avatar Matija Čupić
Browse files

Authorize read_build when listing pipeline jobs

parent 37954d62
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -59,6 +59,8 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
get ':id/pipelines/:pipeline_id/jobs' do
pipeline = user_project.pipelines.find(params[:pipeline_id])
authorize!(:read_build, pipeline)
builds = pipeline.builds
builds = filter_builds(builds, params[:scope])
builds = builds.preload(:job_artifacts_archive, :job_artifacts, project: [:namespace])
Loading
Loading
Loading
Loading
@@ -251,10 +251,20 @@ describe API::Jobs do
end
 
context 'unauthorized user' do
let(:api_user) { nil }
context 'when user is not logged in' do
let(:api_user) { nil }
 
it 'does not return jobs' do
expect(response).to have_gitlab_http_status(401)
it 'does not return jobs' do
expect(response).to have_gitlab_http_status(401)
end
end
context 'when user is guest' do
let(:api_user) { guest }
it 'does not return jobs' do
expect(response).to have_gitlab_http_status(403)
end
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment