Commit c1b6ca94 authored by Maxime Besson's avatar Maxime Besson
Browse files

Unit tests for jail error reporting (#2568)

parent d46a2f5c
Pipeline #15055 passed with stage
in 26 minutes and 39 seconds
......@@ -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'
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment