diff options
| author | Russ Allbery <eagle@eyrie.org> | 2015-12-14 21:54:13 -0800 | 
|---|---|---|
| committer | Russ Allbery <eagle@eyrie.org> | 2015-12-14 21:54:13 -0800 | 
| commit | b0d5c2d20c19ba4f4274a260660c98757ba07644 (patch) | |
| tree | ed2a02e79d6026bdb09e999da433033c0492bee5 /perl/t/policy | |
| parent | 6b7b9a29d20a65712061648404bbc6f1be5cacee (diff) | |
| parent | 6b0cad572edef05d119abc8fc843c8c5d33665b8 (diff) | |
Merge pull request #2 from jonrober/master
Changes so far for 1.3
Diffstat (limited to 'perl/t/policy')
| -rwxr-xr-x | perl/t/policy/stanford.t | 35 | 
1 files changed, 32 insertions, 3 deletions
| diff --git a/perl/t/policy/stanford.t b/perl/t/policy/stanford.t index 555086c..0c3dd2d 100755 --- a/perl/t/policy/stanford.t +++ b/perl/t/policy/stanford.t @@ -16,7 +16,7 @@ use 5.008;  use strict;  use warnings; -use Test::More tests => 101; +use Test::More tests => 130;  use lib 't/lib';  use Util; @@ -24,10 +24,16 @@ use Util;  # Load the naming policy module.  BEGIN {      use_ok('Wallet::Admin'); -    use_ok('Wallet::Policy::Stanford', qw(default_owner verify_name)); +    use_ok('Wallet::Policy::Stanford', +           qw(default_owner verify_name is_for_host));      use_ok('Wallet::Server');  } +# Set up our configuration for netdb, needed for the netdb verifier. +$Wallet::Config::NETDB_REALM        = 'stanford.edu'; +$Wallet::Config::NETDB_REMCTL_CACHE = $ENV{KRB5CCNAME}; +$Wallet::Config::NETDB_REMCTL_HOST  = 'netdb-node-roles-rc.stanford.edu'; +  # Various valid keytab names.  my @VALID_KEYTABS = qw(host/example.stanford.edu HTTP/example.stanford.edu      service/example example/cgi class-example01/cgi dept-01example/cgi @@ -101,6 +107,29 @@ for my $name (@INVALID_FILES) {      isnt(verify_name('file', $name), undef, "Invalid file $name");  } +# Now test a few cases for checking to see if a file is host-based.  We don't +# test the legacy examples because they're more complicated and less obvious. +for my $name (@VALID_KEYTABS) { +    my $hostname = 'example.stanford.edu'; +    if ($name =~ m{\b$hostname\b}) { +        is(is_for_host('keytab', $name, $hostname), 1, +           "Keytab $name belongs to $hostname"); +    } else { +        is(is_for_host('keytab', $name, $hostname), 0, +           "Keytab $name doesn't belong to $hostname"); +    } +} +for my $name (@VALID_FILES) { +    my $hostname = 'example.stanford.edu'; +    if ($name =~ m{\b$hostname\b}) { +        is(is_for_host('file', $name, $hostname), 1, +           "File $name belongs to $hostname"); +    } else { +        is(is_for_host('file', $name, $hostname), 0, +           "File $name doesn't belong to $hostname"); +    } +} +  # Now we need an actual database.  Use Wallet::Admin to set it up.  db_setup;  my $setup = eval { Wallet::Admin->new }; @@ -116,7 +145,7 @@ is(        'example.stanford.edu'),      1,      '...with netdb ACL line' -); +  );  is(      $server->acl_add('host/example.stanford.edu', 'krb5',        'host/example.stanford.edu@stanford.edu'), | 
