diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:47:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:47:50 +0000 |
commit | bbe35a6e1b54ef5cd7c1c471886c30ba85c0804e (patch) | |
tree | 985a31e8c860c690d9f20e6621ce5fcc05ccd244 /tests/Test-https-tlsv1x.px | |
parent | Initial commit. (diff) | |
download | wget-bbe35a6e1b54ef5cd7c1c471886c30ba85c0804e.tar.xz wget-bbe35a6e1b54ef5cd7c1c471886c30ba85c0804e.zip |
Adding upstream version 1.21.upstream/1.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | tests/Test-https-tlsv1x.px | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/Test-https-tlsv1x.px b/tests/Test-https-tlsv1x.px new file mode 100755 index 0000000..2a24c44 --- /dev/null +++ b/tests/Test-https-tlsv1x.px @@ -0,0 +1,72 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Socket; +use Cwd; +use WgetFeature qw(https); +use SSLTest; + +############################################################################### + +# code, msg, headers, content +my %urls = ( + '/somefile.txt' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => "blabla", + }, +); + +my $srcdir; +if (@ARGV) { + $srcdir = shift @ARGV; +} elsif (defined $ENV{srcdir}) { + $srcdir = $ENV{srcdir}; +} +$srcdir = Cwd::abs_path("$srcdir"); + +# HOSTALIASES env variable allows us to create hosts file alias. +my $testhostname = "WgetTestingServer"; +$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts"; + +my $addr = gethostbyname($testhostname); +unless ($addr) +{ + warn "Failed to resolve $testhostname, using $srcdir/certs/wgethosts\n"; + exit 77; +} +unless (inet_ntoa($addr) =~ "127.0.0.1") +{ + warn "Unexpected IP for localhost: ".inet_ntoa($addr)."\n"; + exit 77; +} + +my $port = 29443; +my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=TLSv1_1". + " --ca-certificate=$srcdir/certs/test-ca-cert.pem". + " https://$testhostname:$port/somefile.txt"; + +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, + output => \%expected_downloaded_files, + sslport => $port); +exit $sslsock->run(); + +# vim: et ts=4 sw=4 |