Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Void>() {
@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<Void>() {
@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<Void>() {
@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<Void> action) {
Expand Down