elasticsearch-transport 5.0.4 → 5.0.5

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
  SHA1:
3
- metadata.gz: 44170b2419c63a6ab5d33557fa3d49a7efede792
4
- data.tar.gz: 59ec164cf8865491cf0e4c59628d62ce5a9a0dd2
3
+ metadata.gz: 9141220bdecbb5cd5fe9eef893010d24419a62a6
4
+ data.tar.gz: e2a2ad61469a9398e749b4004909ec2234360262
5
5
  SHA512:
6
- metadata.gz: a12ea012f3a6b64322a8542dc21af3cc6ad2c5774c7a632246b429ca0bcfa212c0c9d8ce8925210e403284c612fff5ac037c084e02b297b4439bc75cc6d99ec5
7
- data.tar.gz: a9bc5d3679d9ca6925f2e6b45e1961fa879865978b0f10a25edf41b4eda101515393ff10f420996b7796ec50c9ad91c0cf8ebee0665153867e729fc1adbd27f6
6
+ metadata.gz: 47916a61140347aba5eb71728587d4c611f0219e8f03d3584405fde93d10fe991f38652b5125e073ad37f16cedd72fe452faea82197f892b539c95809db5cf74
7
+ data.tar.gz: 9130c01c4a9d7687f42fa57848c3dac0ae7382972e1c68776319c829b079307ccda469846f6231e2e64c783225c43a75386d35b6de8f3d5614516266d24e80c8
@@ -181,6 +181,9 @@ module Elasticsearch
181
181
  @arguments[:http][k] ||= v
182
182
  end
183
183
 
184
+ # Remove the trailing slash
185
+ host_parts[:path].chomp!('/') if host_parts[:path]
186
+
184
187
  host_parts
185
188
  end
186
189
 
@@ -39,7 +39,7 @@ module Elasticsearch
39
39
  #
40
40
  def full_url(path, params={})
41
41
  url = "#{host[:protocol]}://"
42
- url += "#{host[:user]}:#{host[:password]}@" if host[:user]
42
+ url += "#{CGI.escape(host[:user])}:#{CGI.escape(host[:password])}@" if host[:user]
43
43
  url += "#{host[:host]}:#{host[:port]}"
44
44
  url += "#{host[:path]}" if host[:path]
45
45
  url += "/#{full_path(path, params)}"
@@ -21,7 +21,10 @@ module Elasticsearch
21
21
 
22
22
  case method
23
23
  when 'HEAD'
24
+ connection.connection.set :nobody, true
24
25
  when 'GET', 'POST', 'PUT', 'DELETE'
26
+ connection.connection.set :nobody, false
27
+
25
28
  connection.connection.put_data = __convert_to_json(body) if body
26
29
  else raise ArgumentError, "Unsupported HTTP method: #{method}"
27
30
  end
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module Transport
3
- VERSION = "5.0.4"
3
+ VERSION = "5.0.5"
4
4
  end
5
5
  end
@@ -2,11 +2,11 @@ require 'test_helper'
2
2
 
3
3
  class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
4
4
  startup do
5
- Elasticsearch::Extensions::Test::Cluster.start(nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
5
+ Elasticsearch::Extensions::Test::Cluster.start(number_of_nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
6
6
  end
7
7
 
8
8
  shutdown do
9
- Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running?
9
+ Elasticsearch::Extensions::Test::Cluster.stop(number_of_nodes: 2) if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
10
10
  end
11
11
 
12
12
  context "Elasticsearch client" do
@@ -2,11 +2,11 @@ require 'test_helper'
2
2
 
3
3
  class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::IntegrationTestCase
4
4
  startup do
5
- Elasticsearch::Extensions::Test::Cluster.start(nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
5
+ Elasticsearch::Extensions::Test::Cluster.start(number_of_nodes: 2) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
6
6
  end
7
7
 
8
8
  shutdown do
9
- Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running?
9
+ Elasticsearch::Extensions::Test::Cluster.stop(number_of_nodes: 2) if ENV['SERVER'] and Elasticsearch::Extensions::Test::Cluster.running?(number_of_nodes: 2)
10
10
  end
11
11
 
12
12
  context "Transport" do
@@ -228,6 +228,14 @@ class Elasticsearch::Transport::ClientTest < Test::Unit::TestCase
228
228
  assert_equal 'bar', hosts[1][:host]
229
229
  end
230
230
 
231
+ should "remove trailing slash from URL path" do
232
+ hosts = @client.__extract_hosts 'http://myhost/'
233
+ assert_equal '', hosts[0][:path]
234
+
235
+ hosts = @client.__extract_hosts 'http://myhost/foo/bar/'
236
+ assert_equal '/foo/bar', hosts[0][:path]
237
+ end
238
+
231
239
  should "raise error for incompatible argument" do
232
240
  assert_raise ArgumentError do
233
241
  @client.__extract_hosts 123
@@ -30,6 +30,11 @@ class Elasticsearch::Transport::Transport::Connections::ConnectionTest < Test::U
30
30
  assert_equal 'http://U:P@localhost:9200/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
31
31
  end
32
32
 
33
+ should "return full url with escaped credentials" do
34
+ c = Connection.new :host => { :protocol => 'http', :user => 'U$$$', :password => 'P^^^', :host => 'localhost', :port => '9200' }
35
+ assert_equal 'http://U%24%24%24:P%5E%5E%5E@localhost:9200/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
36
+ end
37
+
33
38
  should "return full url with path" do
34
39
  c = Connection.new :host => { :protocol => 'http', :host => 'localhost', :port => '9200', :path => '/foo' }
35
40
  assert_equal 'http://localhost:9200/foo/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -415,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
415
  version: '0'
416
416
  requirements: []
417
417
  rubyforge_project:
418
- rubygems_version: 2.6.10
418
+ rubygems_version: 2.6.11
419
419
  signing_key:
420
420
  specification_version: 4
421
421
  summary: Ruby client for Elasticsearch.