activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [activemq-artemis] branch master updated: NO-JIRA fixing tests after ARTEMIS-2889 changes broke them
Date Thu, 17 Sep 2020 14:52:07 GMT
This is an automated email from the ASF dual-hosted git repository.

jbertram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new b896908  NO-JIRA fixing tests after ARTEMIS-2889 changes broke them
b896908 is described below

commit b89690813dbd00b53accbee67b96d212f6c6e007
Author: Justin Bertram <jbertram@apache.org>
AuthorDate: Thu Sep 17 09:50:41 2020 -0500

    NO-JIRA fixing tests after ARTEMIS-2889 changes broke them
---
 ...egacyLDAPSecuritySettingPluginListenerTest.java | 35 ++++++++++++----------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java
index 3345b94..d8bc1a8 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/LegacyLDAPSecuritySettingPluginListenerTest.java
@@ -32,6 +32,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.UUID;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.QueueConfiguration;
@@ -349,6 +350,8 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
    @Test
    public void testNewUserAndRole() throws Exception {
+      final String USERNAME = UUID.randomUUID().toString();
+      final String ROLE = UUID.randomUUID().toString();
       server.getConfiguration().setSecurityInvalidationInterval(0);
       server.start();
       String queue = "queue1";
@@ -357,7 +360,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
       // authentication should fail
       try {
-         cf.createSession("third", "secret", false, true, true, false, 0);
+         cf.createSession(USERNAME, "secret", false, true, true, false, 0);
          Assert.fail("Creating a session here should fail due to the original security data.");
       } catch (ActiveMQException e) {
          Assert.assertTrue(e.getMessage().contains("229031")); // authentication exception
@@ -372,23 +375,23 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
          objclass.add("simpleSecurityObject");
          objclass.add("account");
          basicAttributes.put(objclass);
-         ctx.bind("uid=third,ou=system", null, basicAttributes);
+         ctx.bind("uid=" + USERNAME + ",ou=system", null, basicAttributes);
       }
 
       { // add new role
          DirContext ctx = getContext();
          BasicAttributes basicAttributes = new BasicAttributes();
-         basicAttributes.put("member", "uid=third,ou=system");
+         basicAttributes.put("member", "uid=" + USERNAME + ",ou=system");
          Attribute objclass = new BasicAttribute("objectclass");
          objclass.add("top");
          objclass.add("groupOfNames");
          basicAttributes.put(objclass);
-         ctx.bind("cn=role3,ou=system", null, basicAttributes);
+         ctx.bind("cn=" + ROLE + ",ou=system", null, basicAttributes);
       }
 
       // authentication should succeed now, but authorization for sending should still fail
       try {
-         ClientSession session = cf.createSession("third", "secret", false, true, true, false,
0);
+         ClientSession session = cf.createSession(USERNAME, "secret", false, true, true,
false, 0);
          ClientProducer producer = session.createProducer(queue);
          producer.send(session.createMessage(true));
          Assert.fail("Producing here should fail due to the original security data.");
@@ -399,12 +402,12 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
       { // add write/send permission for new role to existing "queue1"
          DirContext ctx = getContext();
          BasicAttributes basicAttributes = new BasicAttributes();
-         basicAttributes.put("uniquemember", "cn=role3");
+         basicAttributes.put("uniquemember", "cn=" + ROLE);
          ctx.modifyAttributes("cn=write,cn=queue1,ou=queues,ou=destinations,o=ActiveMQ,ou=system",
DirContext.ADD_ATTRIBUTE, basicAttributes);
          ctx.close();
       }
 
-      ClientSession session = cf.createSession("third", "secret", false, true, true, false,
0);
+      ClientSession session = cf.createSession(USERNAME, "secret", false, true, true, false,
0);
       ClientProducer producer = session.createProducer(queue);
       producer.send(session.createMessage(true));
 
@@ -413,6 +416,8 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
    @Test
    public void testNewUserAndRoleWithNewDestination() throws Exception {
+      final String USERNAME = UUID.randomUUID().toString();
+      final String ROLE = UUID.randomUUID().toString();
       server.getConfiguration().setSecurityInvalidationInterval(0);
       server.start();
       ClientSessionFactory cf = locator.createSessionFactory();
@@ -423,7 +428,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
       // authentication should fail
       try {
-         cf.createSession("third", "secret", false, true, true, false, 0);
+         cf.createSession(USERNAME, "secret", false, true, true, false, 0);
          Assert.fail("Creating a session here should fail due to the original security data.");
       } catch (ActiveMQException e) {
          Assert.assertTrue(e.getMessage().contains("229031")); // authentication exception
@@ -438,23 +443,23 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
          objclass.add("simpleSecurityObject");
          objclass.add("account");
          basicAttributes.put(objclass);
-         ctx.bind("uid=third,ou=system", null, basicAttributes);
+         ctx.bind("uid=" + USERNAME + ",ou=system", null, basicAttributes);
       }
 
       { // add new role
          DirContext ctx = getContext();
          BasicAttributes basicAttributes = new BasicAttributes();
-         basicAttributes.put("member", "uid=third,ou=system");
+         basicAttributes.put("member", "uid=" + USERNAME + ",ou=system");
          Attribute objclass = new BasicAttribute("objectclass");
          objclass.add("top");
          objclass.add("groupOfNames");
          basicAttributes.put(objclass);
-         ctx.bind("cn=role3,ou=system", null, basicAttributes);
+         ctx.bind("cn=" + ROLE + ",ou=system", null, basicAttributes);
       }
 
       // authentication should succeed now, but authorization for sending should still fail
       try {
-         ClientSession session = cf.createSession("third", "secret", false, true, true, false,
0);
+         ClientSession session = cf.createSession(USERNAME, "secret", false, true, true,
false, 0);
          ClientProducer producer = session.createProducer(goodQueue);
          producer.send(session.createMessage(true));
          Assert.fail("Producing here should fail due to the original security data.");
@@ -475,7 +480,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
       { // add permissions for new destination
          DirContext ctx = getContext();
          BasicAttributes basicAttributes = new BasicAttributes();
-         basicAttributes.put("uniquemember", "cn=role3");
+         basicAttributes.put("uniquemember", "cn=" + ROLE);
          Attribute objclass = new BasicAttribute("objectclass");
          objclass.add("top");
          objclass.add("groupOfUniqueNames");
@@ -485,7 +490,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
       server.createQueue(new QueueConfiguration(goodQueue).setRoutingType(RoutingType.ANYCAST).setDurable(false));
 
-      ClientSession session = cf.createSession("third", "secret", false, true, true, false,
0);
+      ClientSession session = cf.createSession(USERNAME, "secret", false, true, true, false,
0);
       ClientProducer producer = session.createProducer(goodQueue);
       producer.send(session.createMessage(true));
       session.close();
@@ -495,7 +500,7 @@ public class LegacyLDAPSecuritySettingPluginListenerTest extends AbstractLdapTes
 
       // authorization for sending should fail for the new queue
       try {
-         session = cf.createSession("third", "secret", false, true, true, false, 0);
+         session = cf.createSession(USERNAME, "secret", false, true, true, false, 0);
          producer = session.createProducer(badQueue);
          producer.send(session.createMessage(true));
          Assert.fail("Producing here should fail.");


Mime
View raw message