diff options
| author | Russ Allbery <rra@stanford.edu> | 2010-03-08 10:57:42 -0800 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2010-03-08 10:57:42 -0800 | 
| commit | 602ff7584d3668c36b1bf5fd43988e6f45eceb48 (patch) | |
| tree | f4870e09c76de744c44e230b1b60b21c89acae3b /tests/server/report-t | |
| parent | bf51d2dc4857551aadac4304c111c3ccd063604f (diff) | |
Imported Upstream version 0.11upstream/0.11
Diffstat (limited to 'tests/server/report-t')
| -rwxr-xr-x | tests/server/report-t | 42 | 
1 files changed, 35 insertions, 7 deletions
| diff --git a/tests/server/report-t b/tests/server/report-t index 285ee5a..394a869 100755 --- a/tests/server/report-t +++ b/tests/server/report-t @@ -8,7 +8,7 @@  # See LICENSE for licensing terms.  use strict; -use Test::More tests => 32; +use Test::More tests => 44;  # Create a dummy class for Wallet::Report that prints what method was called  # with its arguments and returns data for testing. @@ -38,6 +38,19 @@ sub acls {      return ([ 1, 'ADMIN' ], [ 2, 'group/admins' ], [ 4, 'group/users' ]);  } +sub audit { +    shift; +    print "audit @_\n"; +    return if ($error or $empty); +    if ($_[0] eq 'objects') { +        return ([ file => 'unix-wallet-password' ]); +    } elsif ($_[0] eq 'acls') { +        return ([ 2, 'group/admins' ]); +    } else { +        return; +    } +} +  sub objects {      shift;      print "objects @_\n"; @@ -81,6 +94,7 @@ is ($out, "new\n", ' and nothing ran');  # Check too few and too many arguments for every command.  my %commands = (acls    => [0, 3], +                audit   => [2, 2],                  objects => [0, 2],                  owners  => [2, 2]);  for my $command (sort keys %commands) { @@ -110,6 +124,14 @@ is ($err, '', 'List succeeds for ACLs');  is ($out, "new\nacls entry foo foo\n"      . "ADMIN (ACL ID: 1)\ngroup/admins (ACL ID: 2)\ngroup/users (ACL ID: 4)\n",      ' and returns the right output'); +($out, $err) = run_report ('audit', 'objects', 'name'); +is ($err, '', 'Object audit report succeeds'); +is ($out, "new\naudit objects name\nfile unix-wallet-password\n", +    ' and returns the right output'); +($out, $err) = run_report ('audit', 'acls', 'name'); +is ($err, '', 'ACL audit report succeeds'); +is ($out, "new\naudit acls name\ngroup/admins (ACL ID: 2)\n", +    ' and returns the right output');  ($out, $err) = run_report ('objects');  is ($err, '', 'List succeeds for objects');  is ($out, "new\nobjects \n" @@ -128,24 +150,30 @@ is ($out, "new\nowners % %\nkrb5 admin\@EXAMPLE.COM\n",  # Test error handling.  $Wallet::Report::error = 1;  ($out, $err) = run_report ('acls'); -is ($err, "some error\n", 'Error handling succeeds for list acls'); +is ($err, "some error\n", 'Error handling succeeds for acls');  is ($out, "new\nacls \n", ' and calls the right methods'); +($out, $err) = run_report ('audit', 'objects', 'name'); +is ($err, "some error\n", 'Error handling succeeds for audit'); +is ($out, "new\naudit objects name\n", ' and calls the right methods');  ($out, $err) = run_report ('objects'); -is ($err, "some error\n", 'Error handling succeeds for list objects'); +is ($err, "some error\n", 'Error handling succeeds for objects');  is ($out, "new\nobjects \n", ' and calls the right methods');  ($out, $err) = run_report ('owners', 'foo', 'bar'); -is ($err, "some error\n", 'Error handling succeeds for report owners'); +is ($err, "some error\n", 'Error handling succeeds for owners');  is ($out, "new\nowners foo bar\n", ' and calls the right methods');  # Test empty lists.  $Wallet::Report::error = 0;  $Wallet::Report::empty = 1;  ($out, $err) = run_report ('acls'); -is ($err, '', 'list acls runs with an empty list and no errors'); +is ($err, '', 'acls runs with an empty list and no errors');  is ($out, "new\nacls \n", ' and calls the right methods'); +($out, $err) = run_report ('audit', 'objects', 'name'); +is ($err, '', 'audit runs with an empty list and no errors'); +is ($out, "new\naudit objects name\n", ' and calls the right methods');  ($out, $err) = run_report ('objects'); -is ($err, '', 'list objects runs with an empty list with no errors'); +is ($err, '', 'objects runs with an empty list with no errors');  is ($out, "new\nobjects \n", ' and calls the right methods');  ($out, $err) = run_report ('owners', 'foo', 'bar'); -is ($err, '', 'report owners runs with an empty list and no errors'); +is ($err, '', 'owners runs with an empty list and no errors');  is ($out, "new\nowners foo bar\n", ' and calls the right methods'); | 
