Move actions out of test app
Tomas Doran [Sun, 7 Mar 2010 21:05:57 +0000 (21:05 +0000)]
t/lib/AuthDigestTestApp.pm
t/lib/AuthDigestTestApp/Controller/Root.pm [new file with mode: 0644]
t/lib/AuthTestApp.pm
t/lib/AuthTestApp/Controller/Root.pm [new file with mode: 0644]

index 101ddec..309cf5f 100644 (file)
@@ -1,26 +1,23 @@
 package AuthDigestTestApp;
-    use Catalyst qw/
-      Authentication
-      Cache
-      /;
-    
-    our %users;
-    sub moose : Local {
-        my ( $self, $c ) = @_;
-        #$c->authenticate( { realm => 'testrealm@host.com' } );
-        $c->authenticate();
-        $c->res->body( $c->user->id );
-    }
-    my $digest_pass = Digest::MD5->new;
-    $digest_pass->add('Mufasa2:testrealm@host.com:Circle Of Life');
-    %users = ( 
-        Mufasa  => { pass         => "Circle Of Life",          }, 
+use Catalyst qw/
+    Authentication
+    Cache
+/;
+
+our %users;
+my $digest_pass = Digest::MD5->new;
+$digest_pass->add('Mufasa2:testrealm@host.com:Circle Of Life');
+%users = (
+        Mufasa  => { pass         => "Circle Of Life",          },
         Mufasa2 => { pass         => $digest_pass->hexdigest, },
-    );
-    __PACKAGE__->config->{cache}{backend} = {
-        class => 'Cache::FileCache',
-    };
-    __PACKAGE__->config( authentication => {
+);
+__PACKAGE__->config(
+    cache => {
+        backend => {
+            class => 'Cache::FileCache',
+        },
+    },
+    authentication => {
         default_realm => 'testrealm@host.com',
         realms => {
             'testrealm@host.com' => {
@@ -31,10 +28,14 @@ package AuthDigestTestApp;
                 credential => {
                     class => 'HTTP',
                     type  => 'digest',
-                    password_type => 'clear', 
+                    password_type => 'clear',
                     password_field => 'pass'
                 },
             },
         },
-    });
-    __PACKAGE__->setup;
+    },
+);
+__PACKAGE__->setup;
+
+1;
+
diff --git a/t/lib/AuthDigestTestApp/Controller/Root.pm b/t/lib/AuthDigestTestApp/Controller/Root.pm
new file mode 100644 (file)
index 0000000..afef812
--- /dev/null
@@ -0,0 +1,17 @@
+package AuthDigestTestApp::Controller::Root;
+use strict;
+use warnings;
+
+use base qw/ Catalyst::Controller /;
+
+__PACKAGE__->config(namespace => '');
+
+sub moose : Local {
+    my ( $self, $c ) = @_;
+    #$c->authenticate( { realm => 'testrealm@host.com' } );
+    $c->authenticate();
+    $c->res->body( $c->user->id );
+}
+
+1;
+
index 2b8f44a..c8300df 100644 (file)
@@ -1,34 +1,29 @@
 package AuthTestApp;
-    use Catalyst qw/
-      Authentication
-      /;
-    our %users;
-    __PACKAGE__->config(authentication => {
+use Catalyst qw/
+    Authentication
+/;
+our %users;
+__PACKAGE__->config(
+    'Plugin::Authentication' => {
         default_realm => 'test',
-        realms => {
-            test => {
-                store => { 
-                    class => 'Minimal',
-                    users => \%users,
-                },
-                credential => { 
-                    class => 'HTTP', 
-                    type  => 'basic',
-                    password_type => 'clear', 
-                    password_field => 'password'
-                },
+        test => {
+            store => {
+                class => 'Minimal',
+                users => \%users,
+            },
+            credential => {
+                class => 'HTTP',
+                type  => 'basic',
+                password_type => 'clear',
+                password_field => 'password'
             },
         },
-    });
-    sub auto : Private {
-        my ($self, $c) = @_;
-        $c->authenticate();
-    }
-    sub moose : Local {
-        my ( $self, $c ) = @_;
-           $c->res->body( $c->user->id );
-    }
-    %users = (
-        foo => { password         => "s3cr3t", },
-    );
-    __PACKAGE__->setup;
+    },
+);
+%users = (
+    foo => { password         => "s3cr3t", },
+);
+__PACKAGE__->setup;
+
+1;
+
diff --git a/t/lib/AuthTestApp/Controller/Root.pm b/t/lib/AuthTestApp/Controller/Root.pm
new file mode 100644 (file)
index 0000000..cf8b22e
--- /dev/null
@@ -0,0 +1,19 @@
+package AuthTestApp::Controller::Root;
+use strict;
+use warnings;
+
+use base qw/ Catalyst::Controller /;
+
+__PACKAGE__->config( namespace => '' );
+
+sub auto : Private {
+    my ($self, $c) = @_;
+    $c->authenticate();
+}
+sub moose : Local {
+    my ( $self, $c ) = @_;
+    $c->res->body( $c->user->id );
+}
+
+1;
+