Debian Codegraph @

tests/Test-https-tlsv1.px

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