You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "jbertram (via GitHub)" <gi...@apache.org> on 2023/07/13 14:29:02 UTC

[GitHub] [activemq-artemis] jbertram commented on a diff in pull request #4488: ARTEMIS-4293 add mngmnt ops to clear authn/z caches

jbertram commented on code in PR #4488:
URL: https://github.com/apache/activemq-artemis/pull/4488#discussion_r1262647465


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java:
##########
@@ -257,6 +257,32 @@ public void testSecurityCacheSizes() throws Exception {
       Wait.assertEquals(usingCore() ? 8 : 1, () -> serverControl.getAuthorizationCacheSize());
    }
 
+   @Test
+   public void testClearingSecurityCaches() throws Exception {
+      ActiveMQServerControl serverControl = createManagementControl();
+
+      ServerLocator loc = createInVMNonHALocator();
+      ClientSessionFactory csf = createSessionFactory(loc);
+      ClientSession session = csf.createSession("myUser", "myPass", false, true, false, false, 0);
+      session.start();
+
+      final String address = "ADDRESS";
+      serverControl.createAddress(address, "MULTICAST");
+      ClientProducer producer = session.createProducer(address);
+      ClientMessage m = session.createMessage(true);
+      m.putStringProperty("hello", "world");
+      producer.send(m);
+
+      Assert.assertTrue(serverControl.getAuthenticationCacheSize() > 0);
+      Wait.assertTrue(() -> serverControl.getAuthorizationCacheSize() > 0);
+
+      serverControl.clearAuthenticationCache();
+      serverControl.clearAuthorizationCache();
+
+      Assert.assertEquals(usingCore() ? 1 : 0, serverControl.getAuthenticationCacheSize());

Review Comment:
   The `usingCore()` method is implemented by:
   
    - `org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest` (returns `false`)
    - `org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlUsingCoreTest` (returns `true`)
   
   This method is meant to indicate when core _messages_ are being used for management rather than JMX. Using core requires an extra connection so the management messages can be sent. This extra connection (and everything that goes with it like authentications and authorizations) need to be ignored so that the same tests work with or without core.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org