summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-20 22:40:49 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-20 22:40:49 +0800
commitff3776c8d5a84f7ea6b1b50ad8c7add02d3f0434 (patch)
tree47de4b3213222703e28b4b015aac523f4e0d0a39
parent88aacaa7e5ec57b85749028f4463a498fc1e35f1 (diff)
downloadgitlab-ce-ff3776c8d5a84f7ea6b1b50ad8c7add02d3f0434.tar.gz
Should check against `authorize_read_builds!`
-rw-r--r--lib/api/builds.rb2
-rw-r--r--spec/requests/api/builds_spec.rb14
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 7e5114052c4..657d421fe97 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -83,6 +83,8 @@ module API
# GET /projects/:id/artifacts/:ref_name/download?job=name
get ':id/builds/artifacts/:ref_name/download',
requirements: { ref_name: /.+/ } do
+ authorize_read_builds!
+
builds = user_project.latest_successful_builds_for(params[:ref_name])
latest_build = builds.find_by!(name: params[:job])
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index d274466edec..43fb2edb730 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -6,9 +6,11 @@ describe API::API, api: true do
let(:user) { create(:user) }
let(:api_user) { user }
let(:user2) { create(:user) }
+ let(:guest_user) { create(:user) }
let!(:project) { create(:project, creator_id: user.id) }
let!(:developer) { create(:project_member, :developer, user: user, project: project) }
let!(:reporter) { create(:project_member, :reporter, user: user2, project: project) }
+ let!(:guest) { create(:project_member, :guest, user: guest_user, project: project) }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) }
let!(:build) { create(:ci_build, pipeline: pipeline) }
@@ -192,6 +194,18 @@ describe API::API, api: true do
end
end
+ context 'when forbidden' do
+ let(:api_user) { guest_user }
+
+ before do
+ get path_for_ref
+ end
+
+ it 'gives 403' do
+ expect(response).to have_http_status(403)
+ end
+ end
+
context 'non-existing build' do
shared_examples 'not found' do
it { expect(response).to have_http_status(:not_found) }