Subject: | Tests fail with HTTPS_PROXY set |
Pretty consistent results:
$ perl5.25.4 -Mblib t/https_proxy.t
1..56
ok 1 - noproxy http://127.0.0.1:54885/foo -> A.1@nossl
ok 2 - URL in request -> /foo
ok 3 - noproxy http://127.0.0.1:54885/bar -> A.2@nossl
ok 4 - URL in request -> /bar
ok 5 - noproxy http://127.0.0.1:54886/foo -> B.1@nossl
ok 6 - URL in request -> /foo
ok 7 - noproxy http://127.0.0.1:54886/bar -> B.2@nossl
ok 8 - URL in request -> /bar
ok 9 - noproxy http://127.0.0.1:54885/tor -> A.3@nossl
ok 10 - URL in request -> /tor
ok 11 - noproxy http://127.0.0.1:54886/tor -> B.3@nossl
ok 12 - URL in request -> /tor
unexpected response: HTTP/1.1 403 Forbidden
Connection: close
Date: Sun, 04 Sep 2016 01:16:49 GMT
Server: HTTP::Proxy/0.302
Content-Type: text/html
Client-Date: Sun, 04 Sep 2016 01:16:49 GMT
Client-Peer: 10.10.10.2:8080
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Title: Sphynx: Access Denied
<!doctype html><title>Sphynx: Access Denied</title>
<body style=text-align:center><h1>Access has been denied!</h1><hr>
<p>Access to the page <p><a href="http://foo/foo">http://foo/foo</a>
<p>has been denied because it is not in the list.
<p style="position:absolute; right: 30px; bottom: 20px; font-size: 70%">Popeye.local
# Looks like your test exited with 2 just after 12.
That is the output that our proxy gives for disallowed addresses. If I patch the offending test script like this:
diff -rup LWP-Protocol-https-6.06-0-orig/t/https_proxy.t LWP-Protocol-https-6.06-0/t/https_proxy.t
--- LWP-Protocol-https-6.06-0-orig/t/https_proxy.t 2016-09-03 18:16:45.000000000 -0700
+++ LWP-Protocol-https-6.06-0/t/https_proxy.t 2016-09-03 18:17:43.000000000 -0700
@@ -85,7 +85,8 @@ $ua{proxy_nokeepalive} = LWP::UserAgent-
SSL_ca_file => $cafile
}
);
-$ENV{http_proxy} = $ENV{https_proxy} = "http://foo:bar\@$saddr[0]";
+$ENV{http_proxy} = $ENV{https_proxy} = $ENV{HTTPS_PROXY} =
+ "http://foo:bar\@$saddr[0]";
$ua{proxy}->env_proxy;
$ua{proxy_nokeepalive}->env_proxy;
if ($netssl) {
@@ -167,6 +168,7 @@ for my $test (@tests) {
$ENV{https_proxy} = $uatype =~m{^proxy} ? "http://$saddr[0]":""
}
+warn "@$test";
my $response = $ua->get($url) or die "no response";
if ( $response->is_success
and ( my $body = $response->content()) =~m{^ID: *(\d+)\.(\S+)}m ) {
Then it passes most of the time, but occasionally fails. I suspect some hash randomisation issue.
When it fails, it looks like this (note the ‘warn’ line in the patch):
$ perl5.25.4 -Mblib t/https_proxy.t
1..56
noproxy http://127.0.0.1:54903/foo A.1@nossl at t/https_proxy.t line 171.
ok 1 - noproxy http://127.0.0.1:54903/foo -> A.1@nossl
ok 2 - URL in request -> /foo
noproxy http://127.0.0.1:54903/bar A.2@nossl at t/https_proxy.t line 171.
ok 3 - noproxy http://127.0.0.1:54903/bar -> A.2@nossl
ok 4 - URL in request -> /bar
noproxy http://127.0.0.1:54904/foo B.1@nossl at t/https_proxy.t line 171.
ok 5 - noproxy http://127.0.0.1:54904/foo -> B.1@nossl
ok 6 - URL in request -> /foo
noproxy http://127.0.0.1:54904/bar B.2@nossl at t/https_proxy.t line 171.
ok 7 - noproxy http://127.0.0.1:54904/bar -> B.2@nossl
ok 8 - URL in request -> /bar
noproxy http://127.0.0.1:54903/tor A.3@nossl at t/https_proxy.t line 171.
ok 9 - noproxy http://127.0.0.1:54903/tor -> A.3@nossl
ok 10 - URL in request -> /tor
noproxy http://127.0.0.1:54904/tor B.3@nossl at t/https_proxy.t line 171.
ok 11 - noproxy http://127.0.0.1:54904/tor -> B.3@nossl
ok 12 - URL in request -> /tor
proxy http://foo/foo C.1.auth@nossl at t/https_proxy.t line 171.
unexpected response: HTTP/1.1 403 Forbidden
Connection: close
Date: Sun, 04 Sep 2016 01:18:47 GMT
Server: HTTP::Proxy/0.302
Content-Type: text/html
Client-Date: Sun, 04 Sep 2016 01:18:47 GMT
Client-Peer: 10.10.10.2:8080
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Title: Sphynx: Access Denied
<!doctype html><title>Sphynx: Access Denied</title>
<body style=text-align:center><h1>Access has been denied!</h1><hr>
<p>Access to the page <p><a href="http://foo/foo">http://foo/foo</a>
<p>has been denied because it is not in the list.
<p style="position:absolute; right: 30px; bottom: 20px; font-size: 70%">Popeye.local
# Looks like your test exited with 2 just after 12.
It’s the same failure as before, but it is now intermittent. You can see that it is failing in the first of these tests:
# keep-alive for proxy http
# use the same proxy connection for all even if the target host differs
[ 'proxy', "http://foo/foo",'C.1.auth@nossl' ],
[ 'proxy', "http://foo/bar",'C.2.auth@nossl' ],
And 'proxy' refers to $ua{proxy}, which gets an ->env_proxy call above, right after the env vars are set.
However early I try to move the %ENV setting, the failure still happens intermittently.
So there are two problems here. First, the test script is not setting HTTPS_PROXY, but just the lowercase version, causing consistent failures. Secondly, something is intermittently reading env before the script has a chance to set it.