use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.
the class HttpTestBase method setUpTestBase.
@Before
public void setUpTestBase() throws Exception {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
HttpRequestConfig config = getHttpRequestConfig();
_helper = new HttpTestHelper(getBrokerAdmin(), config != null && config.useVirtualHostAsHost() ? getVirtualHost() : null);
Protocol protocol = getProtocol();
AmqpManagementFacade managementFacade = new AmqpManagementFacade(protocol);
if (protocol == Protocol.AMQP_1_0) {
_jmsProvider = new QpidJmsClientProvider(managementFacade);
} else {
_jmsProvider = new QpidJmsClient0xProvider();
}
}
use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.
the class QpidBrokerTestCase method runBare.
@Override
public void runBare() throws Throwable {
try {
_managementFacade = new AmqpManagementFacade(BROKER_PROTOCOL);
_jmsProvider = isBroker10() ? new QpidJmsClientProvider(_managementFacade) : new QpidJmsClient0xProvider();
_defaultBroker = new BrokerHolderFactory().create(DEFAULT_BROKER_TYPE, DEFAULT_PORT, this);
super.runBare();
} catch (Exception e) {
LOGGER.error("exception", e);
throw e;
} finally {
stopAllBrokers();
// reset properties used in the test
revertSystemProperties();
LOGGER.info("========== stop " + getTestName() + " ==========");
}
}
use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.
the class AmqpManagementTest method testInvokeSecureOperation.
@Test
public void testInvokeSecureOperation() throws Exception {
assumeThat(isSupportedClient(), is(true));
// // a secure operation
String secureOperation = "publishMessage";
Map<String, String> operationArg = new HashMap<>();
operationArg.put("address", ExchangeDefaults.FANOUT_EXCHANGE_NAME);
operationArg.put("content", "Hello, world!");
Connection unsecuredConnection = getConnection();
try {
setUp(unsecuredConnection);
MapMessage plainRequest = _session.createMapMessage();
plainRequest.setStringProperty("type", "org.apache.qpid.VirtualHost");
plainRequest.setStringProperty("operation", secureOperation);
plainRequest.setStringProperty("index", "object-path");
plainRequest.setStringProperty("key", "");
plainRequest.setStringProperty("message", new ObjectMapper().writeValueAsString(operationArg));
plainRequest.setJMSReplyTo(_replyAddress);
_producer.send(plainRequest);
Message responseMessage = _consumer.receive(getReceiveTimeout());
assertResponseCode(responseMessage, 403);
} finally {
unsecuredConnection.close();
}
int tlsPort = TlsTest.createTlsPort(getTestName() + "TlsPort", false, false, false, getConnectionBuilder(), new AmqpManagementFacade(getProtocol()), getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP).getPort());
Connection connection = getConnectionBuilder().setTls(true).setSslPort(tlsPort).setTrustStoreLocation(TRUSTSTORE).setTrustStorePassword(TRUSTSTORE_PASSWORD).build();
try {
setUp(connection);
MapMessage secureRequest = _session.createMapMessage();
secureRequest.setStringProperty("type", "org.apache.qpid.VirtualHost");
secureRequest.setStringProperty("operation", secureOperation);
secureRequest.setStringProperty("index", "object-path");
secureRequest.setStringProperty("key", "");
secureRequest.setStringProperty("message", new ObjectMapper().writeValueAsString(operationArg));
secureRequest.setJMSReplyTo(_replyAddress);
_producer.send(secureRequest);
Message responseMessage = _consumer.receive(getReceiveTimeout());
assertResponseCode(responseMessage, 200);
} finally {
connection.close();
}
}
Aggregations