lemonldap-ng/lemonldap-ng-portal/t/66-Lemonldap-NG-Portal-Captcha.t

49 lines
1.1 KiB
Perl
Raw Normal View History

2012-07-05 09:33:15 +02:00
use Test::More tests => 4;
2012-07-04 17:18:48 +02:00
BEGIN {
2012-07-26 04:47:27 +02:00
use_ok("Lemonldap::NG::Portal::Simple");
2012-07-04 17:18:48 +02:00
}
2012-07-26 04:47:27 +02:00
# build Lemonldap::NG::Portal::Simple object
2012-07-04 17:18:48 +02:00
my $p = Lemonldap::NG::Portal::Simple->new(
2012-07-26 04:47:27 +02:00
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
error => 0,
applicationList => {},
locationRules => {
'test.example.com' => {
'default' => "deny",
'^/ok' => '$uid eq "kharec"',
'^/nok' => '$uid eq "toto"',
},
},
cfgNum => 42,
sessionInfo => { uid => "kharec" },
}
2012-07-04 17:18:48 +02:00
);
## Overload captcha_output and captcha_data
mkdir "./tmp";
$p->{captcha_output} = "./tmp/output";
2012-07-26 04:47:27 +02:00
$p->{captcha_data} = "./tmp/data";
2012-07-05 09:33:15 +02:00
# create dir
2012-07-04 17:18:48 +02:00
mkdir $p->{captcha_output};
mkdir $p->{captcha_data};
2012-07-26 04:47:27 +02:00
ok( ref($p) eq "Lemonldap::NG::Portal::Simple" );
2012-07-04 17:18:48 +02:00
# try to init a captcha
2012-07-26 04:47:27 +02:00
ok( $p->initCaptcha() );
2012-07-05 09:33:15 +02:00
# try a wrong values to check checkCaptcha method
2012-07-26 04:47:27 +02:00
$p->checkCaptcha( "12D3EO", $p->{captcha_code} );
ok( 1 ne $p->{captcha_result} );
2012-07-04 17:18:48 +02:00
END {
2012-07-26 04:47:27 +02:00
system("rm -rf ./tmp");
2012-07-04 17:18:48 +02:00
}