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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 704afcba6a7b48237368e3a5f93896a152a2a081
4
- data.tar.gz: bb825aa6d94898131fa8185d4c5264296c5c2aed
3
+ metadata.gz: 1961fe701af902402b83e7eaa4a76fb54bf06f93
4
+ data.tar.gz: ae8913a88b7f1da4379ee03f0900ec0e5b896f65
5
5
  SHA512:
6
- metadata.gz: 44916cd9440ba47737a567527755a085034c222e892e311ecc848a114634c25d44c81219ef1c58290e8b2d10ad18f23bdb57a939d9d84072cf3ef4a7665a9bf2
7
- data.tar.gz: f19f4000b1250ddcccce85e6dcf4c0d3fde1c741f68f314da336525f228c619f15f98e682b8f3b059f2eed46c562033864582957ad149e3201e5cd21afb1b112
6
+ metadata.gz: d851f45539fc6af2e302ffc9497a0e18f71c6c261254bd0f7681d8a8996da2fd9b96659019f8d3c3012cc79a692c0d903d31d3ed2e50236fdc6fd13405baeba7
7
+ data.tar.gz: 44aff14e7d23468f10a3214a31e6ee3920401421629230f2b7d19461b43f93a54573441895d2d3d06d041220cd554c3a1b90074447afa5eec0514d37dd91f297
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  _A description of your awesome changes here!_
4
4
 
5
+ ### 3.6.1 (2018-10-09)
6
+
7
+ Features:
8
+
9
+ - Clients can now set User Agent when placing requests
10
+
5
11
  ### 3.6.0 (2018-07-23)
6
12
 
7
13
  Features:
@@ -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.merge(auth)
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
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '3.6.0'.freeze
3
+ VERSION = '3.6.1'.freeze
4
4
  end
5
5
  end
@@ -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.0
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-07-23 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable