bootic_client 0.0.24 → 0.0.25

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: 34a1f5f52be0931537722e1a90599316a94fc25a
4
- data.tar.gz: 994665adf0866edd214518729480b3ee3689cd6c
3
+ metadata.gz: cd25c5f81c531e803321755d311bf34fc4085870
4
+ data.tar.gz: 98dd11f9b4574dd18312d1c74cc720b72af756ab
5
5
  SHA512:
6
- metadata.gz: 3d786e2494e082587bbb684a0a7b078b2f6c43e3b3ba55d8b07c5a929b7deaf47db16a6a122e71574e64dfdaae8331edd39492ff38567f8fa48b078ac8d1820e
7
- data.tar.gz: a9a3950497449be5c852b9bc4e4cc99a001e81084cc78ac5f7abc3c8acd924c86326ab768e5fcb4ebdca1021a3adbebaf81b2606e14961ba547254d0d55e70e0
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)
@@ -59,14 +59,21 @@ module BooticClient
59
59
  end
60
60
  end
61
61
 
62
- class UTF8JSON
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].force_encoding('UTF-8') if data[:body].is_a?(String)
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: UTF8JSON, shared_cache: false, store: options[:cache_store]}
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
@@ -1,3 +1,3 @@
1
1
  module BooticClient
2
- VERSION = "0.0.24".freeze
2
+ VERSION = "0.0.25".freeze
3
3
  end
@@ -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.24
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-05-07 00:00:00.000000000 Z
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