Updates ruby code affected by the secure server API change

pull/835/head
Tim Emiola 10 years ago
parent 3a0d9768d3
commit 0ce8edc49e
  1. 5
      src/ruby/bin/interop/interop_server.rb
  2. 5
      src/ruby/bin/math_server.rb
  3. 5
      src/ruby/bin/noproto_server.rb
  4. 9
      src/ruby/lib/grpc/generic/rpc_server.rb
  5. 18
      src/ruby/spec/client_server_spec.rb
  6. 13
      src/ruby/spec/generic/rpc_server_spec.rb
  7. 15
      src/ruby/spec/server_spec.rb

@ -176,12 +176,11 @@ end
def main
opts = parse_options
host = "0.0.0.0:#{opts['port']}"
s = GRPC::RpcServer.new
if opts['secure']
s = GRPC::RpcServer.new(creds: test_server_creds)
s.add_http2_port(host, true)
s.add_http2_port(host, test_server_creds)
logger.info("... running securely on #{host}")
else
s = GRPC::RpcServer.new
s.add_http2_port(host)
logger.info("... running insecurely on #{host}")
end

@ -173,12 +173,11 @@ def main
end
end.parse!
s = GRPC::RpcServer.new
if options['secure']
s = GRPC::RpcServer.new(creds: test_server_creds)
s.add_http2_port(options['host'], true)
s.add_http2_port(options['host'], test_server_creds)
logger.info("... running securely on #{options['host']}")
else
s = GRPC::RpcServer.new
s.add_http2_port(options['host'])
logger.info("... running insecurely on #{options['host']}")
end

@ -95,12 +95,11 @@ def main
end
end.parse!
s = GRPC::RpcServer.new
if options['secure']
s = GRPC::RpcServer.new(creds: test_server_creds)
s.add_http2_port(options['host'], true)
s.add_http2_port(options['host'], test_server_creds)
logger.info("... running securely on #{options['host']}")
else
s = GRPC::RpcServer.new
s.add_http2_port(options['host'])
logger.info("... running insecurely on #{options['host']}")
end

@ -81,7 +81,6 @@ module GRPC
max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS,
poll_period:INFINITE_FUTURE,
completion_queue_override:nil,
creds:nil,
server_override:nil,
**kw)
if completion_queue_override.nil?
@ -95,13 +94,7 @@ module GRPC
@cq = cq
if server_override.nil?
if creds.nil?
srv = Core::Server.new(@cq, kw)
elsif !creds.is_a? Core::ServerCredentials
fail(ArgumentError, 'not a ServerCredentials')
else
srv = Core::Server.new(@cq, kw, creds)
end
srv = Core::Server.new(@cq, kw)
else
srv = server_override
fail(ArgumentError, 'not a Server') unless srv.is_a? Core::Server

@ -95,7 +95,7 @@ shared_context 'setup: tags' do
end
def new_client_call
@ch.create_call('/method', 'localhost', deadline)
@ch.create_call('/method', 'foo.test.google.fr', deadline)
end
end
@ -346,12 +346,12 @@ end
describe 'the secure http client/server' do
before(:example) do
certs = load_test_certs
server_host = 'localhost:0'
server_host = '0.0.0.0:0'
@client_queue = GRPC::Core::CompletionQueue.new
@server_queue = GRPC::Core::CompletionQueue.new
server_creds = GRPC::Core::ServerCredentials.new(nil, certs[1], certs[2])
@server = GRPC::Core::Server.new(@server_queue, nil, server_creds)
server_port = @server.add_http2_port(server_host, true)
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, server_creds)
@server.start
args = { Channel::SSL_TARGET => 'foo.test.google.fr' }
@ch = Channel.new("0.0.0.0:#{server_port}", args,
@ -362,11 +362,9 @@ describe 'the secure http client/server' do
@server.close
end
# TODO: uncomment after updating the to the new c api
# it_behaves_like 'basic GRPC message delivery is OK' do
# end
it_behaves_like 'basic GRPC message delivery is OK' do
end
# TODO: uncomment after updating the to the new c api
# it_behaves_like 'GRPC metadata delivery works OK' do
# end
it_behaves_like 'GRPC metadata delivery works OK' do
end
end

@ -164,19 +164,6 @@ describe GRPC::RpcServer do
expect(&blk).to raise_error
end
it 'can be created with the creds as valid ServerCedentials' do
certs = load_test_certs
server_creds = GRPC::Core::ServerCredentials.new(nil, certs[1], certs[2])
blk = proc do
opts = {
a_channel_arg: 'an_arg',
creds: server_creds
}
RpcServer.new(**opts)
end
expect(&blk).to_not raise_error
end
it 'can be created with a server override' do
opts = { a_channel_arg: 'an_arg', server_override: @server }
blk = proc do

@ -118,10 +118,11 @@ describe Server do
end
describe 'for secure servers' do
let(:cert) { create_test_cert }
it 'runs without failing' do
blk = proc do
s = Server.new(@cq, nil)
s.add_http2_port('localhost:0', true)
s.add_http2_port('localhost:0', cert)
s.close
end
expect(&blk).to_not raise_error
@ -130,7 +131,7 @@ describe Server do
it 'fails if the server is closed' do
s = Server.new(@cq, nil)
s.close
blk = proc { s.add_http2_port('localhost:0', true) }
blk = proc { s.add_http2_port('localhost:0', cert) }
expect(&blk).to raise_error(RuntimeError)
end
end
@ -138,7 +139,7 @@ describe Server do
shared_examples '#new' do
it 'takes a completion queue with nil channel args' do
expect { Server.new(@cq, nil, create_test_cert) }.to_not raise_error
expect { Server.new(@cq, nil) }.to_not raise_error
end
it 'does not take a hash with bad keys as channel args' do
@ -195,14 +196,6 @@ describe Server do
it_behaves_like '#new'
end
describe '#new with a secure channel' do
def construct_with_args(a)
proc { Server.new(@cq, a, create_test_cert) }
end
it_behaves_like '#new'
end
def start_a_server
s = Server.new(@cq, nil)
s.add_http2_port('0.0.0.0:0')

Loading…
Cancel
Save