diff options
| author | Russ Allbery <rra@stanford.edu> | 2007-09-17 16:29:07 +0000 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2007-09-17 16:29:07 +0000 | 
| commit | a385775cf0f1645d393f249c4a3b086c8b1d8a42 (patch) | |
| tree | 8917efe6b482463128505040a3a10bb001a09af3 | |
| parent | 66298af6358804e674748787cc0ccb642a63db3a (diff) | |
Add an acl show command to the front end that calls the appropriate
Wallet::Server method.
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | client/wallet.pod | 4 | ||||
| -rwxr-xr-x | server/wallet-backend | 12 | ||||
| -rw-r--r-- | tests/server/backend-t.in | 20 | 
4 files changed, 33 insertions, 8 deletions
@@ -2,11 +2,6 @@  Required to replace leland_srvtab: -* Add an ACL list function to display an ACL in human-readable form and -  call it from wallet-backend. - -* Display ACL details when displaying objects. -  * Write new files atomically in the wallet client and save backups unless    told not to (write to file.new, link the old file to file.old, and do    an atomic rename). diff --git a/client/wallet.pod b/client/wallet.pod index 8ae4e58..fd5749f 100644 --- a/client/wallet.pod +++ b/client/wallet.pod @@ -141,6 +141,10 @@ accidental lockout, but administrators can remove themselves from the  C<ADMIN> ACL and can leave only a non-functioning entry on the ACL.  Use  caution when removing entries from the C<ADMIN> ACL. +=item acl show <id> + +Display the name, numeric ID, and entries of the ACL <id>. +  =item create <type> <name>  Create a new object of type <type> with name <name>.  With some backends, diff --git a/server/wallet-backend b/server/wallet-backend index 015c035..8777990 100755 --- a/server/wallet-backend +++ b/server/wallet-backend @@ -77,6 +77,14 @@ sub command {          } elsif ($action eq 'rename') {              check_args (2, [], @args);              $server->acl_rename (@args) or die $server->error; +        } elsif ($action eq 'show') { +            check_args (1, [], @args); +            my $output = $server->acl_show (@args); +            if (defined $output) { +                print $output; +            } else { +                die $server->error; +            }          } else {              die "unknown command acl $action\n";          } @@ -234,6 +242,10 @@ accidental lockout, but administrators can remove themselves from the  C<ADMIN> ACL and can leave only a non-functioning entry on the ACL.  Use  caution when removing entries from the C<ADMIN> ACL. +=item acl show <id> + +Display the name, numeric ID, and entries of the ACL <id>. +  =item create <type> <name>  Create a new object of type <type> with name <name>.  With some backends, diff --git a/tests/server/backend-t.in b/tests/server/backend-t.in index c509fff..408cb0f 100644 --- a/tests/server/backend-t.in +++ b/tests/server/backend-t.in @@ -5,7 +5,7 @@  use strict;  use IO::String; -use Test::More tests => 710; +use Test::More tests => 720;  # Create a dummy class for Wallet::Server that prints what method was called  # with its arguments and returns data for testing. @@ -41,6 +41,13 @@ sub acl_remove  sub acl_rename      { shift; print "acl_rename @_\n"; ($_[0] eq 'error') ? undef : 1 } +sub acl_show { +    shift; +    print "acl_show @_\n"; +    return if $_[0] eq 'error'; +    return 'acl_show'; +} +  sub acl {      shift;      print "acl @_\n"; @@ -147,7 +154,8 @@ my %acl_commands = (add     => [3, 3],                      create  => [1, 1],                      destroy => [1, 1],                      remove  => [3, 3], -                    rename  => [2, 2]); +                    rename  => [2, 2], +                    show    => [1, 1]);  for my $command (sort keys %commands) {      my ($min, $max) = @{ $commands{$command} };      ($out, $err) = run_backend ($command, ('foo') x ($min - 1)); @@ -245,7 +253,13 @@ for my $command (sort keys %acl_commands) {      my $extra = @extra ? join (' ', '', @extra) : '';      ($out, $err) = run_backend ('acl', $command, 'name', @extra);      is ($err, '', "Command acl $command ran with no errors"); -    is ($out, "$new\nacl_$command name$extra\n", ' and ran the right method'); +    my $expected; +    if ($command eq 'show') { +        $expected = "$new\nacl_$command name$extra\nacl_show"; +    } else { +        $expected = "$new\nacl_$command name$extra\n"; +    } +    is ($out, $expected, ' and ran the right method');      ($out, $err) = run_backend ('acl', $command, 'error', @extra);      is ($err, "error count $error\n", "Command acl $command ran with errors");      is ($out, "$new\nacl_$command error$extra\n",  | 
