Skip to content

Commit

Permalink
Added test for when Driver constructor messes up
Browse files Browse the repository at this point in the history
  • Loading branch information
periapt committed Feb 16, 2010
1 parent 24863ee commit b7e908d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion t/50_driver_undefined.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Test::Taint;
use Test::Exception;
use lib qw(t);

plan tests => 17;
plan tests => 18;

use strict;
use warnings;
Expand Down Expand Up @@ -125,3 +125,13 @@ $ENV{CGI_APP_RETURN_ONLY} = 1;
throws_ok {$cgiapp->authen->drivers} qr/Driver Blah can not be found/, 'Non existent driver';
};

# Test what happens when a driver constructor dies
{
local $cap_options->{DRIVER} = ['Die'];
my $query = CGI->new( { authen_username => 'user1', rm => 'two', authen_password=>'123', destination=>'http://news.bbc.co.uk' } );

my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
throws_ok {$cgiapp->authen->drivers} qr/Could not create new CGI::Application::Plugin::Authentication::Driver::Die object/, 'Suicidal driver';
};


8 changes: 8 additions & 0 deletions t/CGI/Application/Plugin/Authentication/Driver/Die.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package CGI::Application::Plugin::Authentication::Driver::Die;
use base qw(CGI::Application::Plugin::Authentication::Driver);

sub new {
return undef;
}
1

0 comments on commit b7e908d

Please sign in to comment.