search_flip 3.7.1 → 3.7.2
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: d8c5d0e833c92cf4584fe620634d0c2633cc82248a5cae91c256799d280057f5
|
4
|
+
data.tar.gz: 62f5f4944c3a1dc823f75f9bcede05c69ab103d19ae19cfec8f3c518a3829723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5480c57d7d814d96903aab184a82831d4f78d3613249eb8c6951992deaf873bba00ee3d5f8053050775973ac70cb2fc4665b7b15503634b53e853b8d0c29b198
|
7
|
+
data.tar.gz: 648f80a25a38e6ec50ab3ecec25a4b6dee92902804c6ee82409d7084c27527cea9788458f5e674dcbf2d0eea5aef401a13e3f1a3b23bd2e6ef1c5659e3a915d3
|
data/CHANGELOG.md
CHANGED
@@ -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,9 +58,22 @@ module SearchFlip
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def execute(method, uri, options = {})
|
61
|
-
|
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) }
|
62
74
|
final_request = final_request.headers({}) # Prevent thread-safety issue of http-rb: https://github.com/httprb/http/issues/558
|
63
|
-
|
75
|
+
|
76
|
+
response = final_request.request.send(method, uri, opts)
|
64
77
|
|
65
78
|
raise SearchFlip::ResponseError.new(code: response.code, body: response.body.to_s) unless response.status.success?
|
66
79
|
|
data/lib/search_flip/version.rb
CHANGED
@@ -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:
|
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" },
|
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: 3.7.
|
4
|
+
version: 3.7.2
|
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-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|