summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-03-13 16:35:10 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-03-13 16:35:10 +0100
commit2e1b2233ce92fadd81ce3e89e1cd1220b9730060 (patch)
tree33f6c9322ffbbed6651af5e20cb1136e2b5e3901
parentcc64eda987d2b1dfc7c0af4255bd09f072301f9c (diff)
downloadgitlab-ce-fix/regression-in-runners-registration-v1-api.tar.gz
Fix regression in runners registration v1 apifix/regression-in-runners-registration-v1-api
-rw-r--r--lib/ci/api/runners.rb4
-rw-r--r--spec/requests/api/runner_spec.rb3
-rw-r--r--spec/requests/ci/api/runners_spec.rb3
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/ci/api/runners.rb b/lib/ci/api/runners.rb
index c1fd959ef14..45aa2adccf5 100644
--- a/lib/ci/api/runners.rb
+++ b/lib/ci/api/runners.rb
@@ -24,13 +24,13 @@ module Ci
optional :locked, type: Boolean, desc: 'Lock this runner for this specific project'
end
post "register" do
- runner_params = declared(params, include_missing: false)
+ runner_params = declared(params, include_missing: false).except(:token)
runner =
if runner_registration_token_valid?
# Create shared runner. Requires admin access
Ci::Runner.create(runner_params.merge(is_shared: true))
- elsif project = Project.find_by(runners_token: runner_params[:token])
+ elsif project = Project.find_by(runners_token: params[:token])
# Create a specific runner for project.
project.runners.create(runner_params)
end
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 15d458e0795..d50fe80b36a 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -39,6 +39,7 @@ describe API::Runner do
expect(json_response['id']).to eq(runner.id)
expect(json_response['token']).to eq(runner.token)
expect(runner.run_untagged).to be true
+ expect(runner.token).not_to eq(registration_token)
end
context 'when project token is used' do
@@ -49,6 +50,8 @@ describe API::Runner do
expect(response).to have_http_status 201
expect(project.runners.size).to eq(1)
+ expect(Ci::Runner.first.token).not_to eq(registration_token)
+ expect(Ci::Runner.first.token).not_to eq(project.runners_token)
end
end
end
diff --git a/spec/requests/ci/api/runners_spec.rb b/spec/requests/ci/api/runners_spec.rb
index 8719313783e..d50cdfdc2d6 100644
--- a/spec/requests/ci/api/runners_spec.rb
+++ b/spec/requests/ci/api/runners_spec.rb
@@ -18,6 +18,7 @@ describe Ci::API::Runners do
it 'creates runner with default values' do
expect(response).to have_http_status 201
expect(Ci::Runner.first.run_untagged).to be true
+ expect(Ci::Runner.first.token).not_to eq(registration_token)
end
end
@@ -74,6 +75,8 @@ describe Ci::API::Runners do
it 'creates runner' do
expect(response).to have_http_status 201
expect(project.runners.size).to eq(1)
+ expect(Ci::Runner.first.token).not_to eq(registration_token)
+ expect(Ci::Runner.first.token).not_to eq(project.runners_token)
end
end