begin tests
This commit is contained in:
parent
68b2c406f7
commit
20e3aef0b5
1 changed files with 45 additions and 2 deletions
|
|
@ -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/<input type="hidden" name="method" value="login" /,
|
||||
"Hidden form elements for login NOT displayed to valid user",
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue