aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/spec/channel_credentials_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby/spec/channel_credentials_spec.rb')
-rw-r--r--src/ruby/spec/channel_credentials_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ruby/spec/channel_credentials_spec.rb b/src/ruby/spec/channel_credentials_spec.rb
index b2bdf7032e..ecab5dca12 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')
@@ -60,4 +61,32 @@ describe GRPC::Core::ChannelCredentials do
expect(&blk).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