out.write("\t<rule access=\"deny\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
// Load config
ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
ApplicationRegistry.initialise(reg, 1);
// Test config
TestNetworkDriver testDriver = new TestNetworkDriver();
testDriver.setRemoteAddress("127.0.0.1");
VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
AMQProtocolSession session = new AMQProtocolEngine(virtualHostRegistry, testDriver);
assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost));
RandomAccessFile fileBRandom = new RandomAccessFile(fileB, "rw");
fileBRandom.setLength(0);
fileBRandom.seek(0);
fileBRandom.close();
out = new FileWriter(fileB);
out.write("<firewall>\n");
out.write("\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
reg.getConfiguration().reparseConfigFileSecuritySections();
assertTrue(reg.getAccessManager().authoriseConnect(session, virtualHost));
fileBRandom = new RandomAccessFile(fileB, "rw");
fileBRandom.setLength(0);
fileBRandom.seek(0);
fileBRandom.close();
out = new FileWriter(fileB);
out.write("<firewall>\n");
out.write("\t<rule access=\"deny\" network=\"127.0.0.1\"/>");
out.write("</firewall>\n");
out.close();
reg.getConfiguration().reparseConfigFileSecuritySections();
assertFalse(reg.getAccessManager().authoriseConnect(session, virtualHost));
}