summaryrefslogtreecommitdiff
path: root/perl/t/server.t
diff options
context:
space:
mode:
Diffstat (limited to 'perl/t/server.t')
-rwxr-xr-xperl/t/server.t41
1 files changed, 38 insertions, 3 deletions
diff --git a/perl/t/server.t b/perl/t/server.t
index 090387b..ed92d6e 100755
--- a/perl/t/server.t
+++ b/perl/t/server.t
@@ -1,13 +1,13 @@
#!/usr/bin/perl -w
#
-# t/server.t -- Tests for the wallet server API.
+# Tests for the wallet server API.
#
# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2007, 2008 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2007, 2008, 2010 Board of Trustees, Leland Stanford Jr. University
#
# See LICENSE for licensing terms.
-use Test::More tests => 341;
+use Test::More tests => 355;
use POSIX qw(strftime);
use Wallet::Admin;
@@ -923,6 +923,41 @@ is ($server->error, 'base:host/default.stanford.edu rejected: host'
. ' default.stanford.edu not in .example.edu domain',
' with the right error');
+# Ensure that we can't destroy an ACL that's in use.
+is ($server->acl_create ('test-destroy'), 1, 'Creating an ACL works');
+is ($server->create ('base', 'service/acl-user'), 1, 'Creating object works');
+is ($server->owner ('base', 'service/acl-user', 'test-destroy'), 1,
+ ' and setting owner');
+is ($server->acl_destroy ('test-destroy'), undef,
+ ' and now we cannot destroy that ACL');
+is ($server->error,
+ 'cannot destroy ACL 9: ACL in use by base:service/acl-user',
+ ' with the right error');
+is ($server->owner ('base', 'service/acl-user', ''), 1,
+ ' but after we clear the owner');
+is ($server->acl_destroy ('test-destroy'), 1, ' now we can destroy the ACL');
+is ($server->destroy ('base', 'service/acl-user'), 1, ' and the object');
+
+# Test ACL naming enforcement. Require that ACL names not contain a slash.
+package Wallet::Config;
+sub verify_acl_name {
+ my ($name, $user) = @_;
+ return 'ACL names may not contain slash' if $name =~ m,/,;
+ return;
+}
+package main;
+is ($server->acl_create ('test/naming'), undef,
+ 'Creating an ACL with a disallowed name fails');
+is ($server->error, 'test/naming rejected: ACL names may not contain slash',
+ ' with the right error message');
+is ($server->acl_create ('test-naming'), 1,
+ 'Creating test-naming succeeds');
+is ($server->acl_rename ('test-naming', 'test/naming'), undef,
+ ' but renaming it fails');
+is ($server->error, 'test/naming rejected: ACL names may not contain slash',
+ ' with the right error message');
+is ($server->acl_destroy ('test-naming'), 1, 'Destroying it succeeds');
+
# Clean up.
$setup->destroy;
unlink 'wallet-db';