git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] activemq-artemis pull request #1722: (WIP DO NOT MERGE) ARTEMIS-1545 Support...


Github user tabish121 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1722#discussion_r157260287
  
    --- Diff: tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/SecurityTest.java ---
    @@ -169,6 +180,71 @@ public void testLoginInvalidUserInvalidPassword() throws Exception {
           }
        }
     
    +   /**
    +    * Login with valid user and password
    +    * But try send to address not authorised - Persistent
    +    * Should not allow and should throw exception
    +    */
    +   @Test
    +   public void testLoginValidUserAndPasswordButNotAuthorisedToSend() throws Exception {
    +      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    +      Connection connection = connectionFactory.createConnection("guest", "guest");
    +      Session session = connection.createSession();
    +      Destination destination = session.createQueue("guest.cannot.send");
    +      MessageProducer messageProducer = session.createProducer(destination);
    +      try {
    +         messageProducer.send(session.createTextMessage("hello"));
    +         fail("JMSSecurityException expected as guest is not allowed to send");
    +      } catch (JMSSecurityException activeMQSecurityException) {
    +         //pass
    +      }
    +      connection.close();
    +   }
    +
    +   /**
    +    * Login with valid user and password
    +    * But try send to address not authorised - Non Persistent.
    +    * Should have same behaviour as Persistent with exception on send.
    +    */
    +   @Test
    +   public void testLoginValidUserAndPasswordButNotAuthorisedToSendNonPersistent() throws Exception {
    +      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    +      connectionFactory.setConfirmationWindowSize(100);
    +      connectionFactory.setBlockOnDurableSend(false);
    +      connectionFactory.setBlockOnNonDurableSend(false);
    +      Connection connection = connectionFactory.createConnection("guest", "guest");
    +      Session session = connection.createSession();
    +      Destination destination = session.createQueue("guest.cannot.send");
    +      MessageProducer messageProducer = session.createProducer(destination);
    +      messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    +      try {
    +         AtomicReference<Exception> e = new AtomicReference<>();
    +         //        messageProducer.send(session.createTextMessage("hello"));
    +
    +         CountDownLatch countDownLatch = new CountDownLatch(1);
    +         messageProducer.send(session.createTextMessage("hello"), new CompletionListener() {
    +            @Override
    +            public void onCompletion(Message message) {
    +               countDownLatch.countDown();
    +            }
    +
    +            @Override
    +            public void onException(Message message, Exception exception) {
    +               countDownLatch.countDown();
    +               e.set(exception);
    --- End diff --
    
    The set here should occur prior to the countDown to avoid potential race on the later check of error state.  


---



( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-activemq-developers/msg08167.html on line 136
Call Stack
#TimeMemoryFunctionLocation
10.0007368824{main}( ).../msg08167.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-activemq-developers/msg08167.html on line 136
Call Stack
#TimeMemoryFunctionLocation
10.0007368824{main}( ).../msg08167.html:0