diff options
| author | Russ Allbery <rra@stanford.edu> | 2007-09-17 16:02:18 +0000 | 
|---|---|---|
| committer | Russ Allbery <rra@stanford.edu> | 2007-09-17 16:02:18 +0000 | 
| commit | 81d2da8adbf8db6629e7a223b10633e58b288b19 (patch) | |
| tree | 9c061fe9dac79044f19217b9a7fdb29559468424 /perl | |
| parent | a793a836222b551517e359b47ba0882b4910944d (diff) | |
In show() for an object, call show() for each of the ACLs on that object
and append that information to the object description.
Diffstat (limited to 'perl')
| -rw-r--r-- | perl/Wallet/Object/Base.pm | 17 | ||||
| -rwxr-xr-x | perl/t/object.t | 3 | ||||
| -rwxr-xr-x | perl/t/server.t | 22 | 
3 files changed, 36 insertions, 6 deletions
diff --git a/perl/Wallet/Object/Base.pm b/perl/Wallet/Object/Base.pm index 79662e7..cddc0bf 100644 --- a/perl/Wallet/Object/Base.pm +++ b/perl/Wallet/Object/Base.pm @@ -346,16 +346,25 @@ sub show {          return undef;      }      my $output = ''; +    my @acls;      for (my $i = 0; $i < @data; $i++) {          next unless defined $data[$i];          if ($attrs[$i][0] =~ /^ob_(owner|acl_)/) {              my $acl = eval { Wallet::ACL->new ($data[$i], $self->{dbh}) };              if ($acl and not $@) {                  $data[$i] = $acl->name || $data[$i]; +                push (@acls, [ $acl, $data[$i] ]);              }          }          $output .= sprintf ("%15s: %s\n", $attrs[$i][1], $data[$i]);      } +    if (@acls) { +        my %seen; +        @acls = grep { !$seen{$_->[1]}++ } @acls; +        for my $acl (@acls) { +            $output .= "\n" . $acl->[0]->show; +        } +    }      return $output;  } @@ -529,9 +538,11 @@ Returns a formatted text description of the object suitable for human  display, or undef on error.  The default implementation shows all of the  base metadata about the object, formatted as key: value pairs with the keys  aligned in the first 15 characters followed by a space, a colon, and the -value.  Object implementations with additional data to display can rely on -that format to add additional settings into the formatted output or at the -end with a matching format. +value.  If any ACLs or an owner are set, after this data there is a blank +line and then the information for each unique ACL, separated by blank lines. +Object implementations with additional data to display can rely on that +format to add additional settings into the formatted output or at the end +with a matching format.  =item store(DATA, PRINCIPAL, HOSTNAME [, DATETIME]) diff --git a/perl/t/object.t b/perl/t/object.t index 05d8569..05f2f00 100755 --- a/perl/t/object.t +++ b/perl/t/object.t @@ -138,6 +138,9 @@ my $output = <<"EOO";       Created by: $user     Created from: $host       Created on: $created + +Members of ACL ADMIN (id: 1) are: +  krb5 $user  EOO  is ($object->show, $output, 'Show output is correct'); diff --git a/perl/t/server.t b/perl/t/server.t index 2b8ecbc..0b7ef17 100755 --- a/perl/t/server.t +++ b/perl/t/server.t @@ -344,7 +344,7 @@ is ($server->error,      "cannot store base:service/user1: object type is immutable",      ' and the method is called');  $show = $server->show ('base', 'service/user1'); -$show =~ s/(Created on:) \d+$/$1 0/; +$show =~ s/(Created on:) \d+$/$1 0/m;  $expected = <<"EOO";             Type: base             Name: service/user1 @@ -352,6 +352,9 @@ $expected = <<"EOO";       Created by: $admin     Created from: $host       Created on: 0 + +Members of ACL user1 (id: 2) are: +  krb5 $user1  EOO  is ($show, $expected, ' and show an object we own'); @@ -379,7 +382,7 @@ is ($server->error,      "cannot store base:service/both: object type is immutable",      ' and the method is called');  $show = $server->show ('base', 'service/both'); -$show =~ s/(Created on:) \d+$/$1 0/; +$show =~ s/(Created on:) \d+$/$1 0/m;  $expected = <<"EOO";             Type: base             Name: service/both @@ -389,6 +392,16 @@ $expected = <<"EOO";       Created by: $admin     Created from: $host       Created on: 0 + +Members of ACL both (id: 4) are: +  krb5 $user1 +  krb5 $user2 + +Members of ACL user1 (id: 2) are: +  krb5 $user1 + +Members of ACL user2 (id: 3) are: +  krb5 $user2  EOO  is ($show, $expected, ' and show an object we jointly own');  is ($server->destroy ('base', 'service/both'), undef, @@ -410,7 +423,7 @@ is ($server->error,      "cannot store base:service/user2: object type is immutable",      ' and the method is called');  $show = $server->show ('base', 'service/user2'); -$show =~ s/(Created on:) \d+$/$1 0/; +$show =~ s/(Created on:) \d+$/$1 0/m;  $expected = <<"EOO";             Type: base             Name: service/user2 @@ -418,6 +431,9 @@ $expected = <<"EOO";       Created by: $admin     Created from: $host       Created on: 0 + +Members of ACL user2 (id: 3) are: +  krb5 $user2  EOO  is ($show, $expected, ' and show an object we own');  | 
