diff options
author | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-06-26 21:40:37 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-06-26 21:40:37 +0000 |
commit | ab9dcdc485c54a7b5ce7756e5b2021ddbffb2af1 (patch) | |
tree | 232b1fb953efb1f66bd19414b16b0bd40b4cd724 /spec | |
parent | 74da71f88d239478cc9e68433c5d2b79e1cadb3e (diff) | |
parent | 68a22519f5e2a3f64b38f3d0a707f6e0af654ba6 (diff) | |
download | gitlab-ce-ab9dcdc485c54a7b5ce7756e5b2021ddbffb2af1.tar.gz |
Merge branch 'security-11-11-mr-head-pipeline-leak' into '11-11-stable'
Fix MR head pipeline leak
See merge request gitlab/gitlabhq!3155
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 5c94a87529b..e37c7ed36d9 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -834,6 +834,31 @@ describe API::MergeRequests do end end + context 'head_pipeline' do + before do + merge_request.update(head_pipeline: create(:ci_pipeline)) + merge_request.project.project_feature.update(builds_access_level: 10) + end + + context 'when user can read the pipeline' do + it 'exposes pipeline information' do + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user) + + expect(json_response).to include('head_pipeline') + end + end + + context 'when user can not read the pipeline' do + let(:guest) { create(:user) } + + it 'does not expose pipeline information' do + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", guest) + + expect(json_response).not_to include('head_pipeline') + end + end + end + it 'returns the commits behind the target branch when include_diverged_commits_count is present' do allow_any_instance_of(merge_request.class).to receive(:diverged_commits_count).and_return(1) |