diff --git a/src/test/java/com/rabbitmq/client/test/server/TopicPermissions.java b/src/test/java/com/rabbitmq/client/test/server/TopicPermissions.java index 8882b124dc..b045780250 100644 --- a/src/test/java/com/rabbitmq/client/test/server/TopicPermissions.java +++ b/src/test/java/com/rabbitmq/client/test/server/TopicPermissions.java @@ -40,8 +40,8 @@ protected void createResources() throws IOException, TimeoutException { channel.exchangeDeclare(notProtectedTopic, BuiltinExchangeType.TOPIC); channel.exchangeDeclare(noneTopicExchange, BuiltinExchangeType.DIRECT); - Host.rabbitmqctl("set_topic_permissions -p / guest " + protectedTopic + " \"^a\" \"^b\""); - Host.rabbitmqctl("set_topic_permissions -p / guest " + noneTopicExchange + " \"^a\" \"^b\""); + Host.rabbitmqctl("set_topic_permissions -p / guest " + protectedTopic + " \"^a\" \"^x\""); + Host.rabbitmqctl("set_topic_permissions -p / guest " + noneTopicExchange + " \"^a\" \"^x\""); } @Override @@ -87,6 +87,39 @@ public Void call() throws Exception { return null; } }); + assertAccessOk("Binding/unbinding on protected exchange with matching routing key, should pass", new Callable() { + @Override + public Void call() throws Exception { + String queue = channel.queueDeclare().getQueue(); + channel.queueBind(queue, protectedTopic, "x.y.z"); + channel.basicQos(0); + channel.queueUnbind(queue, protectedTopic, "x.y.z"); + channel.basicQos(0); + return null; + } + }); + assertAccessRefused("Binding/unbinding on protected exchange with none-matching routing key, should not pass", new Callable() { + @Override + public Void call() throws Exception { + String queue = channel.queueDeclare().getQueue(); + channel.queueBind(queue, protectedTopic, "y.z"); + channel.basicQos(0); + channel.queueUnbind(queue, protectedTopic, "y.z"); + channel.basicQos(0); + return null; + } + }); + assertAccessOk("Binding/unbinding on not-protected exchange with none-matching routing key, should pass", new Callable() { + @Override + public Void call() throws Exception { + String queue = channel.queueDeclare().getQueue(); + channel.queueBind(queue, notProtectedTopic, "y.z"); + channel.basicQos(0); + channel.queueUnbind(queue, notProtectedTopic, "y.z"); + channel.basicQos(0); + return null; + } + }); } void assertAccessOk(String description, Callable action) {