From a3eed2c248067f0319cb72bcc8b5e2c7054ea6dc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2024 05:06:57 +0200 Subject: Adding upstream version 1.20.1. Signed-off-by: Daniel Baumann --- tests/Test-np.px | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100755 tests/Test-np.px (limited to 'tests/Test-np.px') diff --git a/tests/Test-np.px b/tests/Test-np.px new file mode 100755 index 0000000..ed8b30b --- /dev/null +++ b/tests/Test-np.px @@ -0,0 +1,147 @@ +#!/usr/bin/env -S perl -I . + +use strict; +use warnings; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text and a link to a second page. +

+ + +EOF + +my $secondpage = < + + Second Page + + +

+ Some text and a link to a third page. +

+ + +EOF + +my $thirdpage = < + + Third Page + + +

+ Some text and a link to a higher level page. +

+ + +EOF + +my $fourthpage = < + + Fourth Page + + +

+ This page is only linked by the higher level page. Therefore, it should not + be downloaded. +

+ + +EOF + +my $higherlevelpage = < + + Higher Level Page + + +

+ This page is on a higher level in the URL path hierarchy. Therefore, it + should not be downloaded. Wget should not visit the following link to a + fourth page. +

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/firstlevel/index.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $mainpage, + }, + '/firstlevel/secondpage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $secondpage, + }, + '/firstlevel/lowerlevel/thirdpage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/html", + }, + content => $thirdpage, + }, + '/firstlevel/fourthpage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => $fourthpage, + }, + '/higherlevelpage.html' => { + code => "200", + msg => "Dontcare", + headers => { + "Content-type" => "text/plain", + }, + content => $higherlevelpage, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:{{port}}/firstlevel/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'firstlevel/index.html' => { + content => $mainpage, + }, + 'firstlevel/secondpage.html' => { + content => $secondpage, + }, + 'firstlevel/lowerlevel/thirdpage.html' => { + content => $thirdpage, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 -- cgit v1.2.3