CGI-Application-Plugin-Session
view release on metacpan or search on metacpan
t/11_sessiondelete.t view on Meta::CPAN
# with an expire timestamp in the past.
# need to inject session into $query - this is done by an environment var
$ENV{HTTP_COOKIE} = "CGISESSID=$id1";
my $query = new CGI({ rm => 'logout' });
$t1_obj = TestAppSessionDelete->new( QUERY => $query );
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
like($t1_output, qr/Set-Cookie: CGISESSID=;/, 'delete session cookie in output');
my ( $new_expiry ) = $t1_output =~ /expires=(.+)\s+Date/;
ok( $original_expiry ne $new_expiry, 'expirations are different' );
t/11_sessiondelete.t view on Meta::CPAN
$ENV{HTTP_COOKIE} = "CGISESSID=$id1";
$query = new CGI({ rm => 'logout' });
$t1_obj = TestAppSessionDelete->new( QUERY => $query );
$t1_obj->header_add( -cookie => [ CGI::Cookie->new( -name => 'test', -value => 'testing' ) ]);
$t1_obj->header_add( -cookie => [ 'test2=testing2; path=/' ]);
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
like($t1_output, qr/Set-Cookie: CGISESSID=;/, 'delete session cookie in output');
# Was the test cookie in the output? It should be
like($t1_output, qr/Set-Cookie: test=testing/, 'test cookie in output');
t/11_sessiondelete.t view on Meta::CPAN
$ENV{HTTP_COOKIE} = "CGISESSID=$id1";
$query = new CGI({ rm => 'logout' });
$t1_obj = TestAppSessionDelete->new( QUERY => $query );
$t1_obj->session; # this sets the session cookie
$t1_obj->header_add( -cookie => 'test2=testing2; path=/'); # this clobbers the session cookie
$t1_output = $t1_obj->run();
# vanilla output came through ok?
ok( $t1_output =~ /logout finished/, 'vanilla output came through ok' );
# If that didn't pass, then I'm guessing the session wasn't injected properly
# Was the session create cookie in the output? It shouldn't be
unlike($t1_output, qr/Set-Cookie: CGISESSID=[a-zA-Z0-9]+/, 'new session cookie not in output');
# Was the session delete cookie in the output? It should be
like($t1_output, qr/Set-Cookie: CGISESSID=;/, 'delete session cookie in output');
# Was the test cookie in the output? It should be
like($t1_output, qr/Set-Cookie: test2=testing2/, 'test cookie in output');
( run in 0.543 second using v1.01-cache-2.11-cpan-748bfb374f4 )