diff options
Diffstat (limited to 'src/ruby/spec/channel_credentials_spec.rb')
-rw-r--r-- | src/ruby/spec/channel_credentials_spec.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/ruby/spec/channel_credentials_spec.rb b/src/ruby/spec/channel_credentials_spec.rb index b2bdf7032e..0bcfc752a0 100644 --- a/src/ruby/spec/channel_credentials_spec.rb +++ b/src/ruby/spec/channel_credentials_spec.rb @@ -31,6 +31,7 @@ require 'grpc' describe GRPC::Core::ChannelCredentials do ChannelCredentials = GRPC::Core::ChannelCredentials + CallCredentials = GRPC::Core::CallCredentials def load_test_certs test_root = File.join(File.dirname(__FILE__), 'testdata') @@ -54,10 +55,43 @@ describe GRPC::Core::ChannelCredentials do expect { ChannelCredentials.new(root_cert) }.not_to raise_error end - it 'cannot be constructed with a nil server roots' do + it 'can be constructed with a nil server roots' do _, client_key, client_chain = load_test_certs blk = proc { ChannelCredentials.new(nil, client_key, client_chain) } - expect(&blk).to raise_error + expect(&blk).not_to raise_error + end + + it 'can be constructed with no params' do + blk = proc { ChannelCredentials.new(nil) } + expect(&blk).not_to raise_error + end + end + + describe '#compose' do + it 'can compose with a CallCredentials' do + certs = load_test_certs + channel_creds = ChannelCredentials.new(*certs) + auth_proc = proc { { 'plugin_key' => 'plugin_value' } } + call_creds = CallCredentials.new auth_proc + expect { channel_creds.compose call_creds }.not_to raise_error + end + + it 'can compose with multiple CallCredentials' do + certs = load_test_certs + channel_creds = ChannelCredentials.new(*certs) + auth_proc = proc { { 'plugin_key' => 'plugin_value' } } + call_creds1 = CallCredentials.new auth_proc + call_creds2 = CallCredentials.new auth_proc + expect do + channel_creds.compose(call_creds1, call_creds2) + end.not_to raise_error + end + + it 'cannot compose with ChannelCredentials' do + certs = load_test_certs + channel_creds1 = ChannelCredentials.new(*certs) + channel_creds2 = ChannelCredentials.new(*certs) + expect { channel_creds1.compose channel_creds2 }.to raise_error(TypeError) end end end |