C::P::Session::State::Cookie - improved tests (cookie_secure option)
KMX [Wed, 17 Jun 2009 08:23:20 +0000 (08:23 +0000)]
t/basic.t
t/lib/CookieTestApp.pm
t/live_app.t

index ec5e4c7..b9559a7 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -68,7 +68,7 @@ $cxt->set_session_id($sessionid);
 $res->called_ok( "cookies", "response cookie was set when sessionid changed" );
 is_deeply(
     \%res_cookies,
-    { session => { value => $sessionid, expires => 123 } },
+    { session => { value => $sessionid, httponly => 1, expires => 123 } },
     "cookie was set correctly"
 );
 
index 62da412..15fdeab 100644 (file)
@@ -6,6 +6,8 @@ use Catalyst qw/
   Session::State::Cookie
   /;
 
+__PACKAGE__->config->{session} = { cookie_secure => 2 };
+
 sub page : Local {
     my ( $self, $c ) = @_;
     $c->res->body( "Hi! hit number " . ++$c->session->{counter} );
index 0cdb75e..a103956 100644 (file)
@@ -56,3 +56,10 @@ cmp_ok( $expired, "<", $updated_expired, "streaming also extends cookie" );
 
 $m->get_ok( "http://localhost/deleteme", "get page" );
 $m->content_is( 1, 'session id changed' );
+
+$m->get_ok( "https://localhost/page", "get page over HTTPS - init session");
+$m->content_contains( "hit number 1", "first hit" );
+$m->get_ok( "http://localhost/page", "get page again over HTTP");
+$m->content_contains( "hit number 1", "first hit again - cookie not sent" );
+$m->get_ok( "https://localhost/page", "get page over HTTPS");
+$m->content_contains( "hit number 2", "second hit" );