elasticsearch 7.16.1 → 7.17.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9403b07ac2419ebe981f7434c53a6751ff895869250c9cfee72d39b498e19da6
|
4
|
+
data.tar.gz: 8ba7804340871f3c01eb2a8bcb4ad381231b3a000cc086b5c8e0f53a003a9972
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0ceede38bba023ed0c92eec140bb031ca4ef023586c01d002217fbaa4dc19e56c362b2d28994183676b539722a8f852fbf834fdd8bf5b62f0f509aa8382a951
|
7
|
+
data.tar.gz: 73e57f061914f521699f7e270456ef8e1879b53846225ffc0e6c6c83a91637feb410541f690e018d14db46185149507cb51cc0ca5dfb57d1730e34adda1e0a1e
|
data/elasticsearch.gemspec
CHANGED
@@ -45,8 +45,8 @@ Gem::Specification.new do |s|
|
|
45
45
|
|
46
46
|
s.required_ruby_version = '>= 2.4'
|
47
47
|
|
48
|
-
s.add_dependency 'elasticsearch-transport', '7.
|
49
|
-
s.add_dependency 'elasticsearch-api', '7.
|
48
|
+
s.add_dependency 'elasticsearch-transport', '7.17.1'
|
49
|
+
s.add_dependency 'elasticsearch-api', '7.17.1'
|
50
50
|
|
51
51
|
s.add_development_dependency 'bundler'
|
52
52
|
s.add_development_dependency 'byebug' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
data/lib/elasticsearch.rb
CHANGED
@@ -50,7 +50,8 @@ module Elasticsearch
|
|
50
50
|
begin
|
51
51
|
response = elasticsearch_validation_request
|
52
52
|
rescue Elasticsearch::Transport::Transport::Errors::Unauthorized,
|
53
|
-
Elasticsearch::Transport::Transport::Errors::Forbidden
|
53
|
+
Elasticsearch::Transport::Transport::Errors::Forbidden,
|
54
|
+
Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge
|
54
55
|
@verified = true
|
55
56
|
warn(SECURITY_PRIVILEGES_VALIDATION_WARNING)
|
56
57
|
return
|
@@ -58,7 +59,7 @@ module Elasticsearch
|
|
58
59
|
|
59
60
|
body = if response.headers['content-type'] == 'application/yaml'
|
60
61
|
require 'yaml'
|
61
|
-
YAML.
|
62
|
+
YAML.safe_load(response.body)
|
62
63
|
else
|
63
64
|
response.body
|
64
65
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
|
18
|
+
raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
context 'Elasticsearch client' do
|
23
|
+
let(:client) do
|
24
|
+
Elasticsearch::Client.new(host: ELASTICSEARCH_URL, user: 'elastic', password: 'changeme')
|
25
|
+
end
|
26
|
+
let(:index) { 'tvs' }
|
27
|
+
|
28
|
+
after do
|
29
|
+
client.indices.delete(index: index)
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'escaping spaces in ids' do
|
33
|
+
it 'escapes spaces for id when using index' do
|
34
|
+
response = client.index(index: index, id: 'a test 1', body: { name: 'A test 1' }, refresh: true)
|
35
|
+
expect(response['_id']).to eq 'a test 1'
|
36
|
+
|
37
|
+
response = client.search(index: index)
|
38
|
+
expect(response['hits']['hits'].first['_id']).to eq 'a test 1'
|
39
|
+
|
40
|
+
# Raises exception, _id is unrecognized
|
41
|
+
expect do
|
42
|
+
client.index(index: index, _id: 'a test 2', body: { name: 'A test 2' })
|
43
|
+
end.to raise_exception ArgumentError
|
44
|
+
|
45
|
+
# Raises exception, id is a query parameter
|
46
|
+
expect do
|
47
|
+
client.index(index: index, body: { name: 'A test 3', _id: 'a test 3' })
|
48
|
+
end.to raise_exception Elasticsearch::Transport::Transport::Errors::BadRequest
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'escapes spaces for id when using create' do
|
52
|
+
# Works with create
|
53
|
+
response = client.create(index: index, id: 'a test 4', body: { name: 'A test 4' })
|
54
|
+
expect(response['_id']).to eq 'a test 4'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'escapes spaces for id when using bulk' do
|
58
|
+
body = [
|
59
|
+
{ create: { _index: index, _id: 'a test 5', data: { name: 'A test 5' } } }
|
60
|
+
]
|
61
|
+
expect(client.bulk(body: body, refresh: true))
|
62
|
+
|
63
|
+
response = client.search(index: index)
|
64
|
+
expect(
|
65
|
+
response['hits']['hits'].select { |a| a['_id'] == 'a test 5' }.size
|
66
|
+
).to eq 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'it doesnae escape plus signs in id' do
|
71
|
+
it 'escapes spaces for id when using index' do
|
72
|
+
response = client.index(index: index, id: 'a+test+1', body: { name: 'A test 1' })
|
73
|
+
expect(response['_id']).to eq 'a+test+1'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'escapes spaces for id when using create' do
|
77
|
+
# Works with create
|
78
|
+
response = client.create(index: index, id: 'a+test+2', body: { name: 'A test 2' })
|
79
|
+
expect(response['_id']).to eq 'a+test+2'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'escapes spaces for id when using bulk' do
|
83
|
+
body = [
|
84
|
+
{ create: { _index: index, _id: 'a+test+3', data: { name: 'A test 3' } } }
|
85
|
+
]
|
86
|
+
expect(client.bulk(body: body, refresh: true))
|
87
|
+
|
88
|
+
response = client.search(index: index)
|
89
|
+
expect(
|
90
|
+
response['hits']['hits'].select { |a| a['_id'] == 'a+test+3' }.size
|
91
|
+
).to eq 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -96,6 +96,27 @@ describe 'Elasticsearch: Validation' do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
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
|
+
|
99
120
|
context 'When the Elasticsearch version is >= 7.14' do
|
100
121
|
context 'With a valid Elasticsearch response' do
|
101
122
|
let(:body) { { 'version' => { 'number' => '7.14.0' } }.to_json }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch-transport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.
|
19
|
+
version: 7.17.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.
|
26
|
+
version: 7.17.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: elasticsearch-api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 7.
|
33
|
+
version: 7.17.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 7.
|
40
|
+
version: 7.17.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,6 +200,7 @@ files:
|
|
200
200
|
- lib/elasticsearch-ruby.rb
|
201
201
|
- lib/elasticsearch.rb
|
202
202
|
- lib/elasticsearch/version.rb
|
203
|
+
- spec/integration/characters_escaping_spec.rb
|
203
204
|
- spec/integration/client_integration_spec.rb
|
204
205
|
- spec/integration/validation_integration_spec.rb
|
205
206
|
- spec/spec_helper.rb
|
@@ -229,11 +230,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
230
|
- !ruby/object:Gem::Version
|
230
231
|
version: '0'
|
231
232
|
requirements: []
|
232
|
-
rubygems_version: 3.
|
233
|
+
rubygems_version: 3.3.3
|
233
234
|
signing_key:
|
234
235
|
specification_version: 4
|
235
236
|
summary: Ruby integrations for Elasticsearch
|
236
237
|
test_files:
|
238
|
+
- spec/integration/characters_escaping_spec.rb
|
237
239
|
- spec/integration/client_integration_spec.rb
|
238
240
|
- spec/integration/validation_integration_spec.rb
|
239
241
|
- spec/spec_helper.rb
|