codeclimate-services 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cc/service/http.rb +4 -1
- data/lib/cc/services/version.rb +1 -1
- data/spec/cc/service_spec.rb +49 -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: 28a587b7b4dfdf431800b17380549e44b0f9c500
|
4
|
+
data.tar.gz: 65102446840ccaa599271b4875a9be8836c95934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a8d21f29a3a24b42f59c47f3edac13a1fdc25736249d58582b7dabf2d47484c36bed3c6d6b0166ecf5e1f26be3b7c763460d3ec1b132fbcd67669e7329afe1e
|
7
|
+
data.tar.gz: e7e3e23b0698d345fb32cf4bd545ca8f8370ee6de25bd8b64c228e5947c0d024beeb90935bbdf31171aa7d30590a0c233c1f87bab935ae041051c1222baf4602
|
data/lib/cc/service/http.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/cc/services/version.rb
CHANGED
data/spec/cc/service_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|