spec/elasticsearch/transport/client_spec.rb in elasticsearch-transport-7.9.0 vs spec/elasticsearch/transport/client_spec.rb in elasticsearch-transport-7.10.0.pre
- old
+ new
@@ -326,11 +326,15 @@
end
context 'when cloud credentials are provided' do
let(:client) do
- described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme')
+ described_class.new(
+ cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
+ user: 'elastic',
+ password: 'changeme'
+ )
end
let(:hosts) do
client.transport.hosts
end
@@ -342,17 +346,24 @@
expect(hosts[0][:password]).to eq('changeme')
expect(hosts[0][:port]).to eq(9243)
end
it 'creates the correct full url' do
- expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elastic:changeme@abcd.localhost:9243')
+ expect(
+ client.transport.__full_url(client.transport.hosts[0])
+ ).to eq('https://elastic:changeme@abcd.localhost:9243')
end
context 'when a port is specified' do
let(:client) do
- described_class.new(cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elastic', password: 'changeme', port: 9200 )
+ described_class.new(
+ cloud_id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
+ user: 'elastic',
+ password: 'changeme',
+ port: 9200
+ )
end
it 'sets the specified port along with the cloud credentials' do
expect(hosts[0][:host]).to eq('abcd.localhost')
expect(hosts[0][:protocol]).to eq('https')
@@ -367,11 +378,15 @@
end
context 'when the cluster has alternate names' do
let(:client) do
- described_class.new(cloud_id: 'myCluster:bG9jYWxob3N0JGFiY2QkZWZnaA==', user: 'elasticfantastic', password: 'tobechanged')
+ described_class.new(
+ cloud_id: 'myCluster:bG9jYWxob3N0JGFiY2QkZWZnaA==',
+ user: 'elasticfantastic',
+ password: 'tobechanged'
+ )
end
let(:hosts) do
client.transport.hosts
end
@@ -383,12 +398,41 @@
expect(hosts[0][:password]).to eq('tobechanged')
expect(hosts[0][:port]).to eq(9243)
end
it 'creates the correct full url' do
- expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://elasticfantastic:tobechanged@abcd.localhost:9243')
+ expect(
+ client.transport.__full_url(client.transport.hosts[0])
+ ).to eq('https://elasticfantastic:tobechanged@abcd.localhost:9243')
end
+ end
+ context 'when decoded cloud id has a trailing dollar sign' do
+ let(:client) do
+ described_class.new(
+ cloud_id: 'a_cluster:bG9jYWxob3N0JGFiY2Qk',
+ user: 'elasticfantastic',
+ password: 'changeme'
+ )
+ end
+
+ let(:hosts) do
+ client.transport.hosts
+ end
+
+ it 'extracts the cloud credentials' do
+ expect(hosts[0][:host]).to eq('abcd.localhost')
+ expect(hosts[0][:protocol]).to eq('https')
+ expect(hosts[0][:user]).to eq('elasticfantastic')
+ expect(hosts[0][:password]).to eq('changeme')
+ expect(hosts[0][:port]).to eq(9243)
+ end
+
+ it 'creates the correct full url' do
+ expect(
+ client.transport.__full_url(client.transport.hosts[0])
+ ).to eq('https://elasticfantastic:changeme@abcd.localhost:9243')
+ end
end
end
shared_examples_for 'a client that extracts hosts' do