diff --git a/elasticsearch/lib/elasticsearch.rb b/elasticsearch/lib/elasticsearch.rb index d476edbb4e..6dfe765ecb 100644 --- a/elasticsearch/lib/elasticsearch.rb +++ b/elasticsearch/lib/elasticsearch.rb @@ -50,7 +50,8 @@ def verify_elasticsearch begin response = elasticsearch_validation_request rescue Elasticsearch::Transport::Transport::Errors::Unauthorized, - Elasticsearch::Transport::Transport::Errors::Forbidden + Elasticsearch::Transport::Transport::Errors::Forbidden, + Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge @verified = true warn(SECURITY_PRIVILEGES_VALIDATION_WARNING) return diff --git a/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb b/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb index 9bb367edbd..1648111cb0 100644 --- a/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb +++ b/elasticsearch/spec/unit/elasticsearch_product_validation_spec.rb @@ -96,6 +96,27 @@ def valid_requests_and_expectations end end + context 'When Elasticsearch replies with status 403' do + let(:status) { 413 } + let(:body) { {}.to_json } + + it 'Verifies the request but shows a warning' do + stderr = $stderr + fake_stderr = StringIO.new + $stderr = fake_stderr + + verify_request_stub + count_request_stub + + valid_requests_and_expectations + + fake_stderr.rewind + expect(fake_stderr.string).to eq("#{Elasticsearch::SECURITY_PRIVILEGES_VALIDATION_WARNING}\n") + ensure + $stderr = stderr + end + end + context 'When the Elasticsearch version is >= 7.14' do context 'With a valid Elasticsearch response' do let(:body) { { 'version' => { 'number' => '7.14.0' } }.to_json }