From: Tomas Doran Date: Sun, 7 Mar 2010 21:05:57 +0000 (+0000) Subject: Move actions out of test app X-Git-Tag: v1.012~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d941289628aa271d9015d709290dcc9ef5d6395f;hp=ac0351e16fa05aaed6d887258256374cad670497;p=catagits%2FCatalyst-Authentication-Credential-HTTP.git Move actions out of test app --- diff --git a/t/lib/AuthDigestTestApp.pm b/t/lib/AuthDigestTestApp.pm index 101ddec..309cf5f 100644 --- a/t/lib/AuthDigestTestApp.pm +++ b/t/lib/AuthDigestTestApp.pm @@ -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 index 0000000..afef812 --- /dev/null +++ b/t/lib/AuthDigestTestApp/Controller/Root.pm @@ -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; + diff --git a/t/lib/AuthTestApp.pm b/t/lib/AuthTestApp.pm index 2b8f44a..c8300df 100644 --- a/t/lib/AuthTestApp.pm +++ b/t/lib/AuthTestApp.pm @@ -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 index 0000000..cf8b22e --- /dev/null +++ b/t/lib/AuthTestApp/Controller/Root.pm @@ -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; +