Ruby wrapping of core credentials API change.

reviewable/pr3765/r1^2
Tim Emiola 9 years ago
parent 9332ea6af5
commit 43a7e4e6ed
  1. 2
      src/ruby/bin/apis/pubsub_demo.rb
  2. 2
      src/ruby/bin/math_client.rb
  3. 2
      src/ruby/bin/noproto_client.rb
  4. 6
      src/ruby/lib/grpc/generic/client_stub.rb
  5. 4
      src/ruby/pb/test/client.rb
  6. 22
      src/ruby/spec/channel_credentials_spec.rb
  7. 2
      src/ruby/spec/channel_spec.rb
  8. 2
      src/ruby/spec/client_server_spec.rb
  9. 2
      src/ruby/spec/generic/client_stub_spec.rb

@ -66,7 +66,7 @@ end
# creates a SSL Credentials from the production certificates.
def ssl_creds
GRPC::Core::Credentials.new(load_prod_cert)
GRPC::Core::ChannelCredentials.new(load_prod_cert)
end
# Builds the metadata authentication update proc.

@ -102,7 +102,7 @@ end
def test_creds
certs = load_test_certs
GRPC::Core::Credentials.new(certs[0])
GRPC::Core::ChannelCredentials.new(certs[0])
end
def main

@ -68,7 +68,7 @@ end
def test_creds
certs = load_test_certs
GRPC::Core::Credentials.new(certs[0])
GRPC::Core::ChannelCredentials.new(certs[0])
end
def main

@ -51,7 +51,9 @@ module GRPC
end
kw['grpc.primary_user_agent'] = "grpc-ruby/#{VERSION}"
return Core::Channel.new(host, kw) if creds.nil?
fail(TypeError, '!Credentials') unless creds.is_a?(Core::Credentials)
unless creds.is_a?(Core::ChannelCredentials)
fail(TypeError, '!ChannelCredentials')
end
Core::Channel.new(host, kw, creds)
end
@ -106,7 +108,7 @@ module GRPC
# @param q [Core::CompletionQueue] used to wait for events
# @param channel_override [Core::Channel] a pre-created channel
# @param timeout [Number] the default timeout to use in requests
# @param creds [Core::Credentials] the channel
# @param creds [Core::ChannelCredentials] the channel credentials
# @param update_metadata a func that updates metadata as described above
# @param kw [KeywordArgs]the channel arguments
def initialize(host, q,

@ -86,13 +86,13 @@ end
# creates SSL Credentials from the test certificates.
def test_creds
certs = load_test_certs
GRPC::Core::Credentials.new(certs[0])
GRPC::Core::ChannelCredentials.new(certs[0])
end
# creates SSL Credentials from the production certificates.
def prod_creds
cert_text = load_prod_cert
GRPC::Core::Credentials.new(cert_text)
GRPC::Core::ChannelCredentials.new(cert_text)
end
# creates the SSL Credentials.

@ -29,8 +29,8 @@
require 'grpc'
describe GRPC::Core::Credentials do
Credentials = GRPC::Core::Credentials
describe GRPC::Core::ChannelCredentials do
ChannelCredentials = GRPC::Core::ChannelCredentials
def load_test_certs
test_root = File.join(File.dirname(__FILE__), 'testdata')
@ -40,32 +40,24 @@ describe GRPC::Core::Credentials do
describe '#new' do
it 'can be constructed with fake inputs' do
expect { Credentials.new('root_certs', 'key', 'cert') }.not_to raise_error
blk = proc { ChannelCredentials.new('root_certs', 'key', 'cert') }
expect(&blk).not_to raise_error
end
it 'it can be constructed using specific test certificates' do
certs = load_test_certs
expect { Credentials.new(*certs) }.not_to raise_error
expect { ChannelCredentials.new(*certs) }.not_to raise_error
end
it 'can be constructed with server roots certs only' do
root_cert, _, _ = load_test_certs
expect { Credentials.new(root_cert) }.not_to raise_error
expect { ChannelCredentials.new(root_cert) }.not_to raise_error
end
it 'cannot be constructed with a nil server roots' do
_, client_key, client_chain = load_test_certs
blk = proc { Credentials.new(nil, client_key, client_chain) }
blk = proc { ChannelCredentials.new(nil, client_key, client_chain) }
expect(&blk).to raise_error
end
end
describe '#compose' do
it 'cannot be completed OK with 2 SSL creds' do
certs = load_test_certs
cred1 = Credentials.new(*certs)
cred2 = Credentials.new(*certs)
expect { cred1.compose(cred2) }.to raise_error
end
end
end

@ -40,7 +40,7 @@ describe GRPC::Core::Channel do
let(:cq) { GRPC::Core::CompletionQueue.new }
def create_test_cert
GRPC::Core::Credentials.new(load_test_certs[0])
GRPC::Core::ChannelCredentials.new(load_test_certs[0])
end
shared_examples '#new' do

@ -431,7 +431,7 @@ describe 'the secure http client/server' do
@server.start
args = { Channel::SSL_TARGET => 'foo.test.google.fr' }
@ch = Channel.new("0.0.0.0:#{server_port}", args,
GRPC::Core::Credentials.new(certs[0], nil, nil))
GRPC::Core::ChannelCredentials.new(certs[0], nil, nil))
end
after(:example) do

@ -113,7 +113,7 @@ describe 'ClientStub' do
opts = {
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
a_channel_arg: 'an_arg',
creds: GRPC::Core::Credentials.new(certs[0], nil, nil)
creds: GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
}
GRPC::ClientStub.new(fake_host, @cq, **opts)
end

Loading…
Cancel
Save