Skip to content

Add test for topic permission on queue bind/unbind #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2017
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