summaryrefslogtreecommitdiff
path: root/perl/t/init.t
blob: 597cb96777427d7be48aa22362bb90a913034e28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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';