Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 722F91760D for ; Fri, 13 Mar 2015 13:17:18 +0000 (UTC) Received: (qmail 56808 invoked by uid 500); 13 Mar 2015 13:17:18 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 56762 invoked by uid 500); 13 Mar 2015 13:17:18 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 56753 invoked by uid 99); 13 Mar 2015 13:17:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Mar 2015 13:17:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0A7AAE0B2D; Fri, 13 Mar 2015 13:17:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dejanb@apache.org To: commits@activemq.apache.org Message-Id: <5af1992dd31d4241bef6f2f032eeb235@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: https://issues.apache.org/jira/browse/AMQ-5644 - fixing the test as many assumptions in it are not correct and were working previously only cause of this bug Date: Fri, 13 Mar 2015 13:17:18 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/master 6097401c5 -> 10c47d69d https://issues.apache.org/jira/browse/AMQ-5644 - fixing the test as many assumptions in it are not correct and were working previously only cause of this bug Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/10c47d69 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/10c47d69 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/10c47d69 Branch: refs/heads/master Commit: 10c47d69d7545157f79d9b1dff15eabca147754d Parents: 6097401 Author: Dejan Bosanac Authored: Fri Mar 13 14:16:37 2015 +0100 Committer: Dejan Bosanac Committed: Fri Mar 13 14:16:58 2015 +0100 ---------------------------------------------------------------------- .../org/apache/activemq/AuthorizationTest.java | 67 +++----------------- 1 file changed, 10 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/10c47d69/activemq-runtime-config/src/test/java/org/apache/activemq/AuthorizationTest.java ---------------------------------------------------------------------- diff --git a/activemq-runtime-config/src/test/java/org/apache/activemq/AuthorizationTest.java b/activemq-runtime-config/src/test/java/org/apache/activemq/AuthorizationTest.java index 4cd92ac..b9282a0 100644 --- a/activemq-runtime-config/src/test/java/org/apache/activemq/AuthorizationTest.java +++ b/activemq-runtime-config/src/test/java/org/apache/activemq/AuthorizationTest.java @@ -79,8 +79,8 @@ public class AuthorizationTest extends RuntimeConfigTestSupport { startBroker(brokerConfig); assertTrue("broker alive", brokerService.isStarted()); - final String ALL_USERS = "ALL.USERS"; - final String ALL_GUESTS = "ALL.GUESTS"; + final String ALL_USERS = "ALL.USERS.>"; + final String ALL_GUESTS = "ALL.GUESTS.>"; assertAllowed("user", ALL_USERS); assertAllowed("guest", ALL_GUESTS); @@ -88,65 +88,18 @@ public class AuthorizationTest extends RuntimeConfigTestSupport { assertDenied("guest", ALL_GUESTS + "," + ALL_USERS); final String ALL_PREFIX = "ALL.>"; - final String ALL_WILDCARD = "ALL.*"; - - assertAllowed("user", ALL_PREFIX); - assertAllowed("user", ALL_WILDCARD); - assertAllowed("guest", ALL_PREFIX); - assertAllowed("guest", ALL_WILDCARD); - - assertAllowed("user", "ALL.USERS,ALL.>"); - assertAllowed("guest", "ALL.GUESTS,ALL.*"); - assertDenied("user", "ALL.GUESTS,ALL.>"); - assertDenied("guest", "ALL.USERS,ALL.*"); - - assertDenied("user", "ALL.USERS,ALL.GUESTS.>"); - assertDenied("guest", "ALL.GUESTS,ALL.USERS.*"); - assertDenied("user", "ALL.USERS.*,ALL.GUESTS.>"); - assertDenied("guest", "ALL.GUESTS.>,ALL.USERS.*"); - - // subscribe to wildcards and check whether messages are actually filtered - final ActiveMQConnection userConn = new ActiveMQConnectionFactory("vm://localhost").createActiveMQConnection("user", "user"); - final ActiveMQConnection guestConn = new ActiveMQConnectionFactory("vm://localhost").createActiveMQConnection("guest", "guest"); - userConn.start(); - guestConn.start(); - try { - final Session userSession = userConn.createSession(false, Session.AUTO_ACKNOWLEDGE); - final Session guestSession = guestConn.createSession(false, Session.AUTO_ACKNOWLEDGE); - final MessageProducer userProducer = userSession.createProducer(null); - final MessageProducer guestProducer = guestSession.createProducer(null); - - // test prefix filter - MessageConsumer userConsumer = userSession.createConsumer(userSession.createQueue(ALL_PREFIX)); - MessageConsumer guestConsumer = guestSession.createConsumer(userSession.createQueue(ALL_PREFIX)); - - userProducer.send(userSession.createQueue(ALL_USERS), userSession.createTextMessage(ALL_USERS)); - assertNotNull(userConsumer.receive(RECEIVE_TIMEOUT)); - assertNull(guestConsumer.receive(RECEIVE_TIMEOUT)); - - guestProducer.send(guestSession.createQueue(ALL_GUESTS), guestSession.createTextMessage(ALL_GUESTS)); - assertNotNull(guestConsumer.receive(RECEIVE_TIMEOUT)); - assertNull(userConsumer.receive(RECEIVE_TIMEOUT)); - userConsumer.close(); - guestConsumer.close(); + assertDenied("user", ALL_PREFIX); + assertDenied("guest", ALL_PREFIX); - // test wildcard filter - userConsumer = userSession.createConsumer(userSession.createQueue(ALL_WILDCARD)); - guestConsumer = guestSession.createConsumer(userSession.createQueue(ALL_WILDCARD)); + assertAllowed("user", "ALL.USERS.A"); + assertAllowed("user", "ALL.USERS.A,ALL.USERS.B"); + assertAllowed("guest", "ALL.GUESTS.A"); + assertAllowed("guest", "ALL.GUESTS.A,ALL.GUESTS.B"); - userProducer.send(userSession.createQueue(ALL_USERS), userSession.createTextMessage(ALL_USERS)); - assertNotNull(userConsumer.receive(RECEIVE_TIMEOUT)); - assertNull(guestConsumer.receive(RECEIVE_TIMEOUT)); + assertDenied("user", "USERS.>"); + assertDenied("guest", "GUESTS.>"); - guestProducer.send(guestSession.createQueue(ALL_GUESTS), guestSession.createTextMessage(ALL_GUESTS)); - assertNotNull(guestConsumer.receive(RECEIVE_TIMEOUT)); - assertNull(userConsumer.receive(RECEIVE_TIMEOUT)); - - } finally { - userConn.close(); - guestConn.close(); - } assertAllowedTemp("guest"); }