Commit 08a57fe8 authored by Ahmad Hassan's avatar Ahmad Hassan

Add more specs

parent e2cb9245
......@@ -429,7 +429,6 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
# Gitaly
#
Settings['gitaly'] ||= Settingslogic.new({})
Settings.gitaly['tls'] ||= Settingslogic.new({})
#
# Webpack settings
......
......@@ -53,10 +53,6 @@ module Gitlab
base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil)
end
def self.creds
Gitlab.config.gitaly.tls.credentials
end
def self.stub(name, storage)
MUTEX.synchronize do
@stubs ||= {}
......@@ -72,7 +68,7 @@ module Gitlab
def self.stub_creds(storage)
if URI(address(storage)).scheme == 'tls'
GRPC::Code::ChannelCredentials.new
GRPC::Core::ChannelCredentials.new
else
:this_channel_is_insecure
end
......
......@@ -28,6 +28,24 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
end
end
describe '.stub_creds' do
it 'returns :this_channel_is_insecure if tcp' do
address = 'tcp://localhost:9876'
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'default' => { 'gitaly_address' => address }
})
expect(described_class.stub_creds('default')).to eq(:this_channel_is_insecure)
end
it 'returns Credentials object if tls' do
address = 'tls://localhost:9876'
allow(Gitlab.config.repositories).to receive(:storages).and_return({
'default' => { 'gitaly_address' => address }
})
expect(described_class.stub_creds('default')).to be_a(GRPC::Core::ChannelCredentials)
end
end
describe '.stub' do
# Notice that this is referring to gRPC "stubs", not rspec stubs
before do
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment