Unit tests for jail error reporting (#2568)
This commit is contained in:
parent
d46a2f5c28
commit
c1b6ca940d
|
@ -6,7 +6,7 @@
|
|||
# change 'tests => 1' to 'tests => last_test_to_print';
|
||||
|
||||
use strict;
|
||||
use Test::More tests => 20;
|
||||
use Test::More tests => 22;
|
||||
require 't/test.pm';
|
||||
BEGIN { use_ok('Lemonldap::NG::Handler::Main::Jail') }
|
||||
|
||||
|
@ -60,7 +60,7 @@ ok(
|
|||
ok( $res = &$code, "Function works" );
|
||||
ok( $res == 1, 'Get good result' );
|
||||
|
||||
$sub = "sub { return(checkDate('20000101000000+0100','21000101000000+0100')) }";
|
||||
$sub = "sub { return(checkDate('20000101000000+0100','21000101000000+0100')) }";
|
||||
$code = $jail->jail_reval($sub);
|
||||
ok(
|
||||
( defined($code) and ref($code) eq 'CODE' ),
|
||||
|
@ -105,3 +105,11 @@ is(
|
|||
"Function works"
|
||||
);
|
||||
|
||||
$sub = "sub { return(";
|
||||
$code = $jail->jail_reval($sub);
|
||||
ok( ( not defined($code) ), 'Syntax error yields undef result' );
|
||||
like(
|
||||
$jail->error,
|
||||
qr/Missing right curly or square bracket/,
|
||||
'Found correct error message'
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
||||
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 16;
|
||||
require 't/test.pm';
|
||||
BEGIN { use_ok('Lemonldap::NG::Handler::Main::Jail') }
|
||||
|
||||
|
@ -43,7 +43,8 @@ my $checkDate = $jail->jail_reval($sub3);
|
|||
ok( &$checkDate == "1",
|
||||
'checkDate extended function working without Safe Jail' );
|
||||
|
||||
my $sub4 = "sub { return(checkDate('20000101000000+0100','21000101000000+0100')) }";
|
||||
my $sub4 =
|
||||
"sub { return(checkDate('20000101000000+0100','21000101000000+0100')) }";
|
||||
my $checkDate = $jail->jail_reval($sub4);
|
||||
ok( &$checkDate == "1",
|
||||
'checkDate extended function working without Safe Jail' );
|
||||
|
@ -96,3 +97,12 @@ is(
|
|||
0,
|
||||
"Function works"
|
||||
);
|
||||
|
||||
$sub = "sub { return(";
|
||||
$code = $jail->jail_reval($sub);
|
||||
ok( ( not defined($code) ), 'Syntax error yields undef result' );
|
||||
like(
|
||||
$jail->error,
|
||||
qr/Missing right curly or square bracket/,
|
||||
'Found correct error message'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user