aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Tim Emiola <temiola@google.com>2015-01-26 19:55:12 -0800
committerGravatar Tim Emiola <temiola@google.com>2015-01-26 19:55:12 -0800
commit2854ad7aa4db1e7df4a386cac5c3946d6b15de90 (patch)
tree758298e07f1d1e79ac83da24a7deaef41321f472 /src/ruby
parent6e1f10d7579fe97c6b19e8cb5a16668ce3afb0a2 (diff)
Adds support for overriding the server host name during SSL
Diffstat (limited to 'src/ruby')
-rwxr-xr-xsrc/ruby/bin/interop/interop_client.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ruby/bin/interop/interop_client.rb b/src/ruby/bin/interop/interop_client.rb
index 4c9c24be15..c5e87a7ba2 100755
--- a/src/ruby/bin/interop/interop_client.rb
+++ b/src/ruby/bin/interop/interop_client.rb
@@ -69,12 +69,12 @@ def test_creds
end
# creates a test stub that accesses host:port securely.
-def create_stub(host, port, is_secure)
+def create_stub(host, port, is_secure, host_override)
address = "#{host}:#{port}"
if is_secure
stub_opts = {
:creds => test_creds,
- GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.com'
+ GRPC::Core::Channel::SSL_TARGET => host_override
}
logger.info("... connecting securely to #{address}")
Grpc::Testing::TestService::Stub.new(address, **stub_opts)
@@ -212,6 +212,7 @@ def parse_options
options = {
'secure' => false,
'server_host' => nil,
+ 'server_host_override' => nil,
'server_port' => nil,
'test_case' => nil
}
@@ -220,6 +221,10 @@ def parse_options
opts.on('--server_host SERVER_HOST', 'server hostname') do |v|
options['server_host'] = v
end
+ opts.on('--server_host_override HOST_OVERRIDE',
+ 'override host via a HTTP header') do |v|
+ options['server_host_override'] = v
+ end
opts.on('--server_port SERVER_PORT', 'server port') do |v|
options['server_port'] = v
end
@@ -240,12 +245,16 @@ def parse_options
fail(OptionParser::MissingArgument, "please specify --#{arg}")
end
end
+ if options['server_host_override'].nil?
+ options['server_host_override'] = options['server_host']
+ end
options
end
def main
opts = parse_options
- stub = create_stub(opts['server_host'], opts['server_port'], opts['secure'])
+ stub = create_stub(opts['server_host'], opts['server_port'], opts['secure'],
+ opts['server_host_override'])
NamedTests.new(stub).method(opts['test_case']).call
end