diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:51 +0000 |
commit | 4f0770f3df78ecd5dcaefbd214f7a1415366bca6 (patch) | |
tree | 72661b8f81594b855bcc967b819263f63fa30e17 /debian/perl-framework/Apache-Test/t | |
parent | Adding upstream version 2.4.56. (diff) | |
download | apache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.tar.xz apache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.zip |
Adding debian version 2.4.56-1~deb11u2.debian/2.4.56-1_deb11u2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/perl-framework/Apache-Test/t')
26 files changed, 799 insertions, 0 deletions
diff --git a/debian/perl-framework/Apache-Test/t/TEST.PL b/debian/perl-framework/Apache-Test/t/TEST.PL new file mode 100644 index 0000000..bbdc93e --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/TEST.PL @@ -0,0 +1,42 @@ +use strict; + +use lib qw(lib ../lib); + +use warnings FATAL => 'all'; + +use Apache::TestRun (); + +package MyTest; + +use vars qw(@ISA); +@ISA = qw(Apache::TestRun); + +#subclass new_test_config to add some config vars which will +#be replaced in generated config, see t/conf/extra.conf.in + +#'make test' runs -clean by default, so to actually see the replacements: +#perl t/TEST apxs ... +#cat t/conf/extra.conf +#perl t/TEST -clean + +sub new_test_config { + my $self = shift; + + $self->{conf_opts}->{authname} = 'gold club'; + $self->{conf_opts}->{allowed_users} = 'dougm sterling'; + + return $self->SUPER::new_test_config; +} + +sub bug_report { + my $self = shift; + + print <<EOI; ++-----------------------------------------------------+ +| To report problems please refer to the SUPPORT file | ++-----------------------------------------------------+ +EOI +} + +MyTest->new->run(@ARGV); + diff --git a/debian/perl-framework/Apache-Test/t/alltest/01bang.t b/debian/perl-framework/Apache-Test/t/alltest/01bang.t new file mode 100644 index 0000000..3782ade --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/alltest/01bang.t @@ -0,0 +1,5 @@ +use Apache::Test; + +plan tests => 1; + +ok (0, 'this test should never run'); diff --git a/debian/perl-framework/Apache-Test/t/alltest/all.t b/debian/perl-framework/Apache-Test/t/alltest/all.t new file mode 100644 index 0000000..ef0033c --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/alltest/all.t @@ -0,0 +1,8 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; + +plan tests => 1, skip_reason('testing all.t'); + +ok 1; diff --git a/debian/perl-framework/Apache-Test/t/alltest2/01bang.t b/debian/perl-framework/Apache-Test/t/alltest2/01bang.t new file mode 100644 index 0000000..3782ade --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/alltest2/01bang.t @@ -0,0 +1,5 @@ +use Apache::Test; + +plan tests => 1; + +ok (0, 'this test should never run'); diff --git a/debian/perl-framework/Apache-Test/t/alltest2/all.t b/debian/perl-framework/Apache-Test/t/alltest2/all.t new file mode 100644 index 0000000..0393608 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/alltest2/all.t @@ -0,0 +1,8 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; + +plan tests => 1, skip_reason('testing more than one all.t'); + +ok 1; diff --git a/debian/perl-framework/Apache-Test/t/bad_coding.t b/debian/perl-framework/Apache-Test/t/bad_coding.t new file mode 100644 index 0000000..4e445a1 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/bad_coding.t @@ -0,0 +1,22 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +# This test tests how good Apache-Test deals with bad coding practices +# of its users + +plan tests => 1; + +{ + # passing $_ to a non-core function inside a foreach loop or + # similar, may affect $_ on return -- badly breaking things and + # making it hard to figure out where the problem is coming from. + # + # have_* macros localize $_ for these bad programming cases + # let's test that: + my @list = ('mod_dir'); + my %modules = map { $_, have_module($_) } @list; + ok 1; +} diff --git a/debian/perl-framework/Apache-Test/t/cgi-bin/cookies.pl.PL b/debian/perl-framework/Apache-Test/t/cgi-bin/cookies.pl.PL new file mode 100644 index 0000000..b409448 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/cgi-bin/cookies.pl.PL @@ -0,0 +1,16 @@ +#!perl -wT + +use strict; + +use CGI; +use CGI::Cookie; + +my %cookies = CGI::Cookie->fetch; +my $name = 'ApacheTest'; +my $c = ! exists $cookies{$name} + ? CGI::Cookie->new(-name=>$name, -value=>time) + : ''; + +print "Set-Cookie: $c\n" if $c; +print "Content-Type: text/plain\n\n"; +print ($c ? 'new' : 'exists'), "\n"; diff --git a/debian/perl-framework/Apache-Test/t/cgi-bin/next_available_port.pl.PL b/debian/perl-framework/Apache-Test/t/cgi-bin/next_available_port.pl.PL new file mode 100644 index 0000000..855b45b --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/cgi-bin/next_available_port.pl.PL @@ -0,0 +1,4 @@ +use strict; + +print "Content-Type: text/plain\n\n"; +print $ENV{NextAvailablePort} || ''; diff --git a/debian/perl-framework/Apache-Test/t/conf/extra.conf.in b/debian/perl-framework/Apache-Test/t/conf/extra.conf.in new file mode 100644 index 0000000..5d3a611 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/conf/extra.conf.in @@ -0,0 +1,46 @@ +#this file will be Include-d by @ServerRoot@/httpd.conf + +#the subclass inside t/TEST added the authname and allowed_users variables +<IfModule mod_alias.c> + Redirect /redirect http://@ServerName@/redirected/ +</IfModule> + +<IfModule mod_perl.c> + + <Location /TestMore__testpm> + SetHandler perl-script + <IfDefine APACHE2> + PerlResponseHandler TestMore::testpm + </IfDefine> + <IfDefine APACHE1> + PerlHandler TestMore::testpm + </IfDefine> + </Location> + + <Location /TestMore__testmorepm> + SetHandler perl-script + <IfDefine APACHE2> + PerlResponseHandler TestMore::testmorepm + </IfDefine> + <IfDefine APACHE1> + PerlHandler TestMore::testmorepm + </IfDefine> + </Location> +</IfModule> + + +<IfModule @CGI_MODULE@> + ScriptAlias /cgi-bin/ "@ServerRoot@/cgi-bin/" + + <Directory "@ServerRoot@/cgi-bin/"> + AllowOverride None + Options +ExecCGI + </Directory> + + # t/next_available_port.t + <IfModule mod_env.c> + SetEnv NextAvailablePort @NextAvailablePort@ + </IfModule> + +</IfModule> + diff --git a/debian/perl-framework/Apache-Test/t/conf/modperl_extra.pl.in b/debian/perl-framework/Apache-Test/t/conf/modperl_extra.pl.in new file mode 100644 index 0000000..e856cb5 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/conf/modperl_extra.pl.in @@ -0,0 +1,13 @@ +use strict; +use warnings FATAL => qw(all); + +use File::Spec (); + +use lib (); # empty so we can calculate the lib to use + +my @libs = (File::Spec->catfile('@ServerRoot@', 'response'), + File::Spec->catfile('@ServerRoot@', qw(.. lib))); + +lib->import(@libs); + +1; diff --git a/debian/perl-framework/Apache-Test/t/cookies.t b/debian/perl-framework/Apache-Test/t/cookies.t new file mode 100644 index 0000000..63f2a4d --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/cookies.t @@ -0,0 +1,18 @@ +# this test tests how a cookie jar can be passed (needs lwp) + +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; +use Apache::TestUtil; + +plan tests => 2, need [qw(CGI CGI::Cookie)], + need_cgi, need_lwp, need need_module('mod_alias.c'); + +Apache::TestRequest::user_agent( cookie_jar => {} ); + +my $url = '/cgi-bin/cookies.pl'; + +ok t_cmp GET_BODY($url), 'new', "new cookie"; +ok t_cmp GET_BODY($url), 'exists', "existing cookie"; diff --git a/debian/perl-framework/Apache-Test/t/import.t b/debian/perl-framework/Apache-Test/t/import.t new file mode 100644 index 0000000..1dbd747 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/import.t @@ -0,0 +1,145 @@ +#!perl + +use strict; +use warnings FATAL=>'all'; +use Test (); + +Test::plan tests=>47; + +sub t { + my $p=$_[0]; + no strict 'refs'; + Test::ok defined &{$p."::ok"} && \&{$p."::ok"}==\&Test::ok, + 1, "$p - ok"; + Test::ok defined &{$p."::need"} && \&{$p."::need"}==\&Apache::Test::need, + 1, "$p - need"; + Test::ok defined &{$p."::plan"} && \&{$p."::plan"}==\&Apache::Test::plan, + 1, "$p - plan"; +} + +sub tm { + my $p=$_[0]; + no strict 'refs'; + Test::ok defined &{$p."::ok"} && \&{$p."::ok"}==\&Test::More::ok, + 1, "$p - ok"; + Test::ok defined &{$p."::need"} && \&{$p."::need"}==\&Apache::Test::need, + 1, "$p - need"; + Test::ok defined &{$p."::plan"} && \&{$p."::plan"}==\&Apache::Test::plan, + 1, "$p - plan"; +} + +{package X0; use Apache::Test;} +{package Y0; use Apache::Test qw/-withtestmore/;} + +t 'X0'; +tm 'Y0'; + +{package X1; use Apache::Test qw/:DEFAULT/;} +{package Y1; use Apache::Test qw/-withtestmore :DEFAULT/;} + +t 'X1'; +tm 'Y1'; + +{package X2; use Apache::Test qw/!:DEFAULT/;} +{package Y2; use Apache::Test qw/-withtestmore !:DEFAULT/;} + +Test::ok !defined &X2::ok, 1, '!defined &X2::ok'; +Test::ok !defined &X2::need, 1, '!defined &X2::need'; +Test::ok !defined &X2::plan, 1, '!defined &X2::plan'; +Test::ok !defined &Y2::ok, 1, '!defined &Y2::ok'; +Test::ok !defined &Y2::need, 1, '!defined &Y2::need'; +Test::ok !defined &Y2::plan, 1, '!defined &Y2::plan'; + +{package X3; use Apache::Test qw/plan/;} +{package Y3; use Apache::Test qw/-withtestmore plan/;} + +Test::ok !defined &X3::ok, 1, '!defined &X3::ok'; +Test::ok !defined &X3::need, 1, '!defined &X3::need'; +Test::ok defined &X3::plan && \&X3::plan==\&Apache::Test::plan, 1, "X3 - plan"; +Test::ok !defined &Y3::ok, 1, '!defined &Y3::ok'; +Test::ok !defined &Y3::need, 1, '!defined &Y3::need'; +Test::ok defined &Y3::plan && \&Y3::plan==\&Apache::Test::plan, 1, "Y3 - plan"; + +{package X4; use Apache::Test qw/need/;} +{package Y4; use Apache::Test qw/-withtestmore need/;} + +Test::ok !defined &X4::ok, 1, '!defined &X4::ok'; +Test::ok defined &X4::need && \&X4::need==\&Apache::Test::need, 1, "X4 - need"; +Test::ok !defined &X4::plan, 1, '!defined &X4::plan'; +Test::ok !defined &Y4::ok, 1, '!defined &Y4::ok'; +Test::ok defined &Y4::need && \&Y4::need==\&Apache::Test::need, 1, "Y4 - need"; +Test::ok !defined &Y4::plan, 1, '!defined &Y4::plan'; + +{package X5; use Apache::Test qw/ok/;} +{package Y5; use Apache::Test qw/-withtestmore ok/;} + +Test::ok defined &X5::ok && \&X5::ok==\&Test::ok, 1, "X5 - ok"; +Test::ok !defined &X5::need, 1, '!defined &X5::need'; +Test::ok !defined &X5::plan, 1, '!defined &X5::plan'; +Test::ok defined &Y5::ok && \&Y5::ok==\&Test::More::ok, 1, "Y5 - ok"; +Test::ok !defined &Y5::need, 1, '!defined &Y5::need'; +Test::ok !defined &Y5::plan, 1, '!defined &Y5::plan'; + +{package X6; use Apache::Test qw/ok need/;} +{package Y6; use Apache::Test qw/-withtestmore ok need/;} + +Test::ok defined &X6::ok && \&X6::ok==\&Test::ok, 1, "X6 - ok"; +Test::ok defined &X6::need && \&X6::need==\&Apache::Test::need, 1, "X6 - need"; +Test::ok !defined &X6::plan, 1, '!defined &X6::plan'; +Test::ok defined &Y6::ok && \&Y6::ok==\&Test::More::ok, 1, "Y6 - ok"; +Test::ok defined &Y6::need && \&Y6::need==\&Apache::Test::need, 1, "Y6 - need"; +Test::ok !defined &Y6::plan, 1, '!defined &Y6::plan'; + +my $warning; +{ + local $SIG{__WARN__}=sub {$warning=join '', @_}; + eval <<'EVAL'; +package Z0; +use Apache::Test qw/:withtestmore/; +EVAL +} +Test::ok $warning, qr/^Ignoring import spec :withtestmore at/, + "Ignore import warning"; + +undef $warning; +{ + local $SIG{__WARN__}=sub {$warning=join '', @_}; + eval <<'EVAL'; +package X0; +use Apache::Test qw/-withtestmore/; +EVAL +} +Test::ok $warning, qr/^Ignoring -withtestmore due to a previous call /, + "Ignore -withtestmore warning"; + +use Config (); +my $pio=$Config::Config{useperlio} ? '' : 'need perlio'; +my $output; +Test::skip $pio, sub { + my @res; + { + local $Test::ntest=-19; + local $Test::planned=-42; + package Y2; # uses Apache::Test qw/-withtestmore !:DEFAULT/ + # so nothing is exported + + local *STDOUT; + open STDOUT, '>', \$output; + { + # suppress an 'uninitialized' warning in older perl versions + local $SIG{__WARN__}=sub { + warn $_[0] + unless $_[0]=~m!uninitialized\svalue\sin\sopen\b.+ + Test/Builder\.pm!x; + }; + Apache::Test::plan tests=>17; + } + Test::More::isnt "hugo", "erwin", "hugo is not erwin"; + @res=($Test::ntest, $Test::planned); + Test::Builder->new->reset; + } + return "@res"; +}, '-19 -42', '$Test::ntest, $Test::planned did not change'; + +Test::skip $pio, $output=~/^1\.\.17$/m; +Test::skip $pio, $output=~/^ok 1 - hugo is not erwin$/m; diff --git a/debian/perl-framework/Apache-Test/t/log_watch.t b/debian/perl-framework/Apache-Test/t/log_watch.t new file mode 100644 index 0000000..7a69f3f --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/log_watch.t @@ -0,0 +1,76 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestUtil qw/t_start_file_watch + t_read_file_watch + t_finish_file_watch + t_write_file + t_append_file + t_catfile + t_cmp/; + +plan tests => 11; + +my $fn=t_catfile(Apache::Test::vars->{t_logs}, 'watch'); +unlink $fn; + +t_start_file_watch 'watch'; + +t_write_file $fn, "1\n2\n"; + +ok t_cmp [t_read_file_watch 'watch'], ["1\n", "2\n"], + "t_read_file_watch on previously non-existing file"; + +t_append_file $fn, "3\n4\n"; + +ok t_cmp [t_read_file_watch 'watch'], ["3\n", "4\n"], + "subsequent t_read_file_watch"; + +t_append_file $fn, "5\n6\n"; + +ok t_cmp [t_finish_file_watch 'watch'], ["5\n", "6\n"], + "subsequent t_finish_file_watch"; + +ok t_cmp [t_finish_file_watch 'watch'], ["1\n","2\n","3\n","4\n","5\n","6\n"], + "t_finish_file_watch w/o start"; + +ok t_cmp [t_read_file_watch 'watch'], ["1\n","2\n","3\n","4\n","5\n","6\n"], + "t_read_file_watch w/o start"; + +ok t_cmp [t_read_file_watch 'watch'], [], + "subsequent t_read_file_watch"; + +t_append_file $fn, "7\n8\n"; +unlink $fn; + +ok t_cmp [t_read_file_watch 'watch'], ["7\n","8\n"], + "subsequent t_read_file_watch file unlinked"; + +t_write_file $fn, "1\n2\n3\n4\n5\n6\n7\n8\n"; + +ok t_cmp [t_finish_file_watch 'watch'], [], + "subsequent t_finish_file_watch - new file exists but fh is cached"; + +t_start_file_watch 'watch'; + +ok t_cmp [t_read_file_watch 'watch'], [], + "t_read_file_watch at EOF"; + +# Make sure the file is closed before deleting it on Windows. +t_finish_file_watch 'watch' if $^O eq 'MSWin32'; + +unlink $fn; +t_start_file_watch 'watch'; + +t_write_file $fn, "1\n2\n3\n4\n5\n6\n7\n8\n"; + +{ + local $/=\4; + + ok t_cmp [scalar t_read_file_watch 'watch'], ["1\n2\n"], + "t_read_file_watch fixed record length / scalar context"; + + ok t_cmp [t_finish_file_watch 'watch'], ["3\n4\n","5\n6\n","7\n8\n"], + "t_finish_file_watch fixed record length"; +} diff --git a/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t b/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t new file mode 100644 index 0000000..108e10c --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/log_watch_for_broken_lines.t @@ -0,0 +1,40 @@ +#!perl + +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestUtil qw/t_start_file_watch t_file_watch_for + t_cmp t_catfile t_append_file/; + +plan tests => 5, need_fork; + +my $fn=t_catfile(Apache::Test::vars->{t_logs}, 'watch'); +unlink $fn; + +t_start_file_watch 'watch'; + +my $pid; +select undef, undef, undef, 0.1 until defined($pid=fork); +unless ($pid) { # child + t_append_file $fn, "\nhuhu\n4 5 6 \nblabla\n"; + for(1..3) { + select undef, undef, undef, 0.3; + t_append_file $fn, "$_ "; + } + t_append_file $fn, "\nhuhu\n4 5 6 \nblabla"; + exit 0; +} + +ok t_cmp t_file_watch_for('watch', qr/^1 2 3 $/, 2), + "1 2 3 \n", 'incomplete line'; + +my @lines=t_file_watch_for('watch', qr/^\d \d \d $/, 2); +ok t_cmp @lines, 2, '2 lines'; +ok t_cmp $lines[0], "huhu\n", '1st line'; +ok t_cmp $lines[1], "4 5 6 \n", 'found it'; + +ok t_cmp t_file_watch_for('watch', qr/^\d \d \d $/, 0.3), + undef, 'timeout'; + +waitpid $pid, 0; diff --git a/debian/perl-framework/Apache-Test/t/more/01testpm.t b/debian/perl-framework/Apache-Test/t/more/01testpm.t new file mode 100644 index 0000000..0883e92 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/more/01testpm.t @@ -0,0 +1,8 @@ +# see the description in t/more/all.t + +use strict; +use warnings FATAL => qw(all); + +use Apache::TestRequest 'GET_BODY_ASSERT'; +print GET_BODY_ASSERT "/TestMore__testpm"; + diff --git a/debian/perl-framework/Apache-Test/t/more/02testmore.t b/debian/perl-framework/Apache-Test/t/more/02testmore.t new file mode 100644 index 0000000..440f39c --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/more/02testmore.t @@ -0,0 +1,8 @@ +# see the description in t/more/all.t + +use strict; +use warnings FATAL => qw(all); + +use Apache::TestRequest 'GET_BODY_ASSERT'; +print GET_BODY_ASSERT "/TestMore__testmorepm"; + diff --git a/debian/perl-framework/Apache-Test/t/more/03testpm.t b/debian/perl-framework/Apache-Test/t/more/03testpm.t new file mode 100644 index 0000000..0883e92 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/more/03testpm.t @@ -0,0 +1,8 @@ +# see the description in t/more/all.t + +use strict; +use warnings FATAL => qw(all); + +use Apache::TestRequest 'GET_BODY_ASSERT'; +print GET_BODY_ASSERT "/TestMore__testpm"; + diff --git a/debian/perl-framework/Apache-Test/t/more/04testmore.t b/debian/perl-framework/Apache-Test/t/more/04testmore.t new file mode 100644 index 0000000..440f39c --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/more/04testmore.t @@ -0,0 +1,8 @@ +# see the description in t/more/all.t + +use strict; +use warnings FATAL => qw(all); + +use Apache::TestRequest 'GET_BODY_ASSERT'; +print GET_BODY_ASSERT "/TestMore__testmorepm"; + diff --git a/debian/perl-framework/Apache-Test/t/more/all.t b/debian/perl-framework/Apache-Test/t/more/all.t new file mode 100644 index 0000000..c36a2dc --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/more/all.t @@ -0,0 +1,28 @@ +# skip all the Test::More tests if Test::More is +# not of a sufficient version; + +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; + +plan tests => 1, need need_min_module_version(qw(Test::More 0.48_01)), + need_module('mod_perl.c'); + +ok 1; + + +# the t/more/ directory is testing a few things. +# +# first, it is testing that the special +# Apache::Test qw(-withtestmore); +# import works, which allows Apache::Test to use +# Test::More as the backend (in place of Test.pm) +# for server-side tests. +# +# secondly, it is testing that we can intermix +# scripts that use Test.pm and Test::More as the +# backend, which was a bug that needed to be worked +# around in early implementations of -withtestmore. +# hence the reason for the specific ordering of the +# tests in t/more/. diff --git a/debian/perl-framework/Apache-Test/t/next_available_port.t b/debian/perl-framework/Apache-Test/t/next_available_port.t new file mode 100644 index 0000000..1eff85d --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/next_available_port.t @@ -0,0 +1,16 @@ +# this test tests how a cookie jar can be passed (needs lwp) + +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; +use Apache::TestUtil; + +plan tests => 1, need need_cgi, + need_module('mod_env.c'); + +my $url = '/cgi-bin/next_available_port.pl'; + +my $port = GET_BODY($url) || ''; +ok $port, qr/^\d+$/, "next available port number"; diff --git a/debian/perl-framework/Apache-Test/t/ping.t b/debian/perl-framework/Apache-Test/t/ping.t new file mode 100644 index 0000000..a84bf95 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/ping.t @@ -0,0 +1,17 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; + +plan tests => 3; + +my $config = Apache::Test::config(); + +ok $config; + +my $server = $config->server; + +ok $server; + +ok $server->ping; + diff --git a/debian/perl-framework/Apache-Test/t/redirect.t b/debian/perl-framework/Apache-Test/t/redirect.t new file mode 100644 index 0000000..6df2ef4 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/redirect.t @@ -0,0 +1,23 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 6, need need_module('mod_alias.c'), need_lwp; + +my $url = '/redirect'; + +# Allow request to be redirected. +ok my $res = GET $url; +ok ! $res->is_redirect; + +# Don't let request be redirected. +ok $res = GET($url, redirect_ok => 0); +ok $res->is_redirect; + +# Allow no more requests to be redirected. +Apache::TestRequest::user_agent(reset => 1, + requests_redirectable => 0); +ok $res = GET $url; +ok $res->is_redirect; diff --git a/debian/perl-framework/Apache-Test/t/request.t b/debian/perl-framework/Apache-Test/t/request.t new file mode 100644 index 0000000..63be945 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/request.t @@ -0,0 +1,28 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 9, \&need_lwp; + +my $url = '/index.html'; + +ok GET_OK $url; +ok GET_RC $url; +ok GET_STR $url; +ok GET_BODY $url; + +ok HEAD_OK $url; +ok HEAD_RC $url; +ok HEAD_STR $url; + +ok GET_OK $url, username => 'dougm', password => 'XXXX'; #e.g. for auth + +ok GET_OK $url, Referer => $0; #add headers + +#post a string +#ok POST_OK $url, content => 'post body data'; + +#or key/value pairs (see HTTP::Request::Common +#ok POST_OK $url, [university => 'arizona', team => 'wildcats'] diff --git a/debian/perl-framework/Apache-Test/t/response/TestMore/testmorepm.pm b/debian/perl-framework/Apache-Test/t/response/TestMore/testmorepm.pm new file mode 100644 index 0000000..12cb491 --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/response/TestMore/testmorepm.pm @@ -0,0 +1,21 @@ +package TestMore::testmorepm; + +use strict; +use warnings FATAL => qw(all); + +use Test::More; +use Apache::Test qw(-withtestmore); + +sub handler { + + plan shift, tests => 2; + + is (1, 1, 'called Test::More::is()'); + + like ('wow', qr/wow/, 'called Test::More::like()'); + + 0; + +} + +1; diff --git a/debian/perl-framework/Apache-Test/t/response/TestMore/testpm.pm b/debian/perl-framework/Apache-Test/t/response/TestMore/testpm.pm new file mode 100644 index 0000000..8c550ed --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/response/TestMore/testpm.pm @@ -0,0 +1,18 @@ +package TestMore::testpm; + +use strict; +use warnings FATAL => qw(all); + +use Apache::Test; +use Apache::TestUtil; + +sub handler { + + plan shift, tests => 1; + + ok t_cmp(1, 1, 'called Apache::Test::ok()'); + + 0; +} + +1; diff --git a/debian/perl-framework/Apache-Test/t/sok.t b/debian/perl-framework/Apache-Test/t/sok.t new file mode 100644 index 0000000..cb7efdb --- /dev/null +++ b/debian/perl-framework/Apache-Test/t/sok.t @@ -0,0 +1,168 @@ +#!perl + +use strict; +use warnings FATAL=>'all'; + +use Test (); +use Config (); +unless ($Config::Config{useperlio}) { + print "1..0 # need perlio\n"; + exit 0; +} + +Test::plan tests=>8; + +my $output; +{ + package X0; + use Apache::Test; + + local ($Test::planned, $Test::ntest, %Test::todo); + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}=""; + + plan tests=>3; + + sok {1}; + sok {1}; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2$/m && + $output=~/^ok 3$/m; + +{ + package Y0; + use Apache::Test qw/-withtestmore/; + + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}=""; + + plan tests=>3; + + sok {1}; + sok {1}; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2$/m && + $output=~/^ok 3$/m; + +{ + package X0; + + local ($Test::planned, $Test::ntest, %Test::todo); + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}="1 3"; + + plan tests=>3; + + sok {1}; + sok {1}; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2 # skip skipping this subtest$/mi && + $output=~/^ok 3$/m; + +{ + package Y0; + + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}="1 3"; + + plan tests=>3; + + sok {1}; + sok {1}; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2 # skip skipping this subtest$/mi && + $output=~/^ok 3$/m; + +{ + package X0; + + local ($Test::planned, $Test::ntest, %Test::todo); + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}=""; + + plan tests=>4; + + sok {1}; + sok {ok 1; 1} 2; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2$/m && + $output=~/^ok 3$/m && + $output=~/^ok 4$/m; + +{ + package Y0; + + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}=""; + + plan tests=>4; + + sok {1}; + sok {ok 1, "erwin"} 2; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2 - erwin$/m && + $output=~/^ok 3$/m && + $output=~/^ok 4$/m; + +{ + package X0; + + local ($Test::planned, $Test::ntest, %Test::todo); + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}="1 4"; + + plan tests=>4; + + sok {1}; + sok {ok 1; 1} 2; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2 # skip skipping this subtest$/mi && + $output=~/^ok 3 # skip skipping this subtest$/mi && + $output=~/^ok 4$/m; + +{ + package Y0; + + local *STDOUT; + open STDOUT, '>', \$output; + + local $ENV{HTTPD_TEST_SUBTESTS}="1 4"; + + plan tests=>4; + + sok {1}; + sok {ok 1} 2; + sok {1}; +} +Test::ok $output=~/^ok 1$/m && + $output=~/^ok 2 # skip skipping this subtest$/mi && + $output=~/^ok 3 # skip skipping this subtest$/mi && + $output=~/^ok 4$/m; |