aboutsummaryrefslogtreecommitdiff
path: root/perl/t/init.t
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-01-23 03:33:41 +0000
committerRuss Allbery <rra@stanford.edu>2008-01-23 03:33:41 +0000
commit77b6875f95aa54fe9c648ba114e06d85cf655bb1 (patch)
tree27a3ce2238ed38894e68ef7242a3b2a71c5e6cdc /perl/t/init.t
parentd94cac7f73b8a0c0a067bc179747426726ab8c31 (diff)
Refactor database initialization into a new Wallet::Admin module.
Diffstat (limited to 'perl/t/init.t')
-rwxr-xr-xperl/t/init.t28
1 files changed, 15 insertions, 13 deletions
diff --git a/perl/t/init.t b/perl/t/init.t
index 18f8e3b..9e1b600 100755
--- a/perl/t/init.t
+++ b/perl/t/init.t
@@ -4,27 +4,30 @@
# t/init.t -- Tests for database initialization.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.
use Test::More tests => 16;
use Wallet::ACL;
+use Wallet::Admin;
+use Wallet::Admin;
use Wallet::Config;
-use Wallet::Server;
use lib 't/lib';
use Util;
-# Use Wallet::Server to set up the database.
+# Use Wallet::Admin to set up the database.
db_setup;
-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');
+my $admin = eval { Wallet::Admin->new };
+is ($@, '', 'Wallet::Admin creation did not die');
+ok ($admin->isa ('Wallet::Admin'), ' and returned the right class');
+is ($admin->initialize ('admin@EXAMPLE.COM'), 1,
+ ' and initialization succeeds');
# Check whether the database entries that should be created were.
-my $acl = eval { Wallet::ACL->new ('ADMIN', $server->dbh) };
+my $acl = eval { Wallet::ACL->new ('ADMIN', $admin->dbh) };
is ($@, '', 'Retrieving ADMIN ACL successful');
ok ($acl->isa ('Wallet::ACL'), ' and is the right class');
my @entries = $acl->list;
@@ -34,21 +37,20 @@ 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');
+is ($admin->reinitialize ('admin@EXAMPLE.ORG'), 1,
+ 'Reinitialization succeeded');
# Now repeat the database content checks.
-$acl = eval { Wallet::ACL->new ('ADMIN', $server->dbh) };
+$acl = eval { Wallet::ACL->new ('ADMIN', $admin->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');
+is ($entries[0][1], 'admin@EXAMPLE.ORG', ' with the right user');
# Clean up.
my $schema = Wallet::Schema->new;
-$schema->drop ($server->dbh);
+$schema->drop ($admin->dbh);
unlink 'wallet-db';