search_flip 4.0.0.beta11 → 4.0.0.beta13

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: 9e032e109a7c31df14182c17d874f793327081c3c4e5b866dbfb261e8aa4e503
4
- data.tar.gz: 73a2ce2eb918e9f3da28f3bf129eb614c1da5492d138985732af4b41a9f15a41
3
+ metadata.gz: 8ab3b545145f3750e38cff9ceacb96680fd3096e77ef0b1e4ae1d661a5783183
4
+ data.tar.gz: 6290f88a3360c2b521e627f3186525ed50eccd40d58a257ed75b68bc01ba0af1
5
5
  SHA512:
6
- metadata.gz: 152130c3a91ae69dcf53ff43534b0b853786900f1c03847ffead4d52254f95aec5dbfb48362d6386a61fdb92f128b68fc22b2b66f4df27f2a099a9d6db356eea
7
- data.tar.gz: '09f13f81114378ebd9dea98ae713f5be8a27dea15966bf2fc05195900be8ed74c73d6aa46d6a458a4d4aaeb8467e32cc4296fce4e22dbfee672a1dc30d4af14f'
6
+ metadata.gz: 5347539030a480f75b46e554f0f850d6ae24fcd1ccee1f6044ad992e330ca8c21ba3fee264a69ed99cc2675a00c35e5d0f842130063eab54cc3082ded8c572f0
7
+ data.tar.gz: 30914f871f515959eb93d70b094bb609c87a74526f00b9f2e2a60c38dc905365be9c786f56d7e7e894230b5f2715c1b5f9f121c0827b947c21ff2a15d56b69a7
data/CHANGELOG.md CHANGED
@@ -11,6 +11,14 @@
11
11
  * Added `SearchFlip::Connection#get_cluster_settings` and
12
12
  `#update_cluster_settings`
13
13
 
14
+ ## v3.7.2
15
+
16
+ * Fix wrong AWS signatures by generating the json before passing it to http-rb
17
+
18
+ ## v3.7.1
19
+
20
+ * Fix thread-safety issue of http-rb
21
+
14
22
  ## v3.7.0
15
23
 
16
24
  * Add `SearchFlip::Connection#bulk` to allow more clean bulk indexing to
@@ -37,7 +37,6 @@ module SearchFlip
37
37
  }
38
38
 
39
39
  signature_request[:body] = options[:body] if options.key?(:body)
40
- signature_request[:body] = options[:json].respond_to?(:to_str) ? options[:json] : JSON.generate(options[:json]) if options[:json]
41
40
 
42
41
  signature = signer.sign_request(signature_request)
43
42
 
@@ -58,8 +58,22 @@ module SearchFlip
58
58
  private
59
59
 
60
60
  def execute(method, uri, options = {})
61
- final_request = plugins.inject(self) { |res, cur| cur.call(res, method, uri, options) }
62
- response = final_request.request.send(method, uri, options)
61
+ opts = options.dup
62
+ final_request = self
63
+
64
+ if opts[:json]
65
+ # Manually generate and pass the json body to http-rb to guarantee that
66
+ # we have the same json which is used for aws signatures and to
67
+ # guarantee that json is always generated as stated in the config
68
+
69
+ opts[:body] = JSON.generate(opts.delete(:json))
70
+ final_request = final_request.headers(content_type: "application/json")
71
+ end
72
+
73
+ final_request = plugins.inject(final_request) { |res, cur| cur.call(res, method, uri, opts) }
74
+ final_request = final_request.headers({}) # Prevent thread-safety issue of http-rb: https://github.com/httprb/http/issues/558
75
+
76
+ response = final_request.request.send(method, uri, opts)
63
77
 
64
78
  raise SearchFlip::ResponseError.new(code: response.code, body: response.body.to_s) unless response.status.success?
65
79
 
@@ -1,3 +1,3 @@
1
1
  module SearchFlip
2
- VERSION = "4.0.0.beta11"
2
+ VERSION = "4.0.0.beta13"
3
3
  end
@@ -29,15 +29,17 @@ RSpec.describe SearchFlip::AwsSigv4Plugin do
29
29
  end
30
30
 
31
31
  it "feeds the http method, full url and body to the signer" do
32
+ body = JSON.generate(key: "value")
33
+
32
34
  signing_request = {
33
35
  http_method: "GET",
34
36
  url: "http://localhost/index?param=value",
35
- body: JSON.generate(key: "value")
37
+ body: body
36
38
  }
37
39
 
38
40
  expect(plugin.signer).to receive(:sign_request).with(signing_request).and_call_original
39
41
 
40
- plugin.call(client, :get, "http://localhost/index", params: { param: "value" }, json: { key: "value" })
42
+ plugin.call(client, :get, "http://localhost/index", params: { param: "value" }, body: body)
41
43
  end
42
44
  end
43
45
  end
@@ -36,6 +36,12 @@ RSpec.describe SearchFlip::HTTPClient do
36
36
 
37
37
  expect(SearchFlip::HTTPClient.new.send(method, "http://localhost/path", body: "body", params: { key: "value" }).body.to_s).to eq("success")
38
38
  end
39
+
40
+ it "generates json, passes it as body and sets the content type when the json option is used" do
41
+ stub_request(method, "http://localhost/path").with(body: '{"key":"value"}', headers: { "Content-Type" => "application/json" }).to_return(body: "success")
42
+
43
+ expect(SearchFlip::HTTPClient.new.send(method, "http://localhost/path", json: { "key" => "value" }).body.to_s).to eq("success")
44
+ end
39
45
  end
40
46
  end
41
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta11
4
+ version: 4.0.0.beta13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-27 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord