Skip to content
Snippets Groups Projects
Commit 43a7e4e6 authored by Tim Emiola's avatar Tim Emiola
Browse files

Ruby wrapping of core credentials API change.

parent 9332ea6a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment