From abe306c2df8408805ea4a587159ca67291914b18 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 23 Jan 2009 11:57:57 -0600 Subject: [PATCH] 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 --- t/db_dependent/Auth_with_ldap.t | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t index 2f1874c725..961515119e 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 with \$ENV{KOHA_USELDAPSERVER} = $ldap"; +} else { + diag 'Note: You can use $ENV{KOHA_USELDAPSERVER} to override KOHA_CONF for this test'; + $ldap = C4::Context->config('useldapserver'); } +ok(defined($ldap), "Checking if \$ENV{KOHA_USELDAPSERVER} or 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; -- 2.39.2