From: Devin Austin Date: Thu, 14 May 2009 07:58:07 +0000 (+0000) Subject: moved tests out and into t/lib/ X-Git-Tag: v1.010~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=861c2f44050dc2e9e4388353d5939ad8008b3a5a;hp=40918fd153c5228b2dc37c53c8c04617018b35a0;p=catagits%2FCatalyst-Authentication-Credential-HTTP.git moved tests out and into t/lib/ --- diff --git a/t/lib/AuthDigestTestApp.pm b/t/lib/AuthDigestTestApp.pm new file mode 100644 index 0000000..101ddec --- /dev/null +++ b/t/lib/AuthDigestTestApp.pm @@ -0,0 +1,40 @@ +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", }, + Mufasa2 => { pass => $digest_pass->hexdigest, }, + ); + __PACKAGE__->config->{cache}{backend} = { + class => 'Cache::FileCache', + }; + __PACKAGE__->config( authentication => { + default_realm => 'testrealm@host.com', + realms => { + 'testrealm@host.com' => { + store => { + class => 'Minimal', + users => \%users, + }, + credential => { + class => 'HTTP', + type => 'digest', + password_type => 'clear', + password_field => 'pass' + }, + }, + }, + }); + __PACKAGE__->setup; diff --git a/t/lib/AuthTestApp.pm b/t/lib/AuthTestApp.pm new file mode 100644 index 0000000..2b8f44a --- /dev/null +++ b/t/lib/AuthTestApp.pm @@ -0,0 +1,34 @@ +package AuthTestApp; + use Catalyst qw/ + Authentication + /; + our %users; + __PACKAGE__->config(authentication => { + default_realm => 'test', + realms => { + 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; diff --git a/t/live_app.t b/t/live_app.t index e9b9ea0..05cb3a0 100644 --- a/t/live_app.t +++ b/t/live_app.t @@ -9,43 +9,8 @@ BEGIN { plan tests => 4; } use HTTP::Request; -{ - package AuthTestApp; - use Catalyst qw/ - Authentication - /; - use Test::More; - our %users; - __PACKAGE__->config(authentication => { - default_realm => 'test', - realms => { - 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; -} + +use Test::More; use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; my $mech = Test::WWW::Mechanize::Catalyst->new; $mech->get("http://localhost/moose"); diff --git a/t/live_app_digest.t b/t/live_app_digest.t index b77d256..95e9c3f 100644 --- a/t/live_app_digest.t +++ b/t/live_app_digest.t @@ -16,49 +16,8 @@ BEGIN { } use Digest::MD5; use HTTP::Request; -{ - package AuthTestApp; - use Catalyst qw/ - Authentication - Cache - /; - use Test::More; - 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", }, - Mufasa2 => { pass => $digest_pass->hexdigest, }, - ); - __PACKAGE__->config->{cache}{backend} = { - class => 'Cache::FileCache', - }; - __PACKAGE__->config( authentication => { - default_realm => 'testrealm@host.com', - realms => { - 'testrealm@host.com' => { - store => { - class => 'Minimal', - users => \%users, - }, - credential => { - class => 'HTTP', - type => 'digest', - password_type => 'clear', - password_field => 'pass' - }, - }, - }, - }); - __PACKAGE__->setup; -} -use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; +use Test::More; +use Test::WWW::Mechanize::Catalyst qw/AuthDigestTestApp/; sub do_test { my $username = shift;