bootic_client 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -9
- data/bootic_client.gemspec +1 -1
- data/lib/bootic_client/strategies/authorized.rb +3 -2
- data/lib/bootic_client/version.rb +1 -1
- data/spec/authorized_strategy_spec.rb +4 -4
- data/spec/client_spec.rb +40 -17
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ffc22cb79a7dd6547c654277f79f4378430bb40
|
4
|
+
data.tar.gz: dc0359cafd1b9f3725eea8a91a7119d868e513c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b39b0bdc1ec0e14397b7edbbac05476f14865656eedbb40b64d44879cf6f4ab94ec6a8dc51f748a234c3873b4876a830dcc8c4e4d49305ba2f3c4b1ed36b45f
|
7
|
+
data.tar.gz: 68e20485190e6717dbb2557bc32d7c0cb8a0f4092780bf77fcb8aaa100809c847f2ac46b6228a99b01a02e8d36405a46fe520f6b2628bc3b110801f5eef353dd
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v0.0.
|
3
|
+
## [v0.0.11](https://github.com/bootic/bootic_client.rb/tree/v0.0.11) (2015-10-28)
|
4
|
+
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.10...v0.0.11)
|
5
|
+
|
6
|
+
## [v0.0.10](https://github.com/bootic/bootic_client.rb/tree/v0.0.10) (2015-09-24)
|
7
|
+
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.9...v0.0.10)
|
8
|
+
|
9
|
+
**Merged pull requests:**
|
4
10
|
|
11
|
+
- Relation\#parameters lists available parameter names for templated URLs. [\#3](https://github.com/bootic/bootic_client.rb/pull/3) ([ismasan](https://github.com/ismasan))
|
12
|
+
|
13
|
+
## [v0.0.9](https://github.com/bootic/bootic_client.rb/tree/v0.0.9) (2015-05-01)
|
5
14
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.8...v0.0.9)
|
6
15
|
|
7
16
|
## [v0.0.8](https://github.com/bootic/bootic_client.rb/tree/v0.0.8) (2015-04-06)
|
8
|
-
|
9
17
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.7...v0.0.8)
|
10
18
|
|
11
19
|
**Merged pull requests:**
|
@@ -13,11 +21,9 @@
|
|
13
21
|
- Basic auth strategy [\#2](https://github.com/bootic/bootic_client.rb/pull/2) ([ismasan](https://github.com/ismasan))
|
14
22
|
|
15
23
|
## [v0.0.7](https://github.com/bootic/bootic_client.rb/tree/v0.0.7) (2015-03-07)
|
16
|
-
|
17
24
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.6...v0.0.7)
|
18
25
|
|
19
26
|
## [v0.0.6](https://github.com/bootic/bootic_client.rb/tree/v0.0.6) (2015-01-29)
|
20
|
-
|
21
27
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.5...v0.0.6)
|
22
28
|
|
23
29
|
**Merged pull requests:**
|
@@ -25,23 +31,18 @@
|
|
25
31
|
- Enumerable list entities [\#1](https://github.com/bootic/bootic_client.rb/pull/1) ([ismasan](https://github.com/ismasan))
|
26
32
|
|
27
33
|
## [v0.0.5](https://github.com/bootic/bootic_client.rb/tree/v0.0.5) (2014-07-27)
|
28
|
-
|
29
34
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.4...v0.0.5)
|
30
35
|
|
31
36
|
## [v0.0.4](https://github.com/bootic/bootic_client.rb/tree/v0.0.4) (2014-07-13)
|
32
|
-
|
33
37
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.3...v0.0.4)
|
34
38
|
|
35
39
|
## [v0.0.3](https://github.com/bootic/bootic_client.rb/tree/v0.0.3) (2014-06-21)
|
36
|
-
|
37
40
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.2...v0.0.3)
|
38
41
|
|
39
42
|
## [v0.0.2](https://github.com/bootic/bootic_client.rb/tree/v0.0.2) (2014-06-17)
|
40
|
-
|
41
43
|
[Full Changelog](https://github.com/bootic/bootic_client.rb/compare/v0.0.1...v0.0.2)
|
42
44
|
|
43
45
|
## [v0.0.1](https://github.com/bootic/bootic_client.rb/tree/v0.0.1) (2014-06-15)
|
44
46
|
|
45
47
|
|
46
|
-
|
47
48
|
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/bootic_client.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "faraday", '~> 0.9'
|
22
22
|
spec.add_dependency "uri_template", '~> 0.7'
|
23
23
|
spec.add_dependency "faraday_middleware", '~> 0.9'
|
24
|
-
spec.add_dependency "faraday-http-cache", '
|
24
|
+
spec.add_dependency "faraday-http-cache", '1.2.2'
|
25
25
|
spec.add_dependency "net-http-persistent", '~> 2.9'
|
26
26
|
spec.add_dependency "oauth2", "~> 1"
|
27
27
|
|
@@ -21,14 +21,15 @@ module BooticClient
|
|
21
21
|
iss: config.client_id,
|
22
22
|
prn: client.options[:access_token],
|
23
23
|
aud: 'api',
|
24
|
-
exp: exp
|
24
|
+
exp: exp,
|
25
|
+
scope: ''
|
25
26
|
)
|
26
27
|
|
27
28
|
access_token.token
|
28
29
|
end
|
29
30
|
|
30
31
|
def auth
|
31
|
-
@auth ||= OAuth2::Client.new(
|
32
|
+
@auth ||= OAuth2::Client.new('', '', site: config.auth_host)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -22,7 +22,7 @@ describe 'BooticClient::Strategies::Authorized' do
|
|
22
22
|
to_return(status: status, :body => JSON.dump(body))
|
23
23
|
end
|
24
24
|
|
25
|
-
def stub_auth(expired_token, status, body)
|
25
|
+
def stub_auth(expired_token, status, body, client_id: '', client_secret: '', scope: '')
|
26
26
|
now = Time.now
|
27
27
|
Time.stub(:now).and_return now
|
28
28
|
|
@@ -30,10 +30,10 @@ describe 'BooticClient::Strategies::Authorized' do
|
|
30
30
|
with(body: {
|
31
31
|
"assertion" => jwt_assertion(expired_token, now),
|
32
32
|
"assertion_type" => "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
33
|
-
"client_id" =>
|
34
|
-
"client_secret" =>
|
33
|
+
"client_id" => client_id,
|
34
|
+
"client_secret" => client_secret,
|
35
35
|
"grant_type" => "assertion",
|
36
|
-
"scope"=>
|
36
|
+
"scope"=>scope
|
37
37
|
},
|
38
38
|
headers: {
|
39
39
|
'Content-Type'=>'application/x-www-form-urlencoded'
|
data/spec/client_spec.rb
CHANGED
@@ -12,10 +12,11 @@ describe BooticClient::Client do
|
|
12
12
|
}
|
13
13
|
let(:response_headers) {
|
14
14
|
{
|
15
|
-
'Content-Type' => 'application/json',
|
15
|
+
'Content-Type' => 'application/json',
|
16
16
|
'Last-Modified' => 'Sat, 07 Jun 2014 12:10:33 GMT',
|
17
17
|
'ETag' => '0937dafce10db7b7d405667f9576d26d',
|
18
|
-
'Cache-Control' => 'max-age=0, private, must-revalidate'
|
18
|
+
'Cache-Control' => 'max-age=0, private, must-revalidate',
|
19
|
+
'Vary' => 'Acept-Encoding,Authorization'
|
19
20
|
}
|
20
21
|
}
|
21
22
|
let(:root_data) {
|
@@ -28,6 +29,37 @@ describe BooticClient::Client do
|
|
28
29
|
}
|
29
30
|
|
30
31
|
describe '#get' do
|
32
|
+
def assert_successful_response(response)
|
33
|
+
expect(response).to be_kind_of(Faraday::Response)
|
34
|
+
expect(response.status).to eql(200)
|
35
|
+
response.body.tap do |b|
|
36
|
+
expect(b['_links']['shops']).to eql({'href' => 'https://api.bootic.net/v1/products'})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'switching cache key as per Vary header' do
|
41
|
+
let!(:req) {
|
42
|
+
stub_request(:get, root_url)
|
43
|
+
.to_return(status: 200, body: JSON.dump(root_data), headers: response_headers.merge('Cache-Control' => 'max-age=100'))
|
44
|
+
}
|
45
|
+
|
46
|
+
before do
|
47
|
+
client.get(root_url, {}, request_headers.merge('Authorization' => 'Bearer aaa'))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'is cached when using the same authorization' do
|
51
|
+
resp = client.get(root_url, {}, request_headers.merge('Authorization' => 'Bearer aaa'))
|
52
|
+
expect(req).to have_been_requested.once
|
53
|
+
assert_successful_response resp
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'is not cached when using a different authorization' do
|
57
|
+
resp = client.get(root_url, {}, request_headers.merge('Authorization' => 'Bearer bbb'))
|
58
|
+
expect(req).to have_been_requested.twice
|
59
|
+
assert_successful_response resp
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
31
63
|
|
32
64
|
context 'fresh' do
|
33
65
|
before do
|
@@ -38,11 +70,7 @@ describe BooticClient::Client do
|
|
38
70
|
let!(:response) { client.get(root_url, {}, request_headers) }
|
39
71
|
|
40
72
|
it 'returns parsed Faraday response' do
|
41
|
-
|
42
|
-
expect(response.status).to eql(200)
|
43
|
-
response.body.tap do |b|
|
44
|
-
expect(b['_links']['shops']).to eql({'href' => 'https://api.bootic.net/v1/products'})
|
45
|
-
end
|
73
|
+
assert_successful_response response
|
46
74
|
end
|
47
75
|
|
48
76
|
context 'and then cached' do
|
@@ -53,13 +81,10 @@ describe BooticClient::Client do
|
|
53
81
|
end
|
54
82
|
|
55
83
|
it 'returns cached response' do
|
56
|
-
|
84
|
+
resp = client.get(root_url, {}, request_headers)
|
57
85
|
expect(@cached_request).to have_been_requested
|
58
86
|
|
59
|
-
|
60
|
-
r.body.tap do |b|
|
61
|
-
expect(b['_links']['shops']).to eql({'href' => 'https://api.bootic.net/v1/products'})
|
62
|
-
end
|
87
|
+
assert_successful_response resp
|
63
88
|
end
|
64
89
|
end
|
65
90
|
|
@@ -71,15 +96,13 @@ describe BooticClient::Client do
|
|
71
96
|
end
|
72
97
|
|
73
98
|
it 'returns cached response' do
|
74
|
-
|
99
|
+
resp = client.get(root_url, {}, request_headers)
|
75
100
|
expect(@cached_request).to have_been_requested
|
76
101
|
|
77
|
-
|
78
|
-
r.body.tap do |b|
|
79
|
-
expect(b['_links']['shops']).to eql({'href' => 'https://api.bootic.net/v1/products'})
|
80
|
-
end
|
102
|
+
assert_successful_response resp
|
81
103
|
end
|
82
104
|
end
|
105
|
+
|
83
106
|
end
|
84
107
|
|
85
108
|
context 'errors' do
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.2.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.2.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: net-http-persistent
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.4.
|
224
|
+
rubygems_version: 2.4.5
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Official Ruby client for the Bootic API
|