routemaster-drain 3.6.0 → 3.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/routemaster/api_client.rb +7 -1
- data/lib/routemaster/drain.rb +1 -1
- data/spec/routemaster/api_client_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1961fe701af902402b83e7eaa4a76fb54bf06f93
|
4
|
+
data.tar.gz: ae8913a88b7f1da4379ee03f0900ec0e5b896f65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d851f45539fc6af2e302ffc9497a0e18f71c6c261254bd0f7681d8a8996da2fd9b96659019f8d3c3012cc79a692c0d903d31d3ed2e50236fdc6fd13405baeba7
|
7
|
+
data.tar.gz: 44aff14e7d23468f10a3214a31e6ee3920401421629230f2b7d19461b43f93a54573441895d2d3d06d041220cd554c3a1b90074447afa5eec0514d37dd91f297
|
data/CHANGELOG.md
CHANGED
@@ -111,10 +111,11 @@ module Routemaster
|
|
111
111
|
def _request(method, url:, body: nil, headers:, params: {})
|
112
112
|
uri = _assert_uri(url)
|
113
113
|
auth = auth_header(uri.host)
|
114
|
+
headers = [*user_agent_header, *auth, *headers].to_h
|
114
115
|
connection.public_send(method) do |req|
|
115
116
|
req.url uri.to_s
|
116
117
|
req.params.merge! params
|
117
|
-
req.headers = headers
|
118
|
+
req.headers = headers
|
118
119
|
req.body = body
|
119
120
|
end
|
120
121
|
end
|
@@ -155,6 +156,11 @@ module Routemaster
|
|
155
156
|
{ 'Authorization' => "Basic #{Base64.strict_encode64(auth_string)}" }
|
156
157
|
end
|
157
158
|
|
159
|
+
def user_agent_header
|
160
|
+
agent = @source_peer || "Faraday v#{Faraday::VERSION}"
|
161
|
+
{ 'User-Agent' => agent }
|
162
|
+
end
|
163
|
+
|
158
164
|
def response_cache_opt_headers(value)
|
159
165
|
{ Routemaster::Middleware::ResponseCaching::RESPONSE_CACHING_OPT_HEADER => value.to_s }
|
160
166
|
end
|
data/lib/routemaster/drain.rb
CHANGED
@@ -55,6 +55,32 @@ describe Routemaster::APIClient do
|
|
55
55
|
expect(req.headers).to include('X-Custom-Header')
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
describe 'source peer' do
|
60
|
+
context 'with a source peer' do
|
61
|
+
let(:options) { { source_peer: 'ServiceA' } }
|
62
|
+
let(:fetcher) { described_class.new(options) }
|
63
|
+
|
64
|
+
it 'should set the user agent header to the source peer' do
|
65
|
+
subject.status
|
66
|
+
assert_requested(:get, /example/) do |req|
|
67
|
+
expect(req.headers).to include('User-Agent' => 'ServiceA')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'without a source peer' do
|
73
|
+
let(:options) { { source_peer: nil } }
|
74
|
+
let(:fetcher) { described_class.new(options) }
|
75
|
+
|
76
|
+
it 'should set the user agent header to the faraday version' do
|
77
|
+
subject.status
|
78
|
+
assert_requested(:get, /example/) do |req|
|
79
|
+
expect(req.headers).to include('User-Agent' => "Faraday v#{Faraday::VERSION}" )
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
58
84
|
end
|
59
85
|
|
60
86
|
shared_examples 'a wrappable response' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routemaster-drain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|