From f3ed0c7b87087244b4ba41f0d27d6a5ec5cdf06e Mon Sep 17 00:00:00 2001 From: gtully Date: Fri, 22 Nov 2019 15:45:03 +0000 Subject: [PATCH] AMQ-5734 - additional test that verifies wildcard sub does not get access to unauthorised dests retain messages --- .../activemq/transport/mqtt/MQTTAuthTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java index 7ffb3e80ab..98ba8c985f 100644 --- a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java +++ b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTAuthTest.java @@ -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)