Allow LDAP test to bail if LDAP disabled.
Also added more feedback and the ability to override KOHA_CONF "useldapserver" value with ENV variable KOHA_USELDAPSERVER. This patch should be considered for inclusion to 3.0 stable branch because it prevents unnecessary failure of test battery. Signed-off-by: Galen Charlton <galen.charlton@liblime.com> Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
This commit is contained in:
parent
43fdc78358
commit
bbb604a3b1
|
|
@ -15,7 +15,7 @@ BEGIN {
|
|||
rch => 'password2',
|
||||
jmf => 'password3',
|
||||
);
|
||||
plan tests => 7 + scalar(keys %cases);
|
||||
plan tests => 8 + scalar(keys %cases);
|
||||
use_ok('C4::Context');
|
||||
use_ok('C4::Auth_with_ldap', qw(checkpw_ldap));
|
||||
}
|
||||
|
|
@ -31,15 +31,26 @@ ok($context= C4::Context->new(), "Getting new C4::Context object");
|
|||
ok($dbh = C4::Context->dbh(), "Getting dbh from C4::Context");
|
||||
ok($dbh = $context->dbh(), "Getting dbh from \$context object");
|
||||
|
||||
diag("The basis of Authentication is that we don't auth everybody.");
|
||||
diag("Let's make sure we reject on bad calls.");
|
||||
my $ret;
|
||||
ok(!($ret = checkpw_ldap($dbh)), "should reject ( no arguments) returns '$ret'");
|
||||
ok(!($ret = checkpw_ldap($dbh,'','')), "should reject (empty arguments) returns '$ret'");
|
||||
print "\n";
|
||||
diag("Now let's check " . scalar(keys %cases) . " test cases: ");
|
||||
foreach (sort keys %cases) {
|
||||
ok do_checkpw_ldap($_, $cases{$_});
|
||||
$ldap = $ENV{KOHA_USELDAPSERVER};
|
||||
if(defined($ldap)) {
|
||||
diag "Overriding KOHA_CONF <useldapserver> with \$ENV{KOHA_USELDAPSERVER} = $ldap";
|
||||
} else {
|
||||
diag 'Note: You can use $ENV{KOHA_USELDAPSERVER} to override KOHA_CONF <useldapserver> for this test';
|
||||
$ldap = C4::Context->config('useldapserver');
|
||||
}
|
||||
ok(defined($ldap), "Checking if \$ENV{KOHA_USELDAPSERVER} or <useldapserver> is defined");
|
||||
|
||||
SKIP: {
|
||||
$ldap or skip("LDAP is disabled.", scalar(keys %cases) + 2);
|
||||
diag("The basis of Authentication is that we don't auth everybody.");
|
||||
diag("Let's make sure we reject on bad calls.");
|
||||
my $ret;
|
||||
ok(!($ret = checkpw_ldap($dbh)), "should reject ( no arguments) returns '$ret'");
|
||||
ok(!($ret = checkpw_ldap($dbh,'','')), "should reject (empty arguments) returns '$ret'");
|
||||
print "\n";
|
||||
diag("Now let's check " . scalar(keys %cases) . " test cases: ");
|
||||
foreach (sort keys %cases) {
|
||||
ok do_checkpw_ldap($_, $cases{$_});
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue