aboutsummaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rwxr-xr-xperl/t/init.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/perl/t/init.t b/perl/t/init.t
new file mode 100755
index 0000000..597cb96
--- /dev/null
+++ b/perl/t/init.t
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+# $Id$
+#
+# t/init.t -- Tests for database initialization.
+
+use Test::More tests => 8;
+
+use DBD::SQLite;
+use Wallet::Config;
+use Wallet::Object::Base;
+use Wallet::Server;
+
+# Use a local SQLite database for testing.
+$Wallet::Config::DB_DRIVER = 'SQLite';
+$Wallet::Config::DB_INFO = 'wallet-db';
+
+# Use Wallet::Server to set up the database.
+my $server = eval { Wallet::Server->initialize ('admin@EXAMPLE.COM') };
+is ($@, '', 'Database initialization did not die');
+ok ($server->isa ('Wallet::Server'), ' and returned the right class');
+
+# Check whether the database entries that should be created were.
+my $acl = eval { Wallet::ACL->new ('ADMIN', $server->dbh) };
+is ($@, '', 'Retrieving ADMIN ACL successful');
+ok ($acl->isa ('Wallet::ACL'), ' and is the right class');
+my @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.
+unlink 'wallet-db';