AMQ-5734 - additional test that verifies wildcard sub does not get access to unauthorised dests retain messages

This commit is contained in:
gtully 2019-11-22 15:45:03 +00:00
parent e4f155f548
commit f3ed0c7b87
1 changed files with 24 additions and 0 deletions

View File

@ -253,6 +253,30 @@ public class MQTTAuthTest extends MQTTAuthTestSupport {
connectionSub.subscribe(new Topic[]{new Topic("#", QoS.AT_LEAST_ONCE)});
Message msg = connectionSub.receive(1, TimeUnit.SECONDS);
assertNull("Shouldn't receive the message", msg);
}
@Test(timeout = 60 * 1000)
public void testWildcardRetainedSubscriptionLocked() throws Exception {
MQTT mqttPub = createMQTTConnection("pub", true);
mqttPub.setUserName("admin");
mqttPub.setPassword("admin");
getProxyToBroker().addTopic("one.foo");
BlockingConnection connectionPub = mqttPub.blockingConnection();
connectionPub.connect();
connectionPub.publish("one/foo", "test".getBytes(), QoS.AT_LEAST_ONCE, true);
MQTT mqttSub = createMQTTConnection("sub", true);
mqttSub.setUserName("user");
mqttSub.setPassword("password");
BlockingConnection connectionSub = mqttSub.blockingConnection();
connectionSub.connect();
connectionSub.subscribe(new Topic[]{new Topic("+/#", QoS.AT_LEAST_ONCE)});
Message msg = connectionSub.receive(1, TimeUnit.SECONDS);
assertNull("Shouldn't receive the message", msg);
assertEquals(1, getProxyToTopic("one.foo").getEnqueueCount());
}
@Test(timeout = 60 * 1000)