[Koha-patches] [PATCH] Allow LDAP test to bail if LDAP disabled.
Joe Atzberger
joe.atzberger at liblime.com
Fri Jan 23 18:57:57 CET 2009
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.
---
t/db_dependent/Auth_with_ldap.t | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t
index 2f1874c..9615151 100755
--- a/t/db_dependent/Auth_with_ldap.t
+++ b/t/db_dependent/Auth_with_ldap.t
@@ -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;
--
1.5.5.GIT
More information about the Koha-patches
mailing list