aboutsummaryrefslogtreecommitdiff
path: root/perl/t
diff options
context:
space:
mode:
Diffstat (limited to 'perl/t')
-rwxr-xr-xperl/t/init.t19
-rwxr-xr-xperl/t/keytab.t4
-rwxr-xr-xperl/t/object.t4
-rwxr-xr-xperl/t/schema.t17
-rwxr-xr-xperl/t/server.t8
5 files changed, 45 insertions, 7 deletions
diff --git a/perl/t/init.t b/perl/t/init.t
index 3fa026f..81c034d 100755
--- a/perl/t/init.t
+++ b/perl/t/init.t
@@ -8,7 +8,7 @@
#
# See LICENSE for licensing terms.
-use Test::More tests => 8;
+use Test::More tests => 16;
use Wallet::ACL;
use Wallet::Config;
@@ -34,5 +34,22 @@ isnt ($entries[0], undef, ' which is a valid entry');
is ($entries[0][0], 'krb5', ' of krb5 scheme');
is ($entries[0][1], 'admin@EXAMPLE.COM', ' with the right user');
+# Test reinitialization.
+$server = eval { Wallet::Server->reinitialize ('admin@EXAMPLE.COM') };
+is ($@, '', 'Reinitialization did not die');
+ok ($server->isa ('Wallet::Server'), ' and returned the right class');
+
+# Now repeat the database content checks.
+$acl = eval { Wallet::ACL->new ('ADMIN', $server->dbh) };
+is ($@, '', 'Retrieving ADMIN ACL successful');
+ok ($acl->isa ('Wallet::ACL'), ' and is the right class');
+@entries = $acl->list;
+is (scalar (@entries), 1, ' and has only one entry');
+isnt ($entries[0], undef, ' which is a valid entry');
+is ($entries[0][0], 'krb5', ' of krb5 scheme');
+is ($entries[0][1], 'admin@EXAMPLE.COM', ' with the right user');
+
# Clean up.
+my $schema = Wallet::Schema->new;
+$schema->drop ($server->dbh);
unlink 'wallet-db';
diff --git a/perl/t/keytab.t b/perl/t/keytab.t
index d7c2a02..f08bd31 100755
--- a/perl/t/keytab.t
+++ b/perl/t/keytab.t
@@ -200,7 +200,7 @@ sub stop_remctld {
}
# Use Wallet::Server to set up the database.
-my $server = eval { Wallet::Server->initialize ($user) };
+my $server = eval { Wallet::Server->reinitialize ($user) };
is ($@, '', 'Database initialization did not die');
ok ($server->isa ('Wallet::Server'), ' and returned the right class');
my $dbh = $server->dbh;
@@ -861,4 +861,6 @@ EOO
}
# Clean up.
+my $schema = Wallet::Schema->new;
+$schema->drop ($dbh);
unlink ('wallet-db', 'krb5cc_temp', 'krb5cc_test', 'test-acl', 'test-pid');
diff --git a/perl/t/object.t b/perl/t/object.t
index bf100ea..42700d0 100755
--- a/perl/t/object.t
+++ b/perl/t/object.t
@@ -28,7 +28,7 @@ my @trace = ($user, $host, time);
my $princ = 'service/test@EXAMPLE.COM';
# Use Wallet::Server to set up the database.
-my $server = eval { Wallet::Server->initialize ($user) };
+my $server = eval { Wallet::Server->reinitialize ($user) };
is ($@, '', 'Database initialization did not die');
ok ($server->isa ('Wallet::Server'), ' and returned the right class');
my $dbh = $server->dbh;
@@ -321,4 +321,6 @@ EOO
is ($object->history, $output, ' and the history is correct');
# Clean up.
+my $schema = Wallet::Schema->new;
+$schema->drop ($dbh);
unlink 'wallet-db';
diff --git a/perl/t/schema.t b/perl/t/schema.t
index 01b2b88..9e2d84f 100755
--- a/perl/t/schema.t
+++ b/perl/t/schema.t
@@ -8,7 +8,7 @@
#
# See LICENSE for licensing terms.
-use Test::More tests => 5;
+use Test::More tests => 8;
use DBI;
use Wallet::Schema;
@@ -31,5 +31,20 @@ $dbh->{PrintError} = 0;
eval { $schema->create ($dbh) };
is ($@, '', "create() doesn't die");
+# Test dropping the database.
+eval { $schema->drop ($dbh) };
+is ($@, '', "drop() doesn't die");
+my $sql = "select name from sqlite_master where type = 'table'";
+my $sth = $dbh->prepare ($sql);
+$sth->execute;
+my ($table, @tables);
+while (defined ($table = $sth->fetchrow_array)) {
+ push (@tables, $table) unless $table =~ /^sqlite_/;
+}
+is ("@tables", '', ' and there are no tables in the database');
+eval { $schema->create ($dbh) };
+is ($@, '', ' and we can run create again');
+
# Clean up.
+eval { $schema->drop ($dbh) };
unlink 'wallet-db';
diff --git a/perl/t/server.t b/perl/t/server.t
index b0c196b..2520e62 100755
--- a/perl/t/server.t
+++ b/perl/t/server.t
@@ -866,6 +866,11 @@ is ($server->store ('base', 'service/foo', 'stuff'), undef,
is ($server->error, "$user2 not authorized to create base:service/foo",
' with the right error');
+# Clean up.
+my $schema = Wallet::Schema->new;
+$schema->drop ($server->dbh);
+unlink 'wallet-db';
+
# Now test handling of some configuration errors.
undef $Wallet::Config::DB_DRIVER;
$server = eval { Wallet::Server->new ($user2, $host) };
@@ -880,6 +885,3 @@ $Wallet::Config::DB_INFO = 't';
$server = eval { Wallet::Server->new ($user2, $host) };
like ($@, qr/^cannot connect to database: /,
' or if the database connection fails');
-
-# Clean up.
-unlink 'wallet-db';