summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorJon Robertson <jonrober@stanford.edu>2010-01-26 15:16:36 -0800
committerJon Robertson <jonrober@stanford.edu>2010-01-26 15:16:36 -0800
commit8d4899825cf723ef6a975306f146a06388ed4547 (patch)
treee5ce653d337895db63d3299aa4eca019c111648d /perl
parentdad764bc84d371ffc775e66b942ecbbc59f05c8e (diff)
Skip tests in kadmin.t if module requirements are missing
Made kadmin.t skip loading the Wallet::Kadmin::Heimdal module if its requirement, Heimdal::Kadm5, is not installed on the system.
Diffstat (limited to 'perl')
-rwxr-xr-xperl/t/kadmin.t29
1 files changed, 20 insertions, 9 deletions
diff --git a/perl/t/kadmin.t b/perl/t/kadmin.t
index 8ecc2c1..96b249b 100755
--- a/perl/t/kadmin.t
+++ b/perl/t/kadmin.t
@@ -13,9 +13,17 @@ use Test::More tests => 17;
use Wallet::Admin;
use Wallet::Config;
use Wallet::Kadmin;
-use Wallet::Kadmin::Heimdal;
use Wallet::Kadmin::MIT;
+# Only load Wallet::Kadmin::Heimdal if a required module is found.
+my $heimdal_kadm5 = 0;
+eval 'use Heimdal::Kadm5';
+if (!$@) {
+ print "No error...\n";
+ $heimdal_kadm5 = 1;
+ require Wallet::Kadmin::Heimdal;
+}
+
use lib 't/lib';
use Util;
@@ -41,7 +49,7 @@ ok (defined ($kadmin), 'MIT kadmin object created');
my $callback = sub { return 1 };
$kadmin->fork_callback ($callback);
is ($kadmin->{fork_callback} (), 1, ' and callback works.');
-my $callback = sub { return 2 };
+$callback = sub { return 2 };
$kadmin->fork_callback ($callback);
is ($kadmin->{fork_callback} (), 2, ' and changing it works.');
@@ -49,10 +57,13 @@ is ($kadmin->{fork_callback} (), 2, ' and changing it works.');
# we need a properly configured Heimdal KDC. So instead, we deliberately
# connect without configuration to get the error. That at least tests that
# we can find the Heimdal module and it dies how it should.
-undef $Wallet::Config::KEYTAB_PRINCIPAL;
-undef $Wallet::Config::KEYTAB_FILE;
-undef $Wallet::Config::KEYTAB_REALM;
-undef $kadmin;
-$Wallet::Config::KEYTAB_KRBTYPE = 'Heimdal';
-$kadmin = eval { Wallet::Kadmin->new () };
-is ($kadmin, undef, 'Heimdal fails properly.');
+SKIP: {
+ skip 'Heimdal::Kadm5 not installed', 1 unless $heimdal_kadm5;
+ undef $Wallet::Config::KEYTAB_PRINCIPAL;
+ undef $Wallet::Config::KEYTAB_FILE;
+ undef $Wallet::Config::KEYTAB_REALM;
+ undef $kadmin;
+ $Wallet::Config::KEYTAB_KRBTYPE = 'Heimdal';
+ $kadmin = eval { Wallet::Kadmin->new () };
+ is ($kadmin, undef, 'Heimdal fails properly.');
+}