1# Copyright 2015 gRPC authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require 'spec_helper'
16
17describe GRPC::Core::CallCredentials do
18  CallCredentials = GRPC::Core::CallCredentials
19
20  let(:auth_proc) { proc { { 'plugin_key' => 'plugin_value' } } }
21
22  describe '#new' do
23    it 'can successfully create a CallCredentials from a proc' do
24      expect { CallCredentials.new(auth_proc) }.not_to raise_error
25    end
26  end
27
28  describe '#compose' do
29    it 'can compose with another CallCredentials' do
30      creds1 = CallCredentials.new(auth_proc)
31      creds2 = CallCredentials.new(auth_proc)
32      expect { creds1.compose creds2 }.not_to raise_error
33    end
34
35    it 'can compose with multiple CallCredentials' do
36      creds1 = CallCredentials.new(auth_proc)
37      creds2 = CallCredentials.new(auth_proc)
38      creds3 = CallCredentials.new(auth_proc)
39      expect { creds1.compose(creds2, creds3) }.not_to raise_error
40    end
41  end
42end
43