@@ -40,8 +40,8 @@ protected void createResources() throws IOException, TimeoutException {
4040 channel .exchangeDeclare (notProtectedTopic , BuiltinExchangeType .TOPIC );
4141 channel .exchangeDeclare (noneTopicExchange , BuiltinExchangeType .DIRECT );
4242
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 \" " );
4545 }
4646
4747 @ Override
@@ -87,6 +87,39 @@ public Void call() throws Exception {
8787 return null ;
8888 }
8989 });
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+ });
90123 }
91124
92125 void assertAccessOk (String description , Callable <Void > action ) {
0 commit comments