summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSteve Azzopardi <steveazz@outlook.com>2019-01-24 08:55:22 +0100
committerSteve Azzopardi <steveazz@outlook.com>2019-01-24 09:03:14 +0100
commitcb67423d48f6e5e78c7ecd9196b93edf7666ba0c (patch)
tree8be43b9f851a1baebf95b9fd05c809409892ae91 /spec
parent97aa25ba8b87797da268c5b42179df3799347847 (diff)
downloadgitlab-ce-cb67423d48f6e5e78c7ecd9196b93edf7666ba0c.tar.gz
Get remote address for runner
Check if `X-Forwarded-For` is set before getting the IP of the request, with this the real IP address of the runner is shown if it's behind a proxy. closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53676
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/runner_spec.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index ec48bf60426..ed0108c846a 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -210,8 +210,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it "sets the runner's ip_address" do
post api('/runners'),
- params: { token: registration_token },
- headers: { 'REMOTE_ADDR' => '123.111.123.111' }
+ params: { token: registration_token },
+ headers: { 'X-Forwarded-For' => '123.111.123.111' }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.ip_address).to eq('123.111.123.111')
@@ -520,7 +520,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it "sets the runner's ip_address" do
post api('/jobs/request'),
params: { token: runner.token },
- headers: { 'User-Agent' => user_agent, 'REMOTE_ADDR' => '123.222.123.222' }
+ headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222' }
expect(response).to have_gitlab_http_status 201
expect(runner.reload.ip_address).to eq('123.222.123.222')