@@ -40,8 +40,8 @@ protected void createResources() throws IOException, TimeoutException {
40
40
channel .exchangeDeclare (notProtectedTopic , BuiltinExchangeType .TOPIC );
41
41
channel .exchangeDeclare (noneTopicExchange , BuiltinExchangeType .DIRECT );
42
42
43
- Host .rabbitmqctl ("set_topic_permissions -p / guest " + protectedTopic + " \" ^a\" \" ^b \" " );
44
- Host .rabbitmqctl ("set_topic_permissions -p / guest " + noneTopicExchange + " \" ^a\" \" ^b \" " );
43
+ Host .rabbitmqctl ("set_topic_permissions -p / guest " + protectedTopic + " \" ^a\" \" ^x \" " );
44
+ Host .rabbitmqctl ("set_topic_permissions -p / guest " + noneTopicExchange + " \" ^a\" \" ^x \" " );
45
45
}
46
46
47
47
@ Override
@@ -87,6 +87,39 @@ public Void call() throws Exception {
87
87
return null ;
88
88
}
89
89
});
90
+ assertAccessOk ("Binding/unbinding on protected exchange with matching routing key, should pass" , new Callable <Void >() {
91
+ @ Override
92
+ public Void call () throws Exception {
93
+ String queue = channel .queueDeclare ().getQueue ();
94
+ channel .queueBind (queue , protectedTopic , "x.y.z" );
95
+ channel .basicQos (0 );
96
+ channel .queueUnbind (queue , protectedTopic , "x.y.z" );
97
+ channel .basicQos (0 );
98
+ return null ;
99
+ }
100
+ });
101
+ assertAccessRefused ("Binding/unbinding on protected exchange with none-matching routing key, should not pass" , new Callable <Void >() {
102
+ @ Override
103
+ public Void call () throws Exception {
104
+ String queue = channel .queueDeclare ().getQueue ();
105
+ channel .queueBind (queue , protectedTopic , "y.z" );
106
+ channel .basicQos (0 );
107
+ channel .queueUnbind (queue , protectedTopic , "y.z" );
108
+ channel .basicQos (0 );
109
+ return null ;
110
+ }
111
+ });
112
+ assertAccessOk ("Binding/unbinding on not-protected exchange with none-matching routing key, should pass" , new Callable <Void >() {
113
+ @ Override
114
+ public Void call () throws Exception {
115
+ String queue = channel .queueDeclare ().getQueue ();
116
+ channel .queueBind (queue , notProtectedTopic , "y.z" );
117
+ channel .basicQos (0 );
118
+ channel .queueUnbind (queue , notProtectedTopic , "y.z" );
119
+ channel .basicQos (0 );
120
+ return null ;
121
+ }
122
+ });
90
123
}
91
124
92
125
void assertAccessOk (String description , Callable <Void > action ) {
0 commit comments