Add ldap auth unit test

This commit is contained in:
Hadrian Zbarcea 2014-08-17 11:15:56 -04:00
parent b1bc593931
commit bf5305e2ee
2 changed files with 49 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.MessageConsumer; import javax.jms.MessageConsumer;
@ -74,7 +75,7 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit {
Connection conn = factory.createQueueConnection("jdoe", "sunflower"); Connection conn = factory.createQueueConnection("jdoe", "sunflower");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start(); conn.start();
Queue queue = sess.createQueue("TEST.FOO"); Destination queue = sess.createQueue("TEST.FOO");
MessageProducer producer = sess.createProducer(queue); MessageProducer producer = sess.createProducer(queue);
MessageConsumer consumer = sess.createConsumer(queue); MessageConsumer consumer = sess.createConsumer(queue);
@ -84,6 +85,22 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit {
assertNotNull(msg); assertNotNull(msg);
} }
@Test
public void testSendTopic() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection conn = factory.createQueueConnection("jdoe", "sunflower");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
Destination topic = sess.createTopic("TEST.BAR");
MessageProducer producer = sess.createProducer(topic);
MessageConsumer consumer = sess.createConsumer(topic);
producer.send(sess.createTextMessage("test"));
Message msg = consumer.receive(1000);
assertNotNull(msg);
}
@Test @Test
public void testSendDenied() throws Exception { public void testSendDenied() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");

View File

@ -146,6 +146,35 @@ objectClass: top
member: cn=users member: cn=users
member: cn=admins member: cn=admins
## TEST.BAR
dn: cn=TEST.BAR,ou=Topic,ou=Destination,ou=ActiveMQ,ou=system
cn: TEST.BAR
description: A topic
objectClass: applicationProcess
objectClass: top
dn: cn=admin,cn=TEST.BAR,ou=Topic,ou=Destination,ou=ActiveMQ,ou=system
cn: admin
description: Admin privilege group, members are roles
member: cn=admins
member: cn=users
objectClass: groupOfNames
objectClass: top
dn: cn=read,cn=TEST.BAR,ou=Topic,ou=Destination,ou=ActiveMQ,ou=system
cn: read
member: cn=users
member: cn=admins
objectClass: groupOfNames
objectClass: top
dn: cn=write,cn=TEST.BAR,ou=Topic,ou=Destination,ou=ActiveMQ,ou=system
cn: write
objectClass: groupOfNames
objectClass: top
member: cn=users
member: cn=admins
####################### #######################
@ -208,4 +237,5 @@ cn: admin
member: cn=admins member: cn=admins
member: cn=users member: cn=users
objectClass: groupOfNames objectClass: groupOfNames
objectClass: top objectClass: top