[Koha-patches] [PATCH] Shifting the tests that need user input to their own directory, they cant be used by the automated tester

Chris Cormack chrisc at catalyst.net.nz
Sat Sep 4 08:07:13 CEST 2010


---
 t/db_dependent/Auth.t                            |   44 -----------------
 t/db_dependent/Auth_with_ldap.t                  |   56 ----------------------
 t/db_dependent/needs_user_input/Auth.t           |   44 +++++++++++++++++
 t/db_dependent/needs_user_input/Auth_with_ldap.t |   56 ++++++++++++++++++++++
 4 files changed, 100 insertions(+), 100 deletions(-)
 delete mode 100755 t/db_dependent/Auth.t
 delete mode 100755 t/db_dependent/Auth_with_ldap.t
 create mode 100755 t/db_dependent/needs_user_input/Auth.t
 create mode 100755 t/db_dependent/needs_user_input/Auth_with_ldap.t

diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t
deleted file mode 100755
index dcfea53..0000000
--- a/t/db_dependent/Auth.t
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 6;
-
-BEGIN {
-	use FindBin;
-	use lib $FindBin::Bin;
-	use override_context_prefs;
-        use_ok('C4::Auth', qw(checkpw));
-        use_ok('C4::Context');
-}
-
-use vars qw($dbh $ldap);
-can_ok('C4::Context', 'config');
-can_ok('C4::Context', 'dbh');
-can_ok('C4::Auth', qw(checkpw));
-    ok($dbh  = C4::Context->dbh(),  "Getting dbh from C4::Context");
-$ldap = C4::Context->config('useldapserver') || 0;
-diag("Using LDAP? $ldap");
-
-while (1) {		# forever!
-	print "Do you want to test further accounts? (If not, just hit return.)\n";
-	my ($user, $pass);
-	print "Enter username: ";
-	chomp($user = <>);
-	($user) or exit;
-	print "Enter password: ";
-	chomp($pass = <>);
-	my ($retval,$retcard) = checkpw($dbh,$user,$pass);
-	$retval  ||= '';
-	$retcard ||= '';
-	diag ("checkpw(\$dbh,$user,$pass) " . ($retval ? 'SUCCEEDS' : ' FAILS  ') . "\treturns ($retval,$retcard)");
-}
-
-END {
-	diag("C4::Auth - end of test");
-}
-__END__
diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t
deleted file mode 100755
index 9615151..0000000
--- a/t/db_dependent/Auth_with_ldap.t
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/perl
-#
-
-use strict;
-use warnings;
-
-use Test::More;
-use vars qw(%cases $dbh $config $context $ldap);
-
-BEGIN {
-	%cases = (
-		# users from t/LDAP/example3.ldif
-		sss => 'password1',
-		jts => 'password1',
-		rch => 'password2',
-		jmf => 'password3',
-	);
-	plan tests => 8 + scalar(keys %cases);
-	use_ok('C4::Context');
-	use_ok('C4::Auth_with_ldap', qw(checkpw_ldap));
-}
-
-sub do_checkpw_ldap (;$$) { 
-	my ($user,$pass) = (shift,shift);
-	diag "($user,$pass)";
-	my $ret;
-	return ($ret = checkpw_ldap($dbh,$user,$pass), sprintf("(%s,%s) returns '%s'",$user,$pass,$ret));
-}
-
-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");
-
-$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;
diff --git a/t/db_dependent/needs_user_input/Auth.t b/t/db_dependent/needs_user_input/Auth.t
new file mode 100755
index 0000000..dcfea53
--- /dev/null
+++ b/t/db_dependent/needs_user_input/Auth.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+BEGIN {
+	use FindBin;
+	use lib $FindBin::Bin;
+	use override_context_prefs;
+        use_ok('C4::Auth', qw(checkpw));
+        use_ok('C4::Context');
+}
+
+use vars qw($dbh $ldap);
+can_ok('C4::Context', 'config');
+can_ok('C4::Context', 'dbh');
+can_ok('C4::Auth', qw(checkpw));
+    ok($dbh  = C4::Context->dbh(),  "Getting dbh from C4::Context");
+$ldap = C4::Context->config('useldapserver') || 0;
+diag("Using LDAP? $ldap");
+
+while (1) {		# forever!
+	print "Do you want to test further accounts? (If not, just hit return.)\n";
+	my ($user, $pass);
+	print "Enter username: ";
+	chomp($user = <>);
+	($user) or exit;
+	print "Enter password: ";
+	chomp($pass = <>);
+	my ($retval,$retcard) = checkpw($dbh,$user,$pass);
+	$retval  ||= '';
+	$retcard ||= '';
+	diag ("checkpw(\$dbh,$user,$pass) " . ($retval ? 'SUCCEEDS' : ' FAILS  ') . "\treturns ($retval,$retcard)");
+}
+
+END {
+	diag("C4::Auth - end of test");
+}
+__END__
diff --git a/t/db_dependent/needs_user_input/Auth_with_ldap.t b/t/db_dependent/needs_user_input/Auth_with_ldap.t
new file mode 100755
index 0000000..9615151
--- /dev/null
+++ b/t/db_dependent/needs_user_input/Auth_with_ldap.t
@@ -0,0 +1,56 @@
+#!/bin/perl
+#
+
+use strict;
+use warnings;
+
+use Test::More;
+use vars qw(%cases $dbh $config $context $ldap);
+
+BEGIN {
+	%cases = (
+		# users from t/LDAP/example3.ldif
+		sss => 'password1',
+		jts => 'password1',
+		rch => 'password2',
+		jmf => 'password3',
+	);
+	plan tests => 8 + scalar(keys %cases);
+	use_ok('C4::Context');
+	use_ok('C4::Auth_with_ldap', qw(checkpw_ldap));
+}
+
+sub do_checkpw_ldap (;$$) { 
+	my ($user,$pass) = (shift,shift);
+	diag "($user,$pass)";
+	my $ret;
+	return ($ret = checkpw_ldap($dbh,$user,$pass), sprintf("(%s,%s) returns '%s'",$user,$pass,$ret));
+}
+
+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");
+
+$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.7.0.4



More information about the Koha-patches mailing list