codeclimate-services 1.10.0 → 1.10.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b11c82863c3fe8d7abd190d5d8d1605232348a2
4
- data.tar.gz: 7953aafa98f5ff37f3752d6bc0695b35a265a9d7
3
+ metadata.gz: 28a587b7b4dfdf431800b17380549e44b0f9c500
4
+ data.tar.gz: 65102446840ccaa599271b4875a9be8836c95934
5
5
  SHA512:
6
- metadata.gz: 73330d3bf0e63289bdb9d40a884782ed6bff091bd455168ff9eb8865abe63f5746c4a7f5fc7506bfcaa41367eb0879d63d0c9db4bc83af33b5eb87504181e580
7
- data.tar.gz: 0d3a6ba2497993ae7860e7c5772e827c9c48672e7717169459fae0f0c5dee971f320b3207d195ce791cd1d6f8d757d986c2545cb407eb0d1effcdfed1b1fa518
6
+ metadata.gz: 2a8d21f29a3a24b42f59c47f3edac13a1fdc25736249d58582b7dabf2d47484c36bed3c6d6b0166ecf5e1f26be3b7c763460d3ec1b132fbcd67669e7329afe1e
7
+ data.tar.gz: e7e3e23b0698d345fb32cf4bd545ca8f8370ee6de25bd8b64c228e5947c0d024beeb90935bbdf31171aa7d30590a0c233c1f87bab935ae041051c1222baf4602
@@ -58,7 +58,10 @@ module CC::Service::HTTP
58
58
  CC::Service::SafeWebhook.ensure_safe!(url)
59
59
 
60
60
  http.send(method) do |req|
61
- req.url(url) if url
61
+ if url
62
+ req.url(url)
63
+ req.options.proxy = http.proxy_from_env(url)
64
+ end
62
65
  req.headers.update(headers) if headers
63
66
  req.body = body if body
64
67
  block.call req if block
@@ -1,5 +1,5 @@
1
1
  module CC
2
2
  module Services
3
- VERSION = "1.10.0".freeze
3
+ VERSION = "1.10.1".freeze
4
4
  end
5
5
  end
@@ -75,4 +75,53 @@ describe CC::Service, type: :service do
75
75
 
76
76
  expect(services.include?(CC::PullRequests)).not_to eq(true)
77
77
  end
78
+
79
+ context "with proxy details" do
80
+ before do
81
+ @old_no_proxy = ENV["no_proxy"]
82
+ @old_http_proxy = ENV["http_proxy"]
83
+ ENV["no_proxy"] = "github.com"
84
+ ENV["http_proxy"] = "http://127.0.0.2:42"
85
+ end
86
+
87
+ after do
88
+ ENV["no_proxy"] = @old_no_proxy
89
+ ENV["http_proxy"] = @old_http_proxy
90
+ end
91
+
92
+ it "uses the proxy when it should" do
93
+ stub_http("http://proxied.test/my/test/url") do |env|
94
+ expect(env.request.proxy).to be_instance_of(Faraday::ProxyOptions)
95
+ expect(env.request.proxy.uri).to eq(URI.parse("http://127.0.0.2:42"))
96
+ [200, {}, '{"ok": true, "thing": "123"}']
97
+ end
98
+
99
+ response = service_post("http://proxied.test/my/test/url", { token: "1234" }.to_json, {}) do |inner_response|
100
+ body = JSON.parse(inner_response.body)
101
+ { thing: body["thing"] }
102
+ end
103
+
104
+ expect(response[:ok]).to eq(true)
105
+ expect(response[:params]).to eq('{"token":"1234"}')
106
+ expect(response[:endpoint_url]).to eq("http://proxied.test/my/test/url")
107
+ expect(response[:status]).to eq(200)
108
+ end
109
+
110
+ it "respects proxy exclusions" do
111
+ stub_http("http://github.com/my/test/url") do |env|
112
+ expect(env.request.proxy).to be_nil
113
+ [200, {}, '{"ok": true, "thing": "123"}']
114
+ end
115
+
116
+ response = service_post("http://github.com/my/test/url", { token: "1234" }.to_json, {}) do |inner_response|
117
+ body = JSON.parse(inner_response.body)
118
+ { thing: body["thing"] }
119
+ end
120
+
121
+ expect(response[:ok]).to eq(true)
122
+ expect(response[:params]).to eq('{"token":"1234"}')
123
+ expect(response[:endpoint_url]).to eq("http://github.com/my/test/url")
124
+ expect(response[:status]).to eq(200)
125
+ end
126
+ end
78
127
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday