aboutsummaryrefslogtreecommitdiff
path: root/perl/t
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2018-06-03 17:52:20 -0700
committerRuss Allbery <eagle@eyrie.org>2018-06-03 17:52:20 -0700
commite37de01137270d9322405a3bf87035d032228fac (patch)
tree457904c5d2277b6a9e326d238339ce2c72deaef0 /perl/t
parentb320ea60b2761fc984fe2870a718da1ef7fc7440 (diff)
Fix skipping in verifier/netdb test
If AUTHOR_TESTING wasn't set, the test would plan twice. Fix this by restructuring it to delay printing a plan and convert the Kerberos ticket test to a skip_all plan.
Diffstat (limited to 'perl/t')
-rwxr-xr-xperl/t/verifier/netdb.t47
1 files changed, 25 insertions, 22 deletions
diff --git a/perl/t/verifier/netdb.t b/perl/t/verifier/netdb.t
index 0f3e2d4..c9e63d3 100755
--- a/perl/t/verifier/netdb.t
+++ b/perl/t/verifier/netdb.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More;
use Wallet::ACL::NetDB;
@@ -26,29 +26,32 @@ use Util;
# This test requires a specific environment setup, so only run it for package
# maintainers.
-skip_unless_author('LDAP verifier tests');
+skip_unless_author('NetDB verifier tests');
+# Check if we have the ticket cache required to run this test.
+my $klist = `klist 2>&1` || '';
+if ($klist !~ /^(Default p|\s+P)rincipal: \S+\@stanford\.edu$/m) {
+ plan skip_all => 'Requires Stanford Kerberos tickets';
+}
+
+# Set up the test plan.
+plan tests => 5;
+
+# Parameters for the test.
my $netdb = 'netdb-node-roles-rc.stanford.edu';
my $host = 'windlord.stanford.edu';
my $user = 'jonrober@stanford.edu';
-# Determine the local principal.
-my $klist = `klist 2>&1` || '';
-SKIP: {
- skip "tests useful only with Stanford Kerberos tickets", 5
- unless ($klist =~ /^(Default p|\s+P)rincipal: \S+\@stanford\.edu$/m);
-
- # Set up our configuration.
- $Wallet::Config::NETDB_REALM = 'stanford.edu';
- $Wallet::Config::NETDB_REMCTL_CACHE = $ENV{KRB5CCNAME};
- $Wallet::Config::NETDB_REMCTL_HOST = $netdb;
-
- # Finally, we can test.
- my $verifier = eval { Wallet::ACL::NetDB->new };
- ok (defined $verifier, ' and now creation succeeds');
- is ($@, q{}, ' with no errors');
- ok ($verifier->isa ('Wallet::ACL::NetDB'), ' and returns the right class');
- is ($verifier->check ($user, $host), 1, "Checking $host succeeds");
- is ($verifier->check ('test-user@stanford.edu', $host), 0,
- ' but fails with another user');
-}
+# Set up our configuration.
+$Wallet::Config::NETDB_REALM = 'stanford.edu';
+$Wallet::Config::NETDB_REMCTL_CACHE = $ENV{KRB5CCNAME};
+$Wallet::Config::NETDB_REMCTL_HOST = $netdb;
+
+# Finally, we can test.
+my $verifier = eval { Wallet::ACL::NetDB->new };
+ok (defined $verifier, ' and now creation succeeds');
+is ($@, q{}, ' with no errors');
+ok ($verifier->isa ('Wallet::ACL::NetDB'), ' and returns the right class');
+is ($verifier->check ($user, $host), 1, "Checking $host succeeds");
+is ($verifier->check ('test-user@stanford.edu', $host), 0,
+ ' but fails with another user');