bootic_client 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -2
- data/lib/bootic_client/client.rb +11 -4
- data/lib/bootic_client/version.rb +1 -1
- data/spec/safe_cache_serializer_spec.rb +32 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd25c5f81c531e803321755d311bf34fc4085870
|
4
|
+
data.tar.gz: 98dd11f9b4574dd18312d1c74cc720b72af756ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92f2be1137f77c506327f372c04d20cd2875f9776cb4747b0cd2b2374efe03c61edab6810c59120fa0463572c7ac2659967ecfb8c6fb02230124cd2779b04001
|
7
|
+
data.tar.gz: 80e85f49f20396b049d463988016c3bde5b4d88120d3b0769e4bfe4cd3e5fc2e1452684333f3503844cd4056e0fec45b7d4039f0ffe18a0497e659cbb16e39b2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/bootic/bootic_client.rb/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.24...HEAD)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Make HTTP cache serialize binary data \(ex. images\) safely [\#21](https://github.com/bootic/bootic_client.rb/pull/21) ([ismasan](https://github.com/ismasan))
|
10
|
+
|
11
|
+
## [v0.0.24](https://github.com/bootic/bootic_client.rb/tree/v0.0.24) (2019-05-07)
|
12
|
+
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.23...v0.0.24)
|
13
|
+
|
14
|
+
**Merged pull requests:**
|
15
|
+
|
16
|
+
- Update gems, fix HTTP cache [\#20](https://github.com/bootic/bootic_client.rb/pull/20) ([ismasan](https://github.com/ismasan))
|
17
|
+
|
18
|
+
## [v0.0.23](https://github.com/bootic/bootic_client.rb/tree/v0.0.23) (2019-05-04)
|
19
|
+
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.22...v0.0.23)
|
20
|
+
|
3
21
|
## [v0.0.22](https://github.com/bootic/bootic_client.rb/tree/v0.0.22) (2019-05-04)
|
4
22
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.21...v0.0.22)
|
5
23
|
|
@@ -12,6 +30,10 @@
|
|
12
30
|
## [v0.0.21](https://github.com/bootic/bootic_client.rb/tree/v0.0.21) (2018-08-30)
|
13
31
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.20...v0.0.21)
|
14
32
|
|
33
|
+
**Merged pull requests:**
|
34
|
+
|
35
|
+
- Add :user\_agent option [\#13](https://github.com/bootic/bootic_client.rb/pull/13) ([ismasan](https://github.com/ismasan))
|
36
|
+
|
15
37
|
## [v0.0.20](https://github.com/bootic/bootic_client.rb/tree/v0.0.20) (2018-07-05)
|
16
38
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.19...v0.0.20)
|
17
39
|
|
@@ -53,7 +75,6 @@
|
|
53
75
|
|
54
76
|
**Merged pull requests:**
|
55
77
|
|
56
|
-
- Add :user\_agent option [\#13](https://github.com/bootic/bootic_client.rb/pull/13) ([ismasan](https://github.com/ismasan))
|
57
78
|
- Base64-encode any attribute that responds to \#read [\#7](https://github.com/bootic/bootic_client.rb/pull/7) ([ismasan](https://github.com/ismasan))
|
58
79
|
|
59
80
|
## [v0.0.14](https://github.com/bootic/bootic_client.rb/tree/v0.0.14) (2016-04-26)
|
@@ -73,6 +94,10 @@
|
|
73
94
|
## [v0.0.12](https://github.com/bootic/bootic_client.rb/tree/v0.0.12) (2016-01-11)
|
74
95
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.11...v0.0.12)
|
75
96
|
|
97
|
+
**Merged pull requests:**
|
98
|
+
|
99
|
+
- Faraday http cache 1.2.2, Vary header support. [\#4](https://github.com/bootic/bootic_client.rb/pull/4) ([ismasan](https://github.com/ismasan))
|
100
|
+
|
76
101
|
## [v0.0.11](https://github.com/bootic/bootic_client.rb/tree/v0.0.11) (2015-10-28)
|
77
102
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.10...v0.0.11)
|
78
103
|
|
@@ -91,7 +116,6 @@
|
|
91
116
|
|
92
117
|
**Merged pull requests:**
|
93
118
|
|
94
|
-
- Faraday http cache 1.2.2, Vary header support. [\#4](https://github.com/bootic/bootic_client.rb/pull/4) ([ismasan](https://github.com/ismasan))
|
95
119
|
- Basic auth strategy [\#2](https://github.com/bootic/bootic_client.rb/pull/2) ([ismasan](https://github.com/ismasan))
|
96
120
|
|
97
121
|
## [v0.0.7](https://github.com/bootic/bootic_client.rb/tree/v0.0.7) (2015-03-07)
|
data/lib/bootic_client/client.rb
CHANGED
@@ -59,14 +59,21 @@ module BooticClient
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
class
|
62
|
+
class SafeCacheSerializer
|
63
|
+
PREFIX = '__booticclient__base64__:'.freeze
|
64
|
+
PREFIX_EXP = %r{^#{PREFIX}}.freeze
|
65
|
+
|
63
66
|
def self.dump(data)
|
64
|
-
data[:body] = data[:body]
|
67
|
+
data[:body] = "#{PREFIX}#{Base64.strict_encode64(data[:body])}" if data[:body].is_a?(String)
|
65
68
|
JSON.dump(data)
|
66
69
|
end
|
67
70
|
|
68
71
|
def self.load(string)
|
69
|
-
JSON.load(string)
|
72
|
+
data = JSON.load(string)
|
73
|
+
if data['body'] =~ PREFIX_EXP
|
74
|
+
data['body'] = Base64.strict_decode64(data['body'].sub(PREFIX, ''))
|
75
|
+
end
|
76
|
+
data
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
@@ -74,7 +81,7 @@ module BooticClient
|
|
74
81
|
|
75
82
|
def conn(&block)
|
76
83
|
@conn ||= Faraday.new do |f|
|
77
|
-
cache_options = {serializer:
|
84
|
+
cache_options = {serializer: SafeCacheSerializer, shared_cache: false, store: options[:cache_store]}
|
78
85
|
cache_options[:logger] = options[:logger] if options[:logging]
|
79
86
|
|
80
87
|
f.use :http_cache, cache_options
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BooticClient::Client::SafeCacheSerializer do
|
4
|
+
context 'deserializing existing non-base64 content' do
|
5
|
+
it 'does not attempt Base64 decoding' do
|
6
|
+
result = described_class.load('{"headers": {"foo": 1}, "body": "hello"}')
|
7
|
+
expect(result['body']).to eq 'hello'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'Base64-encoding and decoding' do
|
12
|
+
it 'decodes body if flagged as Base64' do
|
13
|
+
body = Base64.strict_encode64('hello')
|
14
|
+
encoded = %({"headers": {"foo": 1}, "body": "__booticclient__base64__:#{body}"})
|
15
|
+
result = described_class.load(encoded)
|
16
|
+
expect(result['body']).to eq 'hello'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'encodes as Base64 with flag prefix' do
|
20
|
+
data = Base64.strict_encode64('{"headers": {"foo": 1}, "body": "hello"}')
|
21
|
+
encoded = described_class.dump({headers: {foo: 1}, body: 'hello'})
|
22
|
+
parsed = JSON.load(encoded)
|
23
|
+
expect(parsed['body']).to eq "__booticclient__base64__:#{Base64.strict_encode64('hello')}"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'encodes and decodes' do
|
27
|
+
encoded = described_class.dump({headers: {foo: 1}, body: 'hello'})
|
28
|
+
decoded = described_class.load(encoded)
|
29
|
+
expect(decoded['body']).to eq 'hello'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootic_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- spec/memcache_storage_spec.rb
|
198
198
|
- spec/relation_spec.rb
|
199
199
|
- spec/response_handlers_spec.rb
|
200
|
+
- spec/safe_cache_serializer_spec.rb
|
200
201
|
- spec/spec_helper.rb
|
201
202
|
- spec/strategy_spec.rb
|
202
203
|
- spec/whiny_uri_spec.rb
|
@@ -237,6 +238,7 @@ test_files:
|
|
237
238
|
- spec/memcache_storage_spec.rb
|
238
239
|
- spec/relation_spec.rb
|
239
240
|
- spec/response_handlers_spec.rb
|
241
|
+
- spec/safe_cache_serializer_spec.rb
|
240
242
|
- spec/spec_helper.rb
|
241
243
|
- spec/strategy_spec.rb
|
242
244
|
- spec/whiny_uri_spec.rb
|