diff options
Diffstat (limited to 'perl/t')
| -rwxr-xr-x | perl/t/acl.t | 13 | ||||
| -rwxr-xr-x | perl/t/init.t | 28 | ||||
| -rwxr-xr-x | perl/t/keytab.t | 12 | ||||
| -rwxr-xr-x | perl/t/object.t | 14 | ||||
| -rwxr-xr-x | perl/t/server.t | 10 | 
5 files changed, 41 insertions, 36 deletions
| diff --git a/perl/t/acl.t b/perl/t/acl.t index 16af5c1..15796d2 100755 --- a/perl/t/acl.t +++ b/perl/t/acl.t @@ -4,7 +4,7 @@  # t/api.t -- Tests for the wallet ACL API.  #  # 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. @@ -12,6 +12,7 @@ use POSIX qw(strftime);  use Test::More tests => 101;  use Wallet::ACL; +use Wallet::Admin;  use Wallet::Config;  use Wallet::Server; @@ -25,12 +26,12 @@ my $user2 = 'bob@EXAMPLE.COM';  my $host = 'localhost';  my @trace = ($admin, $host, time); -# Use Wallet::Server to set up the database. +# Use Wallet::Admin to set up the database.  db_setup; -my $server = eval { Wallet::Server->reinitialize ($admin) }; -is ($@, '', 'Database initialization did not die'); -ok ($server->isa ('Wallet::Server'), ' and returned the right class'); -my $dbh = $server->dbh; +my $setup = eval { Wallet::Admin->new }; +is ($@, '', 'Database connection succeeded'); +is ($setup->reinitialize ($setup), 1, 'Database initialization succeeded'); +my $dbh = $setup->dbh;  # Test create and new.  my $acl = eval { Wallet::ACL->create ('test', $dbh, @trace) }; 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'; diff --git a/perl/t/keytab.t b/perl/t/keytab.t index bb6b048..a40332a 100755 --- a/perl/t/keytab.t +++ b/perl/t/keytab.t @@ -11,9 +11,9 @@  use POSIX qw(strftime);  use Test::More tests => 223; +use Wallet::Admin;  use Wallet::Config;  use Wallet::Object::Keytab; -use Wallet::Server;  use lib 't/lib';  use Util; @@ -187,13 +187,13 @@ sub stop_remctld {      kill 15, $pid;  } -# Use Wallet::Server to set up the database. +# Use Wallet::Admin to set up the database.  unlink ('krb5cc_temp', 'krb5cc_test', 'test-acl', 'test-pid');  db_setup; -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; +my $admin = eval { Wallet::Admin->new }; +is ($@, '', 'Database connection succeeded'); +is ($admin->reinitialize ($user), 1, 'Database initialization succeeded'); +my $dbh = $admin->dbh;  # Use this to accumulate the history traces so that we can check history.  my $history = ''; diff --git a/perl/t/object.t b/perl/t/object.t index 101110a..48604bc 100755 --- a/perl/t/object.t +++ b/perl/t/object.t @@ -4,7 +4,7 @@  # t/object.t -- Tests for the basic object implementation.  #  # 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. @@ -12,9 +12,9 @@ use POSIX qw(strftime);  use Test::More tests => 131;  use Wallet::ACL; +use Wallet::Admin;  use Wallet::Config;  use Wallet::Object::Base; -use Wallet::Server;  use lib 't/lib';  use Util; @@ -25,12 +25,12 @@ my $host = 'localhost';  my @trace = ($user, $host, time);  my $princ = 'service/test@EXAMPLE.COM'; -# Use Wallet::Server to set up the database. +# Use Wallet::Admin to set up the database.  db_setup; -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; +my $admin = eval { Wallet::Admin->new }; +is ($@, '', 'Database connection succeeded'); +is ($admin->reinitialize ($user), 1, 'Database initialization succeeded'); +my $dbh = $admin->dbh;  # Okay, now we have a database.  Test create and new.  We make believe this is  # a keytab object; it won't matter for what we're doing. diff --git a/perl/t/server.t b/perl/t/server.t index 893f23a..5378969 100755 --- a/perl/t/server.t +++ b/perl/t/server.t @@ -11,6 +11,7 @@  use Test::More tests => 332;  use POSIX qw(strftime); +use Wallet::Admin;  use Wallet::Config;  use Wallet::Schema;  use Wallet::Server; @@ -25,13 +26,14 @@ my $user2 = 'bob@EXAMPLE.COM';  my $host = 'localhost';  my @trace = ($admin, $host); -# 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) }; +my $setup = eval { Wallet::Admin->new };  is ($@, '', 'Database initialization did not die'); -ok ($server->isa ('Wallet::Server'), ' and returned the right class'); +is ($setup->reinitialize ($admin), 1, 'Database initialization succeeded'); +undef $setup; -# Now test the new method as well. +# Now test the new method.  $server = eval { Wallet::Server->new (@trace) };  is ($@, '', 'Reopening with new did not die');  ok ($server->isa ('Wallet::Server'), ' and returned the right class'); | 
