spec/elasticsearch/transport/base_spec.rb in elasticsearch-transport-7.13.3 vs spec/elasticsearch/transport/base_spec.rb in elasticsearch-transport-7.14.0.pre
- old
+ new
@@ -30,18 +30,18 @@
it 'does not include the password in the logged string' do
expect(logger).not_to receive(:error).with(/secret_password/)
expect {
- client.cluster.stats
+ client.perform_request('GET', '_cluster/stats')
}.to raise_exception(Faraday::ConnectionFailed)
end
it 'replaces the password with the string \'REDACTED\'' do
expect(logger).to receive(:error).with(/REDACTED/)
expect {
- client.cluster.stats
+ client.perform_request('GET', '_cluster/stats')
}.to raise_exception(Faraday::ConnectionFailed)
end
end
context 'when the user and password are provided as separate arguments' do
@@ -63,22 +63,61 @@
hosts: 'https://test:secret_password@fake_local_elasticsearch',
logger: logger
}
end
- it_behaves_like 'a redacted string'
+ if jruby?
+ let(:client) { Elasticsearch::Transport::Client.new(arguments) }
+ let(:logger) { double('logger', fatal?: true, fatal: '') }
+
+ it 'does not include the password in the logged string' do
+ expect(logger).not_to receive(:fatal).with(/secret_password/)
+
+ expect {
+ client.perform_request('GET', '_cluster/stats')
+ }.to raise_exception(Faraday::SSLError)
+ end
+
+ it 'replaces the password with the string \'REDACTED\'' do
+ expect(logger).to receive(:fatal).with(/REDACTED/)
+ expect {
+ client.perform_request('GET', '_cluster/stats')
+ }.to raise_exception(Faraday::SSLError)
+ end
+ else
+ it_behaves_like 'a redacted string'
+ end
end
context 'when the user and password are provided in the URI object' do
let(:arguments) do
{
hosts: URI.parse('https://test:secret_password@fake_local_elasticsearch'),
logger: logger
}
end
+ if jruby?
+ let(:client) { Elasticsearch::Transport::Client.new(arguments) }
+ let(:logger) { double('logger', fatal?: true, fatal: '') }
- it_behaves_like 'a redacted string'
+ it 'does not include the password in the logged string' do
+ expect(logger).not_to receive(:fatal).with(/secret_password/)
+
+ expect {
+ client.perform_request('GET', '_cluster/stats')
+ }.to raise_exception(Faraday::SSLError)
+ end
+
+ it 'replaces the password with the string \'REDACTED\'' do
+ expect(logger).to receive(:fatal).with(/REDACTED/)
+ expect {
+ client.perform_request('GET', '_cluster/stats')
+ }.to raise_exception(Faraday::SSLError)
+ end
+ else
+ it_behaves_like 'a redacted string'
+ end
end
end
context 'when reload_on_failure is true and and hosts are unreachable' do
let(:client) do
@@ -92,11 +131,11 @@
sniffer_timeout: 5
}
end
it 'raises an exception' do
- expect { client.info }.to raise_exception(Faraday::ConnectionFailed)
+ expect { client.perform_request('GET', '/') }.to raise_exception(Faraday::ConnectionFailed)
end
end
context 'when the client has `retry_on_failure` set to an integer' do
let(:client) do
@@ -127,10 +166,10 @@
expect(client.transport).to receive(:__raise_transport_error).exactly(6).times.and_call_original
end
let(:arguments) do
{
- hosts: ['http://localhost:9250'],
+ hosts: ELASTICSEARCH_HOSTS,
retry_on_status: ['404']
}
end
it 'retries on 404 status the specified number of max_retries' do