Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:sukria/Dancer-Session-Cookie

Conflicts:
	Changes
  • Loading branch information...
commit 98628c38e2d03bf31ca07065403a4f45f6cafed0 2 parents bffe0af + 99e66d8
@kappa kappa authored
View
19 Changes
@@ -1,8 +1,21 @@
Revision history for Dancer-Session-Cookie
-0.15 Fri Mar 11 13:58:56 MSK 2011
- New setting session_cookie_path.
- Support global settings session_name and session_secure.
+0.15 2011-05-21
+
+ * skip test 02-configfile.t if YAML is not present
+ FIX smoker test failure.
+ (Alexis Sukrieh)
+
+0.14 2011-03-12
+
+ [ Michael G. Schwern ]
+
+ * Fix for Dancer > v1.3012
+ * Add support for session_secure to serve https only cookies.
+ * Add missing MYMETA.yml
+ * Make Dancer::Session::Cookie honor the session_name setting
+ added to Dancer::Session::Abstract
+ * Add session_cookie_path to control the path of the cookie.
0.13 Sun Nov 28 17:19:58 MSK 2010
Some documentation fixes. No functional change.
View
6 MANIFEST
@@ -7,5 +7,11 @@ MANIFEST.SKIP
README
t/00-load.t
t/01-session.t
+t/02-configfile.t
+t/03-path.t
+t/03-server.t
+t/04-session_name.t
+t/05-session_secure.t
+t/data/config.yml
t/manifest.t
t/pod.t
View
1  MANIFEST.SKIP
@@ -2,5 +2,6 @@
^blib/
pm_to_blib
^Makefile$
+\.old
MANIFEST.bak
t/logs/
View
8 lib/Dancer/Session/Cookie.pm
@@ -8,8 +8,8 @@ use Crypt::CBC;
use String::CRC32;
use Crypt::Rijndael;
+use Dancer ();
use Dancer::Config 'setting';
-use Dancer::ModuleLoader;
use Storable ();
use MIME::Base64 ();
@@ -76,13 +76,13 @@ sub flush {
my $cipher_text = _encrypt(Storable::freeze($self));
my $session_name = $self->session_name;
- Dancer::Cookies->cookies->{$session_name} = Dancer::Cookie->new(
- name => $session_name,
- value => $cipher_text,
+ Dancer::set_cookie(
+ $session_name => $cipher_text,
path => setting("session_cookie_path") || "/",
secure=> setting("session_secure"),
);
$self->{id} = $cipher_text;
+
return 1;
}
View
9 t/02-configfile.t
@@ -6,13 +6,14 @@ use strict;
use warnings;
use Dancer;
use Dancer::ModuleLoader;
+use Dancer::Session::Cookie;
use FindBin;
use File::Spec;
-BEGIN {
- plan tests => 4;
- use_ok 'Dancer::Session::Cookie'
-}
+eval "use YAML";
+plan skip_all => "YAML is needed for this test" if $@;
+
+plan tests => 3;
my $session;
View
70 t/03-server.t
@@ -0,0 +1,70 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More import => ["!pass"];
+
+plan skip_all => "Test::TCP required" unless eval {
+ require Test::TCP; Test::TCP->import; 1;
+};
+
+plan skip_all => "LWP required" unless eval {
+ require LWP;
+};
+
+test_tcp(
+ client => sub {
+ my $port = shift;
+
+ require LWP::UserAgent;
+ require HTTP::Cookies;
+
+ my $ua = LWP::UserAgent->new;
+
+ # Simulate two different browsers with two different jars
+ my @jars = (HTTP::Cookies->new, HTTP::Cookies->new);
+ for my $jar (@jars) {
+ $ua->cookie_jar( $jar );
+
+ my $res = $ua->get("http://0.0:$port/foo");
+ is $res->content, "hits: 0, last_hit: ";
+
+ $res = $ua->get("http://0.0:$port/bar");
+ is $res->content, "hits: 1, last_hit: foo";
+
+ $res = $ua->get("http://0.0:$port/baz");
+ is $res->content, "hits: 2, last_hit: bar";
+ }
+
+ $ua->cookie_jar($jars[0]);
+ my $res = $ua->get("http://0.0:$port/wibble");
+ is $res->content, "hits: 3, last_hit: baz", "session not overwritten";
+ },
+ server => sub {
+ my $port = shift;
+
+ use Dancer ':tests', ':syntax';
+
+ set port => $port;
+ set appdir => ''; # quiet warnings not having an appdir
+ set access_log => 0; # quiet startup banner
+
+ set session_cookie_key => "John has a long mustache";
+ set session => "cookie";
+
+ get "/*" => sub {
+ my $hits = session("hit_counter") || 0;
+ my $last = session("last_hit") || '';
+
+ session hit_counter => $hits + 1;
+ session last_hit => (splat)[0];
+
+ return "hits: $hits, last_hit: $last";
+ };
+
+ dance;
+ }
+);
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.