diff options
Diffstat (limited to 'qpid/java/systests/src/main/java/org/apache/qpid/server/security')
5 files changed, 55 insertions, 44 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java index 262051ff89..8ccf74a22b 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java @@ -18,22 +18,9 @@ */ package org.apache.qpid.server.security.acl; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.jms.Connection; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.naming.NamingException; - import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.lang.StringUtils; + import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionURL; @@ -42,6 +29,19 @@ import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.url.URLSyntaxException; +import javax.jms.Connection; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.naming.NamingException; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + /** * Abstract test case for ACLs. * diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java index 4f2464e186..50c80692dd 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExhaustiveACLTest.java @@ -18,14 +18,14 @@ */ package org.apache.qpid.server.security.acl; -import javax.jms.Connection; -import javax.jms.Session; - import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQSession; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.protocol.AMQConstant; +import javax.jms.Connection; +import javax.jms.Session; + /** * ACL version 2/3 file testing to verify that ACL entries control queue creation with specific properties. * diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java index 427d253ca5..6e4f12b9f3 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLJMXTest.java @@ -18,14 +18,14 @@ */ package org.apache.qpid.server.security.acl; -import java.lang.management.ManagementFactory; -import java.lang.management.RuntimeMXBean; - import org.apache.qpid.management.common.mbeans.ServerInformation; import org.apache.qpid.server.management.ManagedObject; import org.apache.qpid.server.security.access.ObjectType; import org.apache.qpid.test.utils.JMXTestUtils; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; + /** * Tests that access to the JMX interface is governed only by {@link ObjectType#METHOD}/{@link ObjectType#ALL} * rules and AMQP rights have no effect. diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java index e9b8a2efd5..0e45ca9493 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java @@ -18,6 +18,10 @@ */ package org.apache.qpid.server.security.acl; +import org.apache.qpid.AMQException; +import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.url.URLSyntaxException; + import javax.jms.Connection; import javax.jms.Destination; import javax.jms.JMSException; @@ -31,10 +35,6 @@ import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.naming.NamingException; -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.url.URLSyntaxException; - /** * Tests the V2 ACLs. The tests perform basic AMQP operations like creating queues or excahnges and publishing and consuming messages, using * JMS to contact the broker. diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java index 044a0af335..f5adf815aa 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java @@ -18,20 +18,22 @@ */ package org.apache.qpid.server.security.firewall; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import org.apache.qpid.client.AMQConnectionURL; +import org.apache.qpid.test.utils.QpidBrokerTestCase; import javax.jms.Connection; import javax.jms.JMSException; - -import org.apache.qpid.client.AMQConnectionURL; -import org.apache.qpid.test.utils.QpidBrokerTestCase; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; public class FirewallConfigTest extends QpidBrokerTestCase { private File _tmpConfig, _tmpVirtualhosts; - + private String _ipAddressOfBrokerHost; + @Override protected void setUp() throws Exception { @@ -47,12 +49,13 @@ public class FirewallConfigTest extends QpidBrokerTestCase _tmpVirtualhosts = File.createTempFile("virtualhosts-systests-firewall", ".xml"); setSystemProperty("QPID_FIREWALL_VIRTUALHOSTS_SETTINGS", _tmpVirtualhosts.getAbsolutePath()); _tmpVirtualhosts.deleteOnExit(); + + _ipAddressOfBrokerHost = getIpAddressOfBrokerHost(); } private void writeFirewallFile(boolean allow, boolean inVhost) throws IOException { FileWriter out = new FileWriter(inVhost ? _tmpVirtualhosts : _tmpConfig); - String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ? if (inVhost) { out.write("<virtualhosts><virtualhost><test>"); @@ -62,7 +65,7 @@ public class FirewallConfigTest extends QpidBrokerTestCase out.write("<broker>"); } out.write("<security><firewall>"); - out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>"); + out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\"" + _ipAddressOfBrokerHost + "\"/>"); out.write("</firewall></security>"); if (inVhost) { @@ -81,26 +84,23 @@ public class FirewallConfigTest extends QpidBrokerTestCase _configFile = new File("build/etc/config-systests-firewall-2.xml"); super.setUp(); - - Connection conn = null; try { //Try to get a connection to the 'test2' vhost //This is expected to succeed as it is allowed at the vhost level - conn = getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'")); + getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'")); } catch (JMSException e) { e.getLinkedException().printStackTrace(); fail("The connection was expected to succeed: " + e.getMessage()); } - - conn = null; + try { //Try to get a connection to the 'test' vhost //This is expected to fail as it is denied at the broker level - conn = getConnection(); + getConnection(); fail("We expected the connection to fail"); } catch (JMSException e) @@ -114,13 +114,11 @@ public class FirewallConfigTest extends QpidBrokerTestCase _configFile = new File("build/etc/config-systests-firewall-3.xml"); super.setUp(); - - Connection conn = null; try { //Try to get a connection to the 'test2' vhost //This is expected to fail as it is denied at the vhost level - conn = getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'")); + getConnection(new AMQConnectionURL("amqp://guest:guest@clientid/test2?brokerlist='" + getBroker() + "'")); fail("The connection was expected to fail"); } catch (JMSException e) @@ -128,12 +126,11 @@ public class FirewallConfigTest extends QpidBrokerTestCase //ignore } - conn = null; try { //Try to get a connection to the 'test' vhost //This is expected to succeed as it is allowed at the broker level - conn = getConnection(); + getConnection(); } catch (JMSException e) { @@ -269,4 +266,18 @@ public class FirewallConfigTest extends QpidBrokerTestCase assertEquals("Second connection check failed", !initial, checkConnection()); } + + private String getIpAddressOfBrokerHost() + { + String brokerHost = getBroker().getHost(); + try + { + return InetAddress.getByName(brokerHost).getHostAddress(); + } + catch (UnknownHostException e) + { + throw new RuntimeException("Could not determine IP address of host : " + brokerHost, e); + } + + } } |