2014-03-31 18:25:09 +02:00
|
|
|
# Before `make install' is performed this script should be runnable with
|
|
|
|
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Handler-SharedConf.t'
|
|
|
|
|
|
|
|
#########################
|
|
|
|
|
|
|
|
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
|
|
|
2017-02-10 13:52:25 +01:00
|
|
|
use strict;
|
2017-03-28 23:07:49 +02:00
|
|
|
use Test::More tests => 9;
|
2016-03-17 23:19:44 +01:00
|
|
|
require 't/test.pm';
|
2014-03-31 18:25:09 +02:00
|
|
|
BEGIN { use_ok('Lemonldap::NG::Handler::Main::Jail') }
|
|
|
|
|
|
|
|
#########################
|
|
|
|
|
|
|
|
# Insert your test code below, the Test::More module is use()ed here so read
|
|
|
|
# its man page ( perldoc Test::More ) for help writing this test script.
|
2017-02-10 13:52:25 +01:00
|
|
|
my $res;
|
2014-03-31 18:25:09 +02:00
|
|
|
|
|
|
|
ok(
|
|
|
|
my $jail = Lemonldap::NG::Handler::Main::Jail->new(
|
2016-04-29 09:27:26 +02:00
|
|
|
'jail' => undef,
|
|
|
|
'useSafeJail' => 1,
|
2014-03-31 18:25:09 +02:00
|
|
|
),
|
|
|
|
'new jail object'
|
|
|
|
);
|
2016-03-17 23:19:44 +01:00
|
|
|
$jail->build_jail('Lemonldap::NG::Handler::Test');
|
2014-03-31 18:25:09 +02:00
|
|
|
|
2017-02-10 13:52:25 +01:00
|
|
|
my $sub = "sub { return( basic('login','password') ) }";
|
|
|
|
my $basic = $jail->jail_reval($sub);
|
|
|
|
ok( ( defined($basic) ), 'basic extended function is defined' );
|
|
|
|
|
|
|
|
$sub = "sub { return ( encode_base64('test','') ) }";
|
|
|
|
my $code = $jail->jail_reval($sub);
|
2017-02-15 07:41:50 +01:00
|
|
|
ok(
|
|
|
|
( defined($code) and ref($code) eq 'CODE' ),
|
|
|
|
'encode_base64 function is defined'
|
|
|
|
);
|
2017-02-10 13:52:25 +01:00
|
|
|
ok( $res = &$code, "Function works" );
|
|
|
|
ok( $res eq 'dGVzdA==', 'Get good result' );
|
|
|
|
|
2017-02-15 07:41:50 +01:00
|
|
|
$sub = "sub { return(checkDate('20000000000000','21000000000000')) }";
|
2017-02-10 13:52:25 +01:00
|
|
|
$code = $jail->jail_reval($sub);
|
2017-02-15 07:41:50 +01:00
|
|
|
ok(
|
|
|
|
( defined($code) and ref($code) eq 'CODE' ),
|
|
|
|
'checkDate extended function is defined'
|
|
|
|
);
|
2017-02-10 13:52:25 +01:00
|
|
|
ok( $res = &$code, "Function works" );
|
|
|
|
ok( $res == 1, 'Get good result' );
|
|
|
|
|