summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 14:23:18 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 17:08:12 +0200
commit16b8513ca185ad82df039ca15e158e244b4df963 (patch)
tree0ee07fcff0db3ef3beb744d124efe80aa15373c8
parent90f6a18f621aeff2a02ab0f9e11b0032c0d70688 (diff)
downloadgitlab-ce-per-build-token.tar.gz
Solve code review commentsper-build-token
-rw-r--r--lib/gitlab/auth/result.rb2
-rw-r--r--spec/requests/ci/api/builds_spec.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb
index ed6c6627558..e4786b12676 100644
--- a/lib/gitlab/auth/result.rb
+++ b/lib/gitlab/auth/result.rb
@@ -1,6 +1,6 @@
module Gitlab
module Auth
- class Result < Struct.new(:actor, :project, :type, :authentication_abilities)
+ Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
def ci?
type == :ci
end
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index 09d72fe0a0e..df97f1bf7b6 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -263,6 +263,7 @@ describe Ci::API::API do
context "should authorize posting artifact to running build" do
it "using token as parameter" do
post authorize_url, { token: build.token }, headers
+
expect(response).to have_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response["TempPath"]).not_to be_nil
@@ -270,6 +271,7 @@ describe Ci::API::API do
it "using token as header" do
post authorize_url, {}, headers_with_token
+
expect(response).to have_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response["TempPath"]).not_to be_nil
@@ -277,6 +279,7 @@ describe Ci::API::API do
it "using runners token" do
post authorize_url, { token: build.project.runners_token }, headers
+
expect(response).to have_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(json_response["TempPath"]).not_to be_nil
@@ -284,7 +287,9 @@ describe Ci::API::API do
it "reject requests that did not go through gitlab-workhorse" do
headers.delete(Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER)
+
post authorize_url, { token: build.token }, headers
+
expect(response).to have_http_status(500)
end
end
@@ -292,13 +297,17 @@ describe Ci::API::API do
context "should fail to post too large artifact" do
it "using token as parameter" do
stub_application_setting(max_artifacts_size: 0)
+
post authorize_url, { token: build.token, filesize: 100 }, headers
+
expect(response).to have_http_status(413)
end
it "using token as header" do
stub_application_setting(max_artifacts_size: 0)
+
post authorize_url, { filesize: 100 }, headers_with_token
+
expect(response).to have_http_status(413)
end
end