Adding test for Auth operation
This commit is contained in:
parent
564fea1583
commit
0ba154f8fa
1 changed files with 77 additions and 0 deletions
77
t/Operation/Auth.t
Normal file
77
t/Operation/Auth.t
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# This tests the operation of Authentication
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Operation::Auth;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
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');
|
||||
|
||||
# Test the web method for auth operation
|
||||
# First a clean session, without an authenticated user
|
||||
my $output = WebGUI::Operation::Auth::www_auth($session);
|
||||
like(
|
||||
$output,
|
||||
qr/<input type="hidden" name="method" value="login" /,
|
||||
"Hidden form elements for login displayed",
|
||||
);
|
||||
|
||||
# Become admin and test web method
|
||||
$session->user({userId => 3});
|
||||
$output = WebGUI::Operation::Auth::www_auth($session);
|
||||
unlike(
|
||||
$output,
|
||||
qr/<input type="hidden" name="method" value="login" /,
|
||||
"Hidden form elements for login NOT displayed to valid user",
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/Edit account information/,
|
||||
"Edit account information link exists"
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/Edit profile/,
|
||||
"Edit Profile link exists"
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue