X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=tests%2FTest-proxied-https-auth.px;h=a2efe5ebcb5b90a82d1733c00965c4bf177127ff;hb=f0438edcf2e34169fb0792119ac9ce10ae35a564;hp=2260658903f39eaf699d6dc6ac0e831ba041d78e;hpb=ad21f8e2b774367156fbe71f4318b5646059b724;p=wget diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px index 22606589..a2efe5eb 100755 --- a/tests/Test-proxied-https-auth.px +++ b/tests/Test-proxied-https-auth.px @@ -3,9 +3,22 @@ use warnings; use strict; use WgetTest; # For $WGETPATH. + +# Have we even built an HTTPS-supporting Wget? +{ + my @version_lines = `${WgetTest::WGETPATH} --version`; + unless (grep /\+(openssl|gnutls)/, @version_lines) { + print "Not running test: Wget under test doesn't support HTTPS.\n"; + exit 0; + } +} + use HTTP::Daemon; use HTTP::Request; -use IO::Socket::SSL 'debug4'; +use IO::Socket::SSL; + +my $SOCKET = HTTP::Daemon->new (LocalAddr => 'localhost', + ReuseAddr => 1) or die "Cannot create server!!!"; sub get_request { my $conn = shift; @@ -26,9 +39,7 @@ sub get_request { sub do_server { my $alrm = alarm 10; - my $s = HTTP::Daemon->new (LocalAddr => 'localhost', - LocalPort => '8080', - ReuseAddr => 1) or die "Cannot create server!!!"; + my $s = $SOCKET; my $conn; my $rqst; my $rspn; @@ -68,6 +79,10 @@ sub do_server { 'Content-Type' => 'text/plain', 'Connection' => 'close', ], "foobarbaz\n"); + $rspn->protocol('HTTP/1.0'); + print "=====\n"; + print $rspn->as_string; + print "\n=====\n"; print $conn $rspn->as_string; } $conn->close; @@ -87,15 +102,18 @@ sub fork_server { } system ('rm -f needs-auth.txt'); -&fork_server; +my $pid = &fork_server; sleep 1; my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee" - . " --password=Dodgson -e https_proxy=localhost:8080" + . " --password=Dodgson -e https_proxy=localhost:{{port}}" . " --no-check-certificate" . " https://no.such.domain/needs-auth.txt"; +$cmdline =~ s/{{port}}/$SOCKET->sockport()/e; my $code = system($cmdline); +system ('rm -f needs-auth.txt'); warn "Got code: $code\n" if $code; -exit $code; +kill ('TERM', $pid); +exit ($code >> 8);