Apache2-API
view release on metacpan or search on metacpan
t/lib/Test/Apache2/API.pm view on Meta::CPAN
$json->canonical &&
$json->get_relaxed &&
$json->get_utf8 &&
$json->get_allow_nonref &&
$json->get_allow_blessed &&
$json->get_convert_blessed );
}, args => [pretty => 1, ordered => 1, relaxed => 1, utf8 => 1, allow_nonref => 1, allow_blessed => 1, convert_blessed => 1] }) ); }
sub reply
{
return( shift->api->reply( Apache2::Const::HTTP_OK => {
message => "ok",
}) );
}
sub server { return( shift->_test({ method => 'server', expect => 'Apache2::ServerRec', type => 'isa' }) ); }
sub server_version { return( shift->_test({ method => 'server_version', expect => 'version', type => 'isa' }) ); }
sub _target { return( shift->api ); }
1;
# NOTE: POD
# Use this to generate the tests list:
# egrep -E '^sub ' ./t/lib/Test/Apache2/API.pm | perl -lnE 'my $m = [split(/\s+/, $_)]->[1]; say "=head2 $m\n"'
__END__
=encoding utf8
=head1 NAME
Test::Apache2::API - Apache2::API Testing Class
=head1 SYNOPSIS
In the Apache test conf:
PerlModule Apache2::API
PerlOptions +GlobalRequest
PerlSetupEnv On
<Directory "@documentroot@">
SetHandler modperl
PerlResponseHandler Test::Apache2::API
AcceptPathInfo On
</Directory>
In the test unit:
use Apache::Test;
use Apache::TestRequest;
use HTTP::Request;
my $hostport = Apache::TestRequest::hostport( $config ) || '';
my( $host, $port ) = split( ':', ( $hostport ) );
my $mp_host = 'www.example.org';
Apache::TestRequest::user_agent(reset => 1, keep_alive => 1 );
my $ua = Apache::TestRequest->new;
# To get the fingerprint for the certificate in ./t/server.crt, do:
# echo "sha1\$$(openssl x509 -noout -in ./t/server.crt -fingerprint -sha1|perl -pE 's/^.*Fingerprint=|(\w{2})(?:\:?|$)/$1/g')"
$ua->ssl_opts(
# SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
# SSL_verify_mode => 0x00
# verify_hostname => 0,
SSL_fingerprint => 'sha1$DEE8650E44870896E821AAE4A5A24382174D100E',
# SSL_version => 'SSLv3',
# SSL_verfifycn_name => 'localhost',
);
my $req = HTTP::Request->new( 'GET' => "${proto}://${hostport}/tests/api/some_method" );
my $resp = $ua->request( $req );
is( $resp->code, Apache2::Const::HTTP_OK, 'some test name' );
=head1 VERSION
v0.1.0
=head1 DESCRIPTION
This is a package for testing the L<Apache2::API> module under Apache2/modperl2
=head1 TESTS
The following tests are performed:
=head2 compression_threshold
=head2 decode_json
=head2 encode_decode_url
=head2 auth
=head2 header_datetime
=head2 is_perl_option_enabled
=head2 json
=head2 reply
=head2 server
=head2 server_version
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Apache2::API>, L<Apache::Test>, L<Apache::TestUtil>, L<Apache::TestRequest>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2019-2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
=cut
( run in 0.521 second using v1.01-cache-2.11-cpan-13bb782fe5a )