From e86a7a0569e84ebcb769855ece2417c2ccce9b45 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 19 Sep 2007 20:40:06 +0000 Subject: Allow creation of a keytab object for a principal that already exists. Catch more errors when checking the existence of a principal. Add a test for creating a principal for which we don't have permissions. --- perl/t/data/README | 3 ++- perl/t/keytab.t | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'perl/t') diff --git a/perl/t/data/README b/perl/t/data/README index bd15903..33ec32f 100644 --- a/perl/t/data/README +++ b/perl/t/data/README @@ -14,7 +14,8 @@ including the admin_server for the realm. The test process will create the principals wallet/one and wallet/two and on success will clean up after itself. If the test fails, they may be -left behind in the KDC. +left behind in the KDC. It will also attempt to create wallet-test/one +and expects that attempt to be rejected by the KDC. For MIT Kerberos, to grant appropriate permissions, add the line: diff --git a/perl/t/keytab.t b/perl/t/keytab.t index 9337c80..238c6a7 100755 --- a/perl/t/keytab.t +++ b/perl/t/keytab.t @@ -3,7 +3,7 @@ # # t/keytab.t -- Tests for the keytab object implementation. -use Test::More tests => 46; +use Test::More tests => 50; use Wallet::Config; use Wallet::Object::Keytab; @@ -153,10 +153,15 @@ SKIP: { $object = eval { Wallet::Object::Keytab->create ('keytab', 'wallet/two', $dbh, @trace) }; - is ($object, undef, 'Creating an existing principal fails'); - like ($@, qr{^error adding principal wallet/two\@\Q$realm\E: }, - ' with the right error message'); - destroy ('wallet/two'); + ok (defined ($object), 'Creating an existing principal succeeds'); + ok ($object->isa ('Wallet::Object::Keytab'), ' and is the right class'); + is ($object->destroy (@trace), 1, ' and destroying it succeeds'); + ok (! created ('wallet/two'), ' and now it does not exist'); + my @name = qw(keytab wallet-test/one); + $object = eval { Wallet::Object::Keytab->create (@name, $dbh, @trace) }; + is ($object, undef, 'Creation without permissions fails'); + like ($@, qr{^error adding principal wallet-test/one\@\Q$realm: }, + ' with the right error'); # Now, try retrieving the keytab. $object = Wallet::Object::Keytab->new ('keytab', 'wallet/one', $dbh); -- cgit v1.2.3