From da7adbaef4bb2c47a19db3e83620aed06ba9456e Mon Sep 17 00:00:00 2001 From: Xavier Saint Date: Sat, 2 Aug 2008 12:17:03 +0200 Subject: [PATCH] Functional tests for IRI and HTTP --- tests/Test-iri-disabled.px | 197 ++++++++++++++++++++++++++++ tests/Test-iri-forced-remote.px | 208 +++++++++++++++++++++++++++++ tests/Test-iri.px | 225 ++++++++++++++++++++++++++++++++ tests/run-px | 3 + 4 files changed, 633 insertions(+) create mode 100755 tests/Test-iri-disabled.px create mode 100755 tests/Test-iri-forced-remote.px create mode 100755 tests/Test-iri.px diff --git a/tests/Test-iri-disabled.px b/tests/Test-iri-disabled.px new file mode 100755 index 00000000..122537ff --- /dev/null +++ b/tests/Test-iri-disabled.px @@ -0,0 +1,197 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + +# cf. http://en.wikipedia.org/wiki/Latin1 +# http://en.wikipedia.org/wiki/ISO-8859-15 + +############################################################################### +# +# mime : charset found in Content-Type HTTP MIME header +# meta : charset found in Content-Type meta tag +# +# index.html mime + file = iso-8859-15 +# p1_français.html meta + file = iso-8859-1, mime = utf-8 +# p2_één.html mime + file = iso-8859-1 +# p3_€€€.html meta + file = utf-8, mime = iso-8859-1 +# + +my $ccedilla_l15 = "\xE7"; +my $ccedilla_u8 = "\xC3\xA7"; +my $eacute_l1 = "\xE9"; +my $eacute_u8 = "\xC3\xA9"; +my $eurosign_l15 = "\xA4"; +my $eurosign_u8 = "\xE2\x82\xAC"; +my $eurosign2_u8 = "\xE2%82\xAC"; # version wget use... sXXXav + +my $pageindex = < + + Main Page + + +

+ Link to page 1 La seule page en français. + Link to page 3 My tailor is rich. +

+ + +EOF + +my $pagefrancais = < + + La seule page en français + + + +

+ Link to page 2 Die enkele nerderlangstalige pagina. +

+ + +EOF + +my $pageeen = < + + Die enkele nederlandstalige pagina + + +

+ Één is niet veel maar toch meer dan nul.
+ Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :) +

+ + +EOF + +my $pageeuro = < + + Euro page + + +

+ My tailor isn't rich anymore. +

+ + +EOF + +my $page404 = < + + 404 + + +

+ Nop nop nop... +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/index.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-15", + }, + content => $pageindex, + }, + '/robots.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => "", + }, + '/p1_fran%C3%A7ais.html' => { # UTF-8 encoded + code => "200", + msg => "File not found", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pagefrancais, + }, + '/p1_fran%E7ais.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pagefrancais, + }, + '/p2_%C3%A9%C3%A9n.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pageeen, + }, + '/p2_%E9%E9n.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-1", + }, + content => $pageeen, + }, + '/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => $pageeuro, + }, + '/p3_%A4%A4%A4.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => $pageeuro, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --iri=no -nH -r http://localhost:{{port}}/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'index.html' => { + content => $pageindex, + }, + 'robots.txt' => { + content => "", + }, + "p1_fran${ccedilla_l15}ais.html" => { + content => $pagefrancais, + }, + "p2_${eacute_l1}${eacute_l1}n.html" => { + content => $pageeen, + }, + "p3_${eurosign_l15}${eurosign_l15}${eurosign_l15}.html" => { + content => $pageeuro, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-iri-disabled", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 + diff --git a/tests/Test-iri-forced-remote.px b/tests/Test-iri-forced-remote.px new file mode 100755 index 00000000..0d116d8f --- /dev/null +++ b/tests/Test-iri-forced-remote.px @@ -0,0 +1,208 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + +# cf. http://en.wikipedia.org/wiki/Latin1 +# http://en.wikipedia.org/wiki/ISO-8859-15 + +############################################################################### +# Force remote encoding to ISO-8859-1 +# +# mime : charset found in Content-Type HTTP MIME header +# meta : charset found in Content-Type meta tag +# +# index.html mime + file = iso-8859-15 +# p1_français.html meta + file = iso-8859-1, mime = utf-8 +# p2_één.html mime + file = iso-8859-1 +# p3_€€€.html meta + file = utf-8, mime = iso-8859-1 +# + +my $ccedilla_l15 = "\xE7"; +my $ccedilla_u8 = "\xC3\xA7"; +my $eacute_l1 = "\xE9"; +my $eacute_u8 = "\xC3\xA9"; +my $eurosign_l15 = "\xA4"; +my $eurosign_u8 = "\xE2\x82\xAC"; +my $eurosign2_u8 = "\xE2%82\xAC"; # version wget use... sXXXav +my $currency_l1 = "\xA4"; +my $currency_u8 = "\xC2\xA4"; + +my $pageindex = < + + Main Page + + +

+ Link to page 1 La seule page en français. + Link to page 3 My tailor is rich. +

+ + +EOF + +my $pagefrancais = < + + La seule page en français + + + +

+ Link to page 2 Die enkele nerderlangstalige pagina. +

+ + +EOF + +my $pageeen = < + + Die enkele nederlandstalige pagina + + +

+ Één is niet veel maar toch meer dan nul.
+ Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :) +

+ + +EOF + +my $pageeuro = < + + Euro page + + +

+ My tailor isn't rich anymore. +

+ + +EOF + +my $page404 = < + + 404 + + +

+ Nop nop nop... +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/index.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-15", + }, + content => $pageindex, + }, + '/robots.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => "", + }, + '/p1_fran%C3%A7ais.html' => { # UTF-8 encoded + code => "404", + msg => "File not found", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $page404, + }, + '/p1_fran%E7ais.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pagefrancais, + }, + '/p2_%C3%A9%C3%A9n.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pageeen, + }, + '/p2_%E9%E9n.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-1", + }, + content => $pageeen, + }, + '/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => $pageeuro, + }, + '/p3_%A4%A4%A4.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => $pageeuro, + }, + '/p3_%C2%A4%C2%A4%C2%A4.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => $pageeuro, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --iri --remote-encoding=iso-8859-1 -nH -r http://localhost:{{port}}/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'index.html' => { + content => $pageindex, + }, + 'robots.txt' => { + content => "", + }, + "p1_fran${ccedilla_l15}ais.html" => { + content => $pagefrancais, + }, + "p2_${eacute_u8}${eacute_u8}n.html" => { + content => $pageeen, + }, + "p3_${currency_u8}${currency_u8}${currency_u8}.html" => { + content => $pageeuro, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-iri-forced-remote", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 + diff --git a/tests/Test-iri.px b/tests/Test-iri.px new file mode 100755 index 00000000..3f4cf3fd --- /dev/null +++ b/tests/Test-iri.px @@ -0,0 +1,225 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + +# cf. http://en.wikipedia.org/wiki/Latin1 +# http://en.wikipedia.org/wiki/ISO-8859-15 + +############################################################################### +# +# mime : charset found in Content-Type HTTP MIME header +# meta : charset found in Content-Type meta tag +# +# index.html mime + file = iso-8859-15 +# p1_français.html meta + file = iso-8859-1, mime = utf-8 +# p2_één.html meta + file = utf-8, mime =iso-8859-1 +# p3_€€€.html meta + file = utf-8, mime = iso-8859-1 +# p4_méér.html mime + file = utf-8 +# + +my $ccedilla_l15 = "\xE7"; +my $ccedilla_u8 = "\xC3\xA7"; +my $eacute_l1 = "\xE9"; +my $eacute_u8 = "\xC3\xA9"; +my $eurosign_l15 = "\xA4"; +my $eurosign_u8 = "\xE2\x82\xAC"; +my $eurosign2_u8 = "\xE2%82\xAC"; # version wget use... sXXXav + +my $pageindex = < + + Main Page + + +

+ Link to page 1 La seule page en français. + Link to page 3 My tailor is rich. +

+ + +EOF + +my $pagefrancais = < + + La seule page en français + + + +

+ Link to page 2 Die enkele nerderlangstalige pagina. +

+ + +EOF + +my $pageeen = < + + Die enkele nederlandstalige pagina + + + +

+ Één is niet veel maar toch meer dan nul.
+ Nerdelands is een mooie taal... dit zin stuckje spreekt vanzelf, of niet :)
+ Méér +

+ + +EOF + +my $pageeuro = < + + Euro page + + + +

+ My tailor isn't rich anymore. +

+ + +EOF + +my $pagemeer = < + + Bekende supermarkt + + +

+ Ik ben toch niet gek ! +

+ + +EOF + +my $page404 = < + + 404 + + +

+ Nop nop nop... +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/index.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-15", + }, + content => $pageindex, + }, + '/robots.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + }, + content => "", + }, + '/p1_fran%C3%A7ais.html' => { # UTF-8 encoded + code => "404", + msg => "File not found", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $page404, + }, + '/p1_fran%E7ais.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pagefrancais, + }, + '/p2_%C3%A9%C3%A9n.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-1", + }, + content => $pageeen, + }, + '/p2_%E9%E9n.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-1", + }, + content => $pageeen, + }, + '/p3_%E2%82%AC%E2%82%AC%E2%82%AC.html' => { # UTF-8 encoded + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain; charset=ISO-8859-1", + }, + content => $pageeuro, + }, + '/p3_%A4%A4%A4.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain; charset=ISO-8859-1", + }, + content => $pageeuro, + }, + '/p4_m%C3%A9%C3%A9r.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain; charset=UTF-8", + }, + content => $pagemeer, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --iri -nH -r http://localhost:{{port}}/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'index.html' => { + content => $pageindex, + }, + 'robots.txt' => { + content => "", + }, + "p1_fran${ccedilla_l15}ais.html" => { + content => $pagefrancais, + }, + "p2_${eacute_u8}${eacute_u8}n.html" => { + content => $pageeen, + }, + "p3_${eurosign2_u8}${eurosign2_u8}${eurosign2_u8}.html" => { + content => $pageeuro, + }, + "p4_m${eacute_u8}${eacute_u8}r.html" => { + content => $pagemeer, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-iri", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 + diff --git a/tests/run-px b/tests/run-px index 37f14324..865246e3 100755 --- a/tests/run-px +++ b/tests/run-px @@ -19,6 +19,9 @@ my @tests = ( 'Test-HTTP-Content-Disposition-1.px', 'Test-HTTP-Content-Disposition-2.px', 'Test-HTTP-Content-Disposition.px', + 'Test-iri.px', + 'Test-iri-disabled.px', + 'Test-iri-forced-remote.px', 'Test-N-current.px', 'Test-N-smaller.px', 'Test-N-no-info.px', -- 2.39.2