Cookie
view release on metacpan or search on metacpan
t/CookieTest.pm view on Meta::CPAN
};
my $val = $c->value;
if( !$val->length )
{
return( $self->ok(0) );
}
if( !$c->is_valid( key => $CRYPT_KEY ) )
{
return( $self->ok(0) );
}
return( $self->ok(1) );
}
sub test12
{
my $self = shift( @_ );
my $jar = $self->jar;
my $c = $jar->get( 'signed_cookie' ) || do
{
return( $self->ok(0) );
};
my $val = $c->value;
if( !$val->length )
{
return( $self->ok(0) );
}
if( !$c->is_valid( key => $CRYPT_KEY ) )
{
return( $self->ok(1) );
}
return( $self->ok(0) );
}
1;
__END__
=encoding utf8
=head1 NAME
CookieTest - Cookie Testing Class
=head1 SYNOPSIS
In the Apache test conf:
PerlModule Cookie::Jar
PerlOptions +GlobalRequest
PerlSetupEnv On
<Directory "@documentroot@">
SetHandler modperl
PerlResponseHandler CookieTest
AcceptPathInfo On
</Directory>
In the test unit:
use Apache::Test;
use Apache::TestRequest;
use HTTP::Request;
my $config = Apache::Test::config();
my $hostport = Apache::TestRequest::hostport( $config ) || '';
my $jar = Cookie::Jar->new( debug => $DEBUG );
my $ua = Apache::TestRequest->new;
my $req = HTTP::Request->new( GET => "http://${hostport}/tests/test01" );
$req->header( Host => $hostport );
my $resp = $ua->request( $req );
ok( $resp->content, 'ok' );
=head1 VERSION
v0.1.0
=head1 DESCRIPTION
This is a package for testing the L<Cookie> module under Apache2/modperl2
=head1 METHODS
=head2 handler
The main handler method called by modperl.
It calls the right method based on the last fragment of the path. For example an http request to C</test/test02> would call the method C<test02>
It returns the value returned by the method called, which should be an Apache constant.
=head2 failure
Calls L</reply> with C<Apache2::Const::HTTP_EXPECTATION_FAILED> and C<failed> and returns its value, which is the http code.
=head2 is
Provided with a resulting value and an expected value and this returns C<ok> if both match, or a string explaining the failure to match.
=head2 ok
Provided with a boolean value, and this returns the value returned by L</success> or L</failure> otherwise.
=head2 reply
Provided with a response http code and some text data, and this will return the response to the http client.
=head2 success
Calls L</reply> with C<Apache2::Const::HTTP_OK> and C<ok> and returns its value, which is the http code.
=head1 AUTHOR
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
=head1 SEE ALSO
L<Cookie::Jar>, L<Cookie>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2019-2021 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.594 second using v1.01-cache-2.11-cpan-98e64b0badf )