aboutsummaryrefslogtreecommitdiff
path: root/perl/t/object
diff options
context:
space:
mode:
authorJon Robertson <jonrober@stanford.edu>2015-02-18 15:17:51 -0800
committerJon Robertson <jonrober@stanford.edu>2015-06-08 15:24:34 -0700
commit000b338694fae87996220336678fe990a1c3e3e1 (patch)
tree5266498e6c4024d56c8afc0afc5677de590fad8e /perl/t/object
parent1575e25c9e9edc8d577a0f1118732c98871984e0 (diff)
Added new method for wallet-backend, update
update will work generally like get, but only for objects that have a concept of updating content automatically, like keytabs and passwords. For these, the content will be updated before sending to the client. In a later release get for keytabs will be modified to never update the kvno before sending to the user, and so the unchanging flag will be phased out in lieu of explicitly using the method that does what you want. Change-Id: I96a84416c5e50278eb29fe07052dde6e063bc071
Diffstat (limited to 'perl/t/object')
-rwxr-xr-xperl/t/object/base.t5
-rw-r--r--perl/t/object/password.t8
2 files changed, 11 insertions, 2 deletions
diff --git a/perl/t/object/base.t b/perl/t/object/base.t
index ee9ff4b..8fedd64 100755
--- a/perl/t/object/base.t
+++ b/perl/t/object/base.t
@@ -12,7 +12,7 @@ use strict;
use warnings;
use POSIX qw(strftime);
-use Test::More tests => 137;
+use Test::More tests => 139;
use Wallet::ACL;
use Wallet::Admin;
@@ -208,6 +208,9 @@ is ($object->flag_clear ('locked', @trace), 1, 'Clearing locked succeeds');
eval { $object->get (@trace) };
is ($@, "Do not instantiate Wallet::Object::Base directly\n",
'Get fails with the right error');
+ok (!$object->update (@trace), 'Update fails');
+is ($object->error, 'update is not supported for this type, use get instead',
+ ' with the right error');
ok (! $object->store ("Some data", @trace), 'Store fails');
is ($object->error, "cannot store keytab:$princ: object type is immutable",
' with the right error');
diff --git a/perl/t/object/password.t b/perl/t/object/password.t
index c0f2fbc..4fe6b50 100644
--- a/perl/t/object/password.t
+++ b/perl/t/object/password.t
@@ -13,7 +13,7 @@ use strict;
use warnings;
use POSIX qw(strftime);
-use Test::More tests => 31;
+use Test::More tests => 33;
use Wallet::Admin;
use Wallet::Config;
@@ -111,6 +111,12 @@ ok (-f 'test-files/09/test', ' and the file exists');
is (contents ('test-files/09/test'), 'bar', ' with the right contents');
is ($object->get (@trace), "bar\n\0baz\n", ' and get returns correctly');
+# And check to make sure update changes the contents.
+$pwd = $object->update (@trace);
+isnt ($pwd, "bar\n\0baz\n", 'Update changes the contents');
+like ($pwd, qr{^.{$Wallet::Config::PWD_LENGTH_MIN}$},
+ ' to a random password string of the right length');
+
# Clean up.
$admin->destroy;
END {