Debian Codegraph @

tests/Test-https-tlsv1x.px

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Socket;
6 use Cwd;
7 use WgetFeature qw(https);
8 use SSLTest;
9
10 ###############################################################################
11
12 # code, msg, headers, content
13 my %urls = (
14 '/somefile.txt' => {
15 code => "200",
16 msg => "Dontcare",
17 headers => {
18 "Content-type" => "text/plain",
19 },
20 content => "blabla",
21 },
22 );
23
24 my $srcdir;
25 if (@ARGV) {
26 $srcdir = shift @ARGV;
27 } elsif (defined $ENV{srcdir}) {
28 $srcdir = $ENV{srcdir};
29 }
30 $srcdir = Cwd::abs_path("$srcdir");
31
32 # HOSTALIASES env variable allows us to create hosts file alias.
33 my $testhostname = "WgetTestingServer";
34 $ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
35
36 my $addr = gethostbyname($testhostname);
37 unless ($addr)
38 {
39 warn "Failed to resolve $testhostname, using $srcdir/certs/wgethosts\n";
40 exit 77;
41 }
42 unless (inet_ntoa($addr) =~ "127.0.0.1")
43 {
44 warn "Unexpected IP for localhost: ".inet_ntoa($addr)."\n";
45 exit 77;
46 }
47
48 my $port = 29443;
49 my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=TLSv1_1".
50 " --ca-certificate=$srcdir/certs/test-ca-cert.pem".
51 " https://$testhostname:$port/somefile.txt";
52
53 my $expected_error_code = 0;
54
55 my %existing_files = (
56 );
57
58 my %expected_downloaded_files = (
59 'somefile.txt' => {
60 content => "blabla",
61 },
62 );
63
64 my $sslsock = SSLTest->new(cmdline => $cmdline,
65 input => \%urls,
66 errcode => $expected_error_code,
67 existing => \%existing_files,
68 output => \%expected_downloaded_files,
69 sslport => $port);
70 exit $sslsock->run();
71
72 # vim: et ts=4 sw=4