8 use vars qw(%cases $dbh $config $ldap);
12 # users from example3.ldif
18 plan tests => 3 + scalar(keys %cases);
19 use_ok('C4::Context');
20 use_ok('C4::Auth_with_ldap', qw(checkauth));
23 sub do_checkauth (;$$) {
24 my ($user,$pass) = (shift,shift);
27 return ($ret = checkauth($dbh,$user,$pass), sprintf("(%s,%s) returns '%s'",$user,$pass,$ret));
30 ok($dbh = C4::Context->dbh(), "Getting dbh from C4::Context");
31 ok($config = C4::Context->config(), "Getting config (hashref) from C4::Context");
32 ok($ldap = $config->{ldap}, "Getting LDAP info from config");
34 diag("The basis of Authenticaiton is that we don't auth everybody.");
35 diag("Let's make sure we reject on bad calls.");
37 ok(!($ret = checkauth($dbh)), "should reject ( no arguments) returns '$ret'");
38 ok(!($ret = checkauth($dbh,'','')), "should reject (empty arguments) returns '$ret'");
40 diag("Now let's check " . scalar(keys %cases) . " test cases: ");
41 foreach (sort keys %cases) {
42 ok do_checkauth($_, $cases{$_});