From 76ea4886c2887b4e14b7172b556b899c7ec28eff Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 13 Nov 2007 19:02:37 -0600 Subject: [PATCH] Auth_with_ldap.t - real test cases... work in progress Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- t/Auth_with_ldap.t | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/t/Auth_with_ldap.t b/t/Auth_with_ldap.t index ad4f192ed3..2a4cfc72c2 100755 --- a/t/Auth_with_ldap.t +++ b/t/Auth_with_ldap.t @@ -4,9 +4,42 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More; +use vars qw(%cases $dbh $config $ldap); BEGIN { - use_ok('C4::Auth_with_ldap'); + %cases = ( + # users from example3.ldif + sss => 'password1', + jts => 'password1', + rch => 'password2', + jmf => 'password3', + ); + plan tests => 3 + scalar(keys %cases); + use_ok('C4::Context'); + use_ok('C4::Auth_with_ldap', qw(checkauth)); } +sub do_checkauth (;$$) { + my ($user,$pass) = (shift,shift); + diag "($user,$pass)"; + my $ret; + return ($ret = checkauth($dbh,$user,$pass), sprintf("(%s,%s) returns '%s'",$user,$pass,$ret)); +} + +ok($dbh = C4::Context->dbh(), "Getting dbh from C4::Context"); +ok($config = C4::Context->config(), "Getting config (hashref) from C4::Context"); +ok($ldap = $config->{ldap}, "Getting LDAP info from config"); + +diag("The basis of Authenticaiton is that we don't auth everybody."); +diag("Let's make sure we reject on bad calls."); +my $ret; +ok(!($ret = checkauth($dbh)), "should reject ( no arguments) returns '$ret'"); +ok(!($ret = checkauth($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_checkauth($_, $cases{$_}); +} + +1; -- 2.39.5