2017-03-15 15:09:46 +08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2017-05-09 17:06:44 +08:00
|
|
|
use Socket;
|
|
|
|
use WgetFeature qw(https);
|
2017-03-15 15:09:46 +08:00
|
|
|
use SSLTest;
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# code, msg, headers, content
|
|
|
|
my %urls = (
|
|
|
|
'/somefile.txt' => {
|
|
|
|
code => "200",
|
|
|
|
msg => "Dontcare",
|
|
|
|
headers => {
|
|
|
|
"Content-type" => "text/plain",
|
|
|
|
},
|
|
|
|
content => "blabla",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2017-04-22 03:34:16 +08:00
|
|
|
# Skip the test if openssl is not available
|
|
|
|
my $ossl = `openssl version`;
|
|
|
|
unless ($ossl =~ m/OpenSSL 1/)
|
|
|
|
{
|
|
|
|
exit 77;
|
|
|
|
}
|
|
|
|
|
2017-03-15 15:09:46 +08:00
|
|
|
my $cdir = $ENV{'PWD'};
|
|
|
|
# HOSTALIASES env variable allows us to create hosts file alias.
|
|
|
|
my $testhostname = "WgetTestingServer";
|
2017-05-04 22:42:49 +08:00
|
|
|
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
2017-04-22 03:34:16 +08:00
|
|
|
|
2017-05-09 17:06:44 +08:00
|
|
|
my $addr = gethostbyname($testhostname) or
|
|
|
|
exit 77;
|
|
|
|
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
|
|
|
{
|
|
|
|
warn "Failed to resolve $testhostname";
|
|
|
|
exit 77;
|
|
|
|
}
|
|
|
|
|
2017-05-08 17:35:22 +08:00
|
|
|
my $port = 24443;
|
2017-04-22 03:34:16 +08:00
|
|
|
my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=PFS".
|
|
|
|
" --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
|
|
|
" https://$testhostname:$port/somefile.txt";
|
2017-03-15 15:09:46 +08:00
|
|
|
|
|
|
|
my $expected_error_code = 0;
|
|
|
|
|
|
|
|
my %existing_files = (
|
|
|
|
);
|
|
|
|
|
|
|
|
my %expected_downloaded_files = (
|
|
|
|
'somefile.txt' => {
|
|
|
|
content => "blabla",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
my $sslsock = SSLTest->new(cmdline => $cmdline,
|
|
|
|
input => \%urls,
|
|
|
|
errcode => $expected_error_code,
|
|
|
|
existing => \%existing_files,
|
2017-04-22 03:34:16 +08:00
|
|
|
output => \%expected_downloaded_files,
|
|
|
|
sslport => $port);
|
2017-04-22 03:34:16 +08:00
|
|
|
exit $sslsock->run();
|
2017-03-15 15:09:46 +08:00
|
|
|
|
|
|
|
# vim: et ts=4 sw=4
|