[DRE-maint] Bug#873681: ruby-rest-client tests fail if global proxy is set in environment
Steve Langasek
steve.langasek at canonical.com
Wed Aug 30 04:18:35 UTC 2017
Package: ruby-rest-client
Version: 2.0.2-2
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu artful ubuntu-patch autopkgtest
The Ubuntu autopkgtest infrastructure uses an http proxy for Internet
access, which means ruby-rest-client automatically picks up the proxy from
the enviroment and uses it. Unfortunately, the upstream tests don't *pass*
if a global proxy is set.
Attached is a patch that has been applied to Ubuntu to mock the environment
for two autopkgtests that are sensitive to this environment setting.
Thanks,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
slangasek at ubuntu.com vorlon at debian.org
-------------- next part --------------
diff -Nru ruby-rest-client-2.0.2/debian/patches/proxy-proof-tests.patch ruby-rest-client-2.0.2/debian/patches/proxy-proof-tests.patch
--- ruby-rest-client-2.0.2/debian/patches/proxy-proof-tests.patch 1969-12-31 16:00:00.000000000 -0800
+++ ruby-rest-client-2.0.2/debian/patches/proxy-proof-tests.patch 2017-08-29 21:15:28.000000000 -0700
@@ -0,0 +1,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 at 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')
diff -Nru ruby-rest-client-2.0.2/debian/patches/series ruby-rest-client-2.0.2/debian/patches/series
--- ruby-rest-client-2.0.2/debian/patches/series 2017-07-25 23:24:23.000000000 -0700
+++ ruby-rest-client-2.0.2/debian/patches/series 2017-08-29 21:04:31.000000000 -0700
@@ -1,2 +1,3 @@
disable-network-tests.patch
no-git-in-gemspec.patch
+proxy-proof-tests.patch
More information about the Pkg-ruby-extras-maintainers
mailing list