Debian Codegraph @

tests/Test-iri-disabled.px

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use HTTPTest;
7
8 # cf. http://en.wikipedia.org/wiki/Latin1
9 # http://en.wikipedia.org/wiki/ISO-8859-15
10
11 ###############################################################################
12 #
13 # mime : charset found in Content-Type HTTP MIME header
14 # meta : charset found in Content-Type meta tag
15 #
16 # index.html mime + file = iso-8859-15
17 # p1_français.html meta + file = iso-8859-1, mime = utf-8
18 # p2_één.html mime + file = iso-8859-1
19 # p3_€€€.html meta + file = utf-8, mime = iso-8859-1
20 #
21
22 my $ccedilla_l15 = "\xE7";
23 my $ccedilla_u8 = "\xC3\xA7";
24 my $eacute_l1 = "\xE9";
25 my $eacute_u8 = "\xC3\xA9";
26 my $eurosign_l15 = "\xA4";
27 my $eurosign_u8 = "\xE2\x82\xAC";
28
29 my $pageindex = <<EOF;
30 <html>
31 <head>
32 <title>Main Page</title>
33 </head>
34 <body>
35 <p>
36 Link to page 1 <a href="http://localhost:{{port}}/p1_fran${ccedilla_l15}ais.html">La seule page en fran&ccedil;ais</a>.
37 Link to page 3 <a href="http://localhost:{{port}}/p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html">My tailor is rich</a>.
38 </p>
39 </body>
40 </html>
41 EOF
42
43 my $pagefrancais = <<EOF;
44 <html>
45 <head>
46 <title>La seule page en français</title>
47 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
48 </head>
49 <body>
50 <p>
51 Link to page 2 <a href="http://localhost:{{port}}/p2_${eacute_l1}${eacute_l1}n.html">Die enkele nerderlangstalige pagina</a>.
52 </p>
53 </body>
54 </html>
55 EOF
56
57 my $pageeen = <<EOF;
58 <html>
59 <head>
60 <title>Die enkele nederlandstalige pagina</title>
61 </head>
62 <body>
63 <p>
64 &Eacute;&eacute;n is niet veel maar toch meer dan nul.<br/>
65 Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :)
66 </p>
67 </body>
68 </html>
69 EOF
70
71 my $pageeuro = <<EOF;
72 <html>
73 <head>
74 <title>Euro page</title>
75 </head>
76 <body>
77 <p>
78 My tailor isn't rich anymore.
79 </p>
80 </body>
81 </html>
82 EOF
83
84 my $page404 = <<EOF;
85 <html>
86 <head>
87 <title>404</title>
88 </head>
89 <body>
90 <p>
91 Nop nop nop...
92 </p>
93 </body>
94 </html>
95 EOF
96
97 # code, msg, headers, content
98 my %urls = (
99 '/index.html' => {
100 code => "200",
101 msg => "Ok",
102 headers => {
103 "Content-type" => "text/html; charset=ISO-8859-15",
104 },
105 content => $pageindex,
106 },
107 '/robots.txt' => {
108 code => "200",
109 msg => "Ok",
110 headers => {
111 "Content-type" => "text/plain",
112 },
113 content => "",
114 },
115 '/p1_fran%C3%A7ais.html' => { # UTF-8 encoded
116 code => "200",
117 msg => "File not found",
118 headers => {
119 "Content-type" => "text/html; charset=UTF-8",
120 },
121 content => $pagefrancais,
122 },
123 '/p1_fran%E7ais.html' => {
124 code => "200",
125 msg => "Ok",
126 headers => {
127 "Content-type" => "text/html; charset=UTF-8",
128 },
129 content => $pagefrancais,
130 },
131 '/p2_%C3%A9%C3%A9n.html' => { # UTF-8 encoded
132 code => "200",
133 msg => "Ok",
134 headers => {
135 "Content-type" => "text/html; charset=UTF-8",
136 },
137 content => $pageeen,
138 },
139 '/p2_%E9%E9n.html' => {
140 code => "200",
141 msg => "Ok",
142 headers => {
143 "Content-type" => "text/html; charset=ISO-8859-1",
144 },
145 content => $pageeen,
146 },
147 '/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded
148 code => "200",
149 msg => "Ok",
150 headers => {
151 "Content-type" => "text/plain",
152 },
153 content => $pageeuro,
154 },
155 '/p3_%A4%A4%A4.html' => {
156 code => "200",
157 msg => "Ok",
158 headers => {
159 "Content-type" => "text/plain",
160 },
161 content => $pageeuro,
162 },
163 );
164
165 my $cmdline = $WgetTest::WGETPATH . " --no-iri -nH -r http://localhost:{{port}}/";
166
167 my $expected_error_code = 0;
168
169 my %expected_downloaded_files = (
170 'index.html' => {
171 content => $pageindex,
172 },
173 'robots.txt' => {
174 content => "",
175 },
176 "p1_fran${ccedilla_l15}ais.html" => {
177 content => $pagefrancais,
178 },
179 "p2_${eacute_l1}${eacute_l1}n.html" => {
180 content => $pageeen,
181 },
182 "p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html" => {
183 content => $pageeuro,
184 },
185 );
186
187 ###############################################################################
188
189 my $the_test = HTTPTest->new (input => \%urls,
190 cmdline => $cmdline,
191 errcode => $expected_error_code,
192 output => \%expected_downloaded_files);
193 exit $the_test->run();
194
195 # vim: et ts=4 sw=4