Skip Menu |

This queue is for tickets about the CGI-Application-Plugin-Authentication CPAN distribution.

Report information
The Basics
Id: 24547
Status: resolved
Priority: 0/
Queue: CGI-Application-Plugin-Authentication

People
Owner: Nobody in particular
Requestors: stennie [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.12
Fixed in: (no value)



Subject: Some tests fail without CGI::Application::Plugin::Session
If CGI::Application::Plugin::Session is not installed, these tests fail: t/60_store t/60_store_session Updated tests and diffs attached. Cheers, Stephen
Subject: test.patch
--- dist/60_store.t 2006-10-01 07:43:15.000000000 +1000 +++ t/60_store.t 2007-01-25 08:33:21.000000000 +1100 @@ -7,7 +7,13 @@ use Test::More; use Test::Exception; -plan tests => 17; + +eval "use CGI::Application::Plugin::Session;"; +if ($@) { + plan skip_all => "CGI::Application::Plugin::Session required for this test"; +} else { + plan tests => 17; +} our %STORAGE; @@ -16,7 +22,7 @@ package TestAppStoreDummy; use base qw(TestAppStore); - use CGI::Application::Plugin::Session; + CGI::Application::Plugin::Session->import; # it was used conditionally above __PACKAGE__->authen->config( DRIVER => [ 'Generic', { 'test' => '123' } ], --- dist/60_store_session.t 2006-10-01 07:43:15.000000000 +1000 +++ t/60_store_session.t 2007-01-25 08:33:15.000000000 +1100 @@ -6,14 +6,20 @@ use CGI::Util; use Test::More; -plan tests => 14; + +eval "use CGI::Application::Plugin::Session;"; +if ($@) { + plan skip_all => "CGI::Application::Plugin::Session required for this test"; +} else { + plan tests => 14; +} { package TestAppStoreSession; use base qw(TestAppStore); - use CGI::Application::Plugin::Session; + CGI::Application::Plugin::Session->import; # it was used conditionally above __PACKAGE__->authen->config( DRIVER => [ 'Generic', { 'test' => '123' } ],
t/60_store.t t/60_store_session.t
#!/usr/bin/perl use strict; use warnings; use lib qw(t); use CGI::Util; use Test::More; eval "use CGI::Application::Plugin::Session;"; if ($@) { plan skip_all => "CGI::Application::Plugin::Session required for this test"; } else { plan tests => 14; } { package TestAppStoreSession; use base qw(TestAppStore); CGI::Application::Plugin::Session->import; # it was used conditionally above __PACKAGE__->authen->config( DRIVER => [ 'Generic', { 'test' => '123' } ], STORE => [ 'Session' ], CREDENTIALS => [qw(auth_username auth_password)], ); sub get_store_entries { my $class = shift; my $cgiapp = shift; my $results = shift; my $data = { username => $cgiapp->session->param('AUTH_USERNAME'), login_attempts => $cgiapp->session->param('AUTH_LOGIN_ATTEMPTS'), }; return ($data->{username} || $data->{login_attempts}) ? $data : undef; } sub maintain_state { my $class = shift; my $old_cgiapp = shift; my $old_results = shift; my $new_query = shift; $old_cgiapp->session->flush; $new_query->param(-name => CGI::Session->name, -value => $old_cgiapp->session->id, -override => 1); } sub clear_state { my $class = shift; my $old_cgiapp = shift; my $old_results = shift; $old_cgiapp->session->clear(['AUTH_USERNAME','AUTH_LOGIN_ATTEMPTS']), $old_cgiapp->session->flush; $class->SUPER::clear_state(@_); } } TestAppStoreSession->run_store_tests;
#!/usr/bin/perl use strict; use warnings; use lib qw(t); use CGI::Util; use Test::More; use Test::Exception; eval "use CGI::Application::Plugin::Session;"; if ($@) { plan skip_all => "CGI::Application::Plugin::Session required for this test"; } else { plan tests => 17; } our %STORAGE; { package TestAppStoreDummy; use base qw(TestAppStore); CGI::Application::Plugin::Session->import; # it was used conditionally above __PACKAGE__->authen->config( DRIVER => [ 'Generic', { 'test' => '123' } ], STORE => [ 'Store::Dummy', \%STORAGE ], CREDENTIALS => [qw(auth_username auth_password)], ); sub get_store_entries { return %STORAGE ? \%STORAGE : undef; } #-------------------------------------------------- # sub maintain_state { # my $class = shift; # my $old_cgiapp = shift; # my $old_results = shift; # my $new_query = shift; # } #-------------------------------------------------- sub clear_state { my $class = shift; my $old_cgiapp = shift; my $old_results = shift; delete $STORAGE{$_} foreach keys %STORAGE; } } TestAppStoreDummy->run_store_tests; # Test some methods that should never be called my $store = TestAppStoreDummy->new->authen->store; throws_ok { $store->CGI::Application::Plugin::Authentication::Store::fetch('username') } qr/fetch must be implemented in the/, 'Store dies when fetch is called without being overridden in the subclass'; throws_ok { $store->CGI::Application::Plugin::Authentication::Store::save(username => 'test1') } qr/save must be implemented in the/, 'Store dies when save is called without being overridden in the subclass'; throws_ok { $store->CGI::Application::Plugin::Authentication::Store::delete('username') } qr/delete must be implemented in the/, 'Store dies when delete is called without being overridden in the subclass';
patch added in version 0.13. Thanks!