aboutsummaryrefslogtreecommitdiff
path: root/perl/t/object.t
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-09-17 17:58:51 +0000
committerRuss Allbery <rra@stanford.edu>2007-09-17 17:58:51 +0000
commit488ad0911d63d46d9adad156edafc7d5d4d84df5 (patch)
tree7317a4ef3be04dff12fe370138dfed666e9ea4c6 /perl/t/object.t
parent604eb0dfd73390a72852b5eed850744089dd289e (diff)
Add methods to the base object to set, clear, list, and check flags. Wrap
attribute setting in objects inside eval to catch SQL errors and set the object error accordingly rather than throwing an exception.
Diffstat (limited to 'perl/t/object.t')
-rwxr-xr-xperl/t/object.t36
1 files changed, 35 insertions, 1 deletions
diff --git a/perl/t/object.t b/perl/t/object.t
index 05f2f00..2514c04 100755
--- a/perl/t/object.t
+++ b/perl/t/object.t
@@ -3,7 +3,7 @@
#
# t/object.t -- Tests for the basic object implementation.
-use Test::More tests => 74;
+use Test::More tests => 93;
use Wallet::ACL;
use Wallet::Config;
@@ -116,6 +116,40 @@ for my $type (qw/get store show destroy flags/) {
' and setting it again works');
}
+# Flags.
+my @flags = $object->flag_list;
+is (scalar (@flags), 0, 'No flags set to start');
+is ($object->flag_check ('locked'), 0, ' and locked is not set');
+is ($object->flag_set ('locked', @trace), 1, ' and setting locked works');
+is ($object->flag_check ('locked'), 1, ' and now locked is set');
+@flags = $object->flag_list;
+is (scalar (@flags), 1, ' and there is one flag');
+is ($flags[0], 'locked', ' which is locked');
+is ($object->flag_set ('locked', @trace), undef, 'Setting locked again fails');
+is ($object->error,
+ "cannot set flag locked on keytab:$princ: flag already set",
+ ' with the right error');
+is ($object->flag_set ('unchanging', @trace), 1,
+ ' but setting unchanging works');
+is ($object->flag_check ('unchanging'), 1, ' and unchanging is now set');
+@flags = $object->flag_list;
+is (scalar (@flags), 2, ' and there are two flags');
+is ($flags[0], 'locked', ' which are locked');
+is ($flags[1], 'unchanging', ' and unchanging');
+is ($object->flag_clear ('locked', @trace), 1, 'Clearing locked works');
+is ($object->flag_check ('locked'), 0, ' and now it is not set');
+is ($object->flag_check ('unchanging'), 1, ' but unchanging still is');
+is ($object->flag_clear ('locked', @trace), undef,
+ ' and clearing it again fails');
+is ($object->error,
+ "cannot clear flag locked on keytab:$princ: flag not set",
+ ' with the right error');
+if ($object->flag_set ('locked', @trace)) {
+ ok (1, ' and setting it again works');
+} else {
+ is ($object->error, '', ' and setting it again works');
+}
+
# Test stub methods.
eval { $object->get };
is ($@, "Do not instantiate Wallet::Object::Base directly\n",