summaryrefslogtreecommitdiff
path: root/perl/Wallet/Admin.pm
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-01-23 19:17:09 +0000
committerRuss Allbery <rra@stanford.edu>2008-01-23 19:17:09 +0000
commit45e33ff74717f39c421091f1a74f7d895e38bf57 (patch)
treeb2d6e6e2ce21612eae18ecde213e372787e58711 /perl/Wallet/Admin.pm
parent77b6875f95aa54fe9c648ba114e06d85cf655bb1 (diff)
Add a destroy() method to the Wallet::Admin object and use that instead
of Wallet::Schema::drop in the test suite.
Diffstat (limited to 'perl/Wallet/Admin.pm')
-rw-r--r--perl/Wallet/Admin.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/perl/Wallet/Admin.pm b/perl/Wallet/Admin.pm
index 400068d..258077a 100644
--- a/perl/Wallet/Admin.pm
+++ b/perl/Wallet/Admin.pm
@@ -90,17 +90,25 @@ sub initialize {
}
# The same as initialize, but also drops any existing tables first before
-# creating the schema. Takes the same arguments and throws an exception on
-# failure.
+# creating the schema. Takes the same arguments. Returns true on success and
+# false on failure.
sub reinitialize {
my ($self, $user) = @_;
+ return unless $self->destroy;
+ return $self->initialize ($user);
+}
+
+# Drop the database, including all of its data. Returns true on success and
+# false on failure.
+sub destroy {
+ my ($self) = @_;
my $schema = Wallet::Schema->new;
eval { $schema->drop ($self->{dbh}) };
if ($@) {
$self->error ($@);
return;
}
- return $self->initialize ($user);
+ return 1;
}
1;
@@ -152,6 +160,11 @@ failure to get the error message.
=over 4
+=item destroy()
+
+Destroys the database, deleting all of its data and all of the tables used
+by the wallet server. Returns true on success and false on failure.
+
=item initialize(PRINCIPAL)
Initializes the database as configured in Wallet::Config and loads the
@@ -159,6 +172,7 @@ wallet database schema. Then, creates an ACL with the name ADMIN and adds
an ACL entry of scheme C<krb5> and instance PRINCIPAL to that ACL. This
bootstraps the authorization system and lets that Kerberos identity make
further changes to the ADMIN ACL and the rest of the wallet database.
+Returns true on success and false on failure.
initialize() uses C<localhost> as the hostname and PRINCIPAL as the user
when logging the history of the ADMIN ACL creation and for any subsequent
@@ -176,6 +190,8 @@ Performs the same actions as initialize(), but first drops any existing
wallet database tables from the database, allowing this function to be
called on a prior wallet database. All data stored in the database will
be deleted and a fresh set of wallet database tables will be created.
+This method is equivalent to calling destroy() followed by initialize().
+Returns true on success and false on failure.
=back