diff --git a/t/Operation/Auth.t b/t/Operation/Auth.t index 82b10ab0c..cbe1e5a6d 100644 --- a/t/Operation/Auth.t +++ b/t/Operation/Auth.t @@ -25,17 +25,58 @@ use WebGUI::Operation::Auth; # Init my $session = WebGUI::Test->session; +#---------------------------------------------------------------------------- +# Test package for method dispatch +BEGIN { + package WebGUI::Auth::TestAuth; + + use base 'WebGUI::Auth'; + + sub new { + my $self = $_[0]->SUPER::new(@_); + $self->setCallable( ['callable'] ); + return bless $self, 'WebGUI::Auth::TestAuth'; # Auth requires rebless + } + + sub callable { + return "callable"; + } + + sub www_verify { + return "verify"; + } +} +$INC{'WebGUI/Auth/TestAuth.pm'} = __FILE__; +package main; + #---------------------------------------------------------------------------- # Tests -plan tests => 4; # Increment this number for each test you create +plan tests => 6; # Increment this number for each test you create #---------------------------------------------------------------------------- # Test the getInstance method # By default, it returns a WebGUI::Auth::WebGUI object my $auth = WebGUI::Operation::Auth::getInstance( $session ); ok($auth, 'getInstance returned something'); -isa_ok($auth, 'WebGUI::Auth::WebGUI'); +isa_ok($auth, 'WebGUI::Auth::' . $session->setting->get('authMethod') ); + +# Test setting authType by form var +$session->request->setup_body({ + authType => 'TestAuth', +}); +isa_ok( + WebGUI::Operation::Auth::getInstance( $session ), + 'WebGUI::Auth::' . $session->setting->get('authMethod'), + 'AuthType not in config file, so return default authType', +); + +$session->config->addToArray( 'authMethods', 'TestAuth' ); +isa_ok( + WebGUI::Operation::Auth::getInstance( $session ), + 'WebGUI::Auth::' . $session->setting->get('authMethod'), + 'AuthType in config file, so return instance of authType', +); # Test the web method for auth operation # First a clean session, without an authenticated user @@ -54,3 +95,5 @@ unlike( qr/