Skip to content

Commit e4db8f0

Browse files
committed
[Client] Updates base_spec for JRuby
1 parent 7fed5fd commit e4db8f0

File tree

1 file changed

+42
-3
lines changed
  • elasticsearch-transport/spec/elasticsearch/transport

1 file changed

+42
-3
lines changed

elasticsearch-transport/spec/elasticsearch/transport/base_spec.rb

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,27 @@
6565
}
6666
end
6767

68-
it_behaves_like 'a redacted string'
68+
if jruby?
69+
let(:client) { Elasticsearch::Transport::Client.new(arguments) }
70+
let(:logger) { double('logger', fatal?: true, fatal: '') }
71+
72+
it 'does not include the password in the logged string' do
73+
expect(logger).not_to receive(:fatal).with(/secret_password/)
74+
75+
expect {
76+
client.cluster.stats
77+
}.to raise_exception(Faraday::SSLError)
78+
end
79+
80+
it 'replaces the password with the string \'REDACTED\'' do
81+
expect(logger).to receive(:fatal).with(/REDACTED/)
82+
expect {
83+
client.cluster.stats
84+
}.to raise_exception(Faraday::SSLError)
85+
end
86+
else
87+
it_behaves_like 'a redacted string'
88+
end
6989
end
7090

7191
context 'when the user and password are provided in the URI object' do
@@ -75,8 +95,27 @@
7595
logger: logger
7696
}
7797
end
78-
79-
it_behaves_like 'a redacted string'
98+
if jruby?
99+
let(:client) { Elasticsearch::Transport::Client.new(arguments) }
100+
let(:logger) { double('logger', fatal?: true, fatal: '') }
101+
102+
it 'does not include the password in the logged string' do
103+
expect(logger).not_to receive(:fatal).with(/secret_password/)
104+
105+
expect {
106+
client.cluster.stats
107+
}.to raise_exception(Faraday::SSLError)
108+
end
109+
110+
it 'replaces the password with the string \'REDACTED\'' do
111+
expect(logger).to receive(:fatal).with(/REDACTED/)
112+
expect {
113+
client.cluster.stats
114+
}.to raise_exception(Faraday::SSLError)
115+
end
116+
else
117+
it_behaves_like 'a redacted string'
118+
end
80119
end
81120
end
82121

0 commit comments

Comments
 (0)