Skip to content

Commit 77bc88f

Browse files
committed
[GEM] Handle 413 responses for product check
1 parent 480433e commit 77bc88f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

elasticsearch/lib/elasticsearch.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def verify_elasticsearch
5050
begin
5151
response = elasticsearch_validation_request
5252
rescue Elasticsearch::Transport::Transport::Errors::Unauthorized,
53-
Elasticsearch::Transport::Transport::Errors::Forbidden
53+
Elasticsearch::Transport::Transport::Errors::Forbidden,
54+
Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge
5455
@verified = true
5556
warn(SECURITY_PRIVILEGES_VALIDATION_WARNING)
5657
return

elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,27 @@ def valid_requests_and_expectations
9696
end
9797
end
9898

99+
context 'When Elasticsearch replies with status 403' do
100+
let(:status) { 413 }
101+
let(:body) { {}.to_json }
102+
103+
it 'Verifies the request but shows a warning' do
104+
stderr = $stderr
105+
fake_stderr = StringIO.new
106+
$stderr = fake_stderr
107+
108+
verify_request_stub
109+
count_request_stub
110+
111+
valid_requests_and_expectations
112+
113+
fake_stderr.rewind
114+
expect(fake_stderr.string).to eq("#{Elasticsearch::SECURITY_PRIVILEGES_VALIDATION_WARNING}\n")
115+
ensure
116+
$stderr = stderr
117+
end
118+
end
119+
99120
context 'When the Elasticsearch version is >= 7.14' do
100121
context 'With a valid Elasticsearch response' do
101122
let(:body) { { 'version' => { 'number' => '7.14.0' } }.to_json }

0 commit comments

Comments
 (0)