File: proxy-proof-tests.patch

package info (click to toggle)
ruby-rest-client 2.0.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 664 kB
  • sloc: ruby: 3,734; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Description: Fix tests to pass cleanly when http_proxy is set in the env
 An autopkgtest environment may have a global proxy set for access to the
 Internet.  Our tests should not fail if this is the case.  Mock the
 environment so that we're not inadvertently testing the wrong thing.
Author: Steve Langasek <steve.langasek@ubuntu.com>

Index: ruby-rest-client-2.0.2/spec/unit/request_spec.rb
===================================================================
--- ruby-rest-client-2.0.2.orig/spec/unit/request_spec.rb
+++ ruby-rest-client-2.0.2/spec/unit/request_spec.rb
@@ -579,6 +579,9 @@
     end
 
     it "creates a non-proxy class if a proxy url is not given" do
+      allow(ENV).to receive(:[]).with("HTTP_PROXY").and_return(nil)
+      allow(ENV).to receive(:[]).with("http_proxy").and_return(nil)
+      allow(ENV).to receive(:[]).with("NETRC").and_return(nil)
       expect(@proxy_req.net_http_object('host', 80).proxy?).to be_falsey
     end
 
@@ -592,6 +595,9 @@
     end
 
     it "sets proxy on a per-request basis" do
+      allow(ENV).to receive(:[]).with("HTTP_PROXY").and_return(nil)
+      allow(ENV).to receive(:[]).with("http_proxy").and_return(nil)
+      allow(ENV).to receive(:[]).with("NETRC").and_return(nil)
       expect(@proxy_req.net_http_object('some', 80).proxy?).to be_falsey
 
       req = RestClient::Request.new(:method => :put, :url => 'http://some/resource', :payload => 'payload', :proxy => 'http://example.com')