RequireSSL 0.06, no_cache option, work properly under restarter and POE servers v0.06
Andy Grundman [Tue, 6 Mar 2007 16:27:13 +0000 (16:27 +0000)]
Changes
META.yml
Makefile.PL
lib/Catalyst/Plugin/RequireSSL.pm
t/07no_cache.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 9548c65..af4d8eb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,9 @@
 Revision history for Perl extension Catalyst::Plugin::RequireSSL
 
-0.06
-        - Fixed to support additional HTTP engines.
+0.06    2007-03-06 11:00:00
+        - Added no_cache config option to support wildcard SSL certificates.
+          (Simon Elliott)
+        - Disable properly when running under other development HTTP servers.
 
 0.05    2005-09-15 12:15:00
         - Updated skipped tests to run if Catalyst >= 5.5.
index b00bbf3..ba394ab 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,14 +1,19 @@
 ---
 name: Catalyst-Plugin-RequireSSL
-version: 0.05
+version: 0.06
 author:
   - 'Andy Grundman, <andy@hybridized.org>'
 abstract: Force SSL mode on select pages
 license: perl
+resources:
+  license: http://dev.perl.org/licenses/
 requires:
   Catalyst: 5.23
 provides:
   Catalyst::Plugin::RequireSSL:
     file: lib/Catalyst/Plugin/RequireSSL.pm
-    version: 0.05
-generated_by: Module::Build version 0.2611
+    version: 0.06
+generated_by: Module::Build version 0.2806
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2
index 51d31fd..192903a 100644 (file)
       
       # Save this 'cause CPAN will chdir all over the place.
       my $cwd = Cwd::cwd();
-      my $makefile = File::Spec->rel2abs($0);
       
-      CPAN::Shell->install('Module::Build::Compat')
-       or die " *** Cannot install without Module::Build.  Exiting ...\n";
+      CPAN::Shell->install('Module::Build::Compat');
+      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
+       or die "Couldn't install Module::Build, giving up.\n";
       
       chdir $cwd or die "Cannot chdir() back to $cwd: $!";
     }
     eval "use Module::Build::Compat 0.02; 1" or die $@;
-    use lib '_build/lib';
+    
     Module::Build::Compat->run_build_pl(args => \@ARGV);
     require Module::Build;
     Module::Build::Compat->write_makefile(build_class => 'Module::Build');
index 0b72c8a..8bed9ab 100644 (file)
@@ -64,8 +64,6 @@ sub setup {
 
     # disable the plugin when running under certain engines which don't
     # support SSL
-    # XXX: I didn't include Catalyst::Engine::Server here as it may be used as
-    # a backend in a proxy setup.
     if ( $c->engine =~ /Catalyst::Engine::HTTP/ ) {
         $c->config->{require_ssl}->{disabled} = 1;
         $c->log->warn( "RequireSSL: Disabling SSL redirection while running "
@@ -103,10 +101,12 @@ sub _redirect_uri {
             }
         }
         $redir .= '?' . join( '&', @params );
-    }        
-       if($c->config->{require_ssl}->{'no_cache'}) {           
-           $c->config->{require_ssl}->{$type} = undef;
+    }  
+          
+       if ( $c->config->{require_ssl}->{no_cache} ) {          
+           delete $c->config->{require_ssl}->{$type};
        }
+       
     return $redir;
 }
 
@@ -174,7 +174,7 @@ users will be redirected back to non-SSL mode as soon as possible.
        no_cache 
 
 If you have a wildcard certificate you will need to set this option if you are
-using multiple domains on one instance of catalyst.
+using multiple domains on one instance of Catalyst.
 
 =head1 METHODS
 
diff --git a/t/07no_cache.t b/t/07no_cache.t
new file mode 100644 (file)
index 0000000..0ac682d
--- /dev/null
@@ -0,0 +1,22 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 4;
+use Catalyst::Test 'TestApp';
+
+TestApp->config->{require_ssl} = {
+    no_cache => 1,
+};
+
+# test an SSL redirect
+ok( my $res = request('http://localhost/ssl/secured'), 'request ok' );
+is( $res->code, 302, 'redirect code ok' );
+is( $res->header('location'), 'https://localhost/ssl/secured', 'redirect uri ok' );
+
+# test that the http/https server info wasn't cached
+ok( !TestApp->config->{https}, 'domain was not cached' );
\ No newline at end of file