diff options
| author | Aidan Skinner <aidan@apache.org> | 2009-02-04 15:33:26 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2009-02-04 15:33:26 +0000 |
| commit | 80c1c1da2855cc0c03d08a0fcb425c38b3344333 (patch) | |
| tree | 5cdfa774288771b66efa8d803b65ff0025f50c60 /java/broker/src/test | |
| parent | ee048535988a9434057d65822b1327a50ab11dd3 (diff) | |
| download | qpid-python-80c1c1da2855cc0c03d08a0fcb425c38b3344333.tar.gz | |
QPID-1626: Make ACLPlugin a more sensible interface, get rid of the giant switch in SimpleXML. Handlers shouldn't rely on the plugin throwing an exception for flow control, they now check the return value and do the right thing themselves.
AllowAll, DenyAll now extend BasicACLPlugin.
PrinciplePermissions(Test): futz with the interface a little so that it's easier to call from an ACLPlugin implementation. Leave the giant switch alone as it's quite fragile, and throws rocks at cats.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@740769 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker/src/test')
| -rw-r--r-- | java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java b/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java index 7927339491..df41ac9dc2 100644 --- a/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java +++ b/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java @@ -54,7 +54,7 @@ public class PrincipalPermissionsTest extends TestCase private AMQShortString _exchangeType = new AMQShortString("direct"); private boolean _internal = false; - private DirectExchange _exchange = new DirectExchange(); + private DirectExchange _exchange; private VirtualHost _virtualHost; private AMQShortString _owner = new AMQShortString(this.getClass().getName()+"owner"); private AMQQueue _queue; @@ -67,6 +67,7 @@ public class PrincipalPermissionsTest extends TestCase try { _virtualHost = new VirtualHost("localhost", new SkeletonMessageStore()); + _exchange = DirectExchange.TYPE.newInstance(_virtualHost, _exchangeName, _durable, _ticket, _autoDelete); _queue = AMQQueueFactory.createAMQQueueImpl(_queueName, false, _owner , false, _virtualHost, _arguments); } catch (Exception e) @@ -96,15 +97,11 @@ public class PrincipalPermissionsTest extends TestCase public void testQueueCreate() { Object[] grantArgs = new Object[]{_temporary , _queueName, _exchangeName, _routingKey}; + Object[] authArgs = new Object[]{_autoDelete, _queueName}; - - QueueDeclareBodyImpl queueDeclare = new QueueDeclareBodyImpl( - _ticket, _queueName, _passive, _durable, _exclusive, _autoDelete, _nowait, _arguments); - Object[] authArgs = new Object[]{queueDeclare}; - - assertFalse(_perms.authorise(Permission.CREATE, authArgs)); - _perms.grant(Permission.CREATE, grantArgs); - assertTrue(_perms.authorise(Permission.CREATE, authArgs)); + assertFalse(_perms.authorise(Permission.CREATEQUEUE, authArgs)); + _perms.grant(Permission.CREATEQUEUE, grantArgs); + assertTrue(_perms.authorise(Permission.CREATEQUEUE, authArgs)); } @@ -117,9 +114,9 @@ public class PrincipalPermissionsTest extends TestCase Object[] authArgs = new Object[]{exchangeDeclare}; Object[] grantArgs = new Object[]{_exchangeName, _exchangeType}; - assertFalse(_perms.authorise(Permission.CREATE, authArgs)); - _perms.grant(Permission.CREATE, grantArgs); - assertTrue(_perms.authorise(Permission.CREATE, authArgs)); + assertFalse(_perms.authorise(Permission.CREATEEXCHANGE, authArgs)); + _perms.grant(Permission.CREATEEXCHANGE, grantArgs); + assertTrue(_perms.authorise(Permission.CREATEEXCHANGE, authArgs)); } public void testConsume() @@ -137,9 +134,10 @@ public class PrincipalPermissionsTest extends TestCase public void testPublish() { Object[] authArgs = new Object[]{_exchange, _routingKey}; + Object[] grantArgs = new Object[]{_exchange.getName(), _routingKey}; assertFalse(_perms.authorise(Permission.PUBLISH, authArgs)); - _perms.grant(Permission.PUBLISH, authArgs); + _perms.grant(Permission.PUBLISH, grantArgs); assertTrue(_perms.authorise(Permission.PUBLISH, authArgs)); } |
