use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ConnectionTest method connectionSecureUnsuccessfulAuthentication.
@Test
@SpecificationTest(section = "1.4.2.3", description = "security challenge data")
public void connectionSecureUnsuccessfulAuthentication() throws Exception {
assumeThat(getBrokerAdmin().isSASLMechanismSupported(PLAIN), is(true));
try (FrameTransport transport = new FrameTransport(getBrokerAdmin(), BrokerAdmin.PortType.AMQP).connect()) {
final byte[] initialResponse = String.format("\0%s\0%s", getBrokerAdmin().getValidUsername(), "badpassword").getBytes(StandardCharsets.US_ASCII);
final Interaction interaction = transport.newInteraction();
final ConnectionStartBody start = interaction.negotiateProtocol().consumeResponse().getLatestResponse(ConnectionStartBody.class);
assertThat(Arrays.asList(new String(start.getMechanisms()).split(" ")), hasItem(PLAIN));
final ConnectionCloseBody close = interaction.connection().startOkMechanism(PLAIN).startOk().consumeResponse(ConnectionSecureBody.class).connection().secureOk(initialResponse).consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(close.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
assertThat(String.valueOf(close.getReplyText()).toLowerCase(), containsString("authentication failed"));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class TransactionTimeoutTest method publishTransactionTimeout.
@Test
public void publishTransactionTimeout() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().contentHeaderPropertiesContentType("text/plain").contentHeaderPropertiesHeaders(Collections.singletonMap("test", "testValue")).contentHeaderPropertiesDeliveryMode((byte) 1).contentHeaderPropertiesPriority((byte) 1).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().exchange().declarePassive(true).declare().consumeResponse(ExchangeDeclareOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
final ConnectionCloseBody close = interaction.consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(close.getReplyCode(), is(equalTo(ErrorCodes.RESOURCE_ERROR)));
assertThat(close.getReplyText().toString(), containsString("transaction timed out"));
interaction.connection().closeOk();
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeDeclareInvalidWireArguments.
@Test
public void exchangeDeclareInvalidWireArguments() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ConnectionCloseBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(TEST_EXCHANGE).declareArguments(Collections.singletonMap("foo", "bar")).declare().consumeResponse(ConnectionCloseBody.class).getLatestResponse(ConnectionCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.INVALID_ARGUMENT)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ExchangeTest method exchangeUnsupportedExchangeType.
@Test
@SpecificationTest(section = "1.6.2.1", description = "The client MUST NOT attempt to declare an exchange with a type that the server does not " + "support.")
public void exchangeUnsupportedExchangeType() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse(ExchangeDeclareOkBody.class);
ConnectionCloseBody response = interaction.exchange().declarePassive(true).declareType(ExchangeDefaults.TOPIC_EXCHANGE_CLASS).declareName(TEST_EXCHANGE).declare().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
assertThat(response.getReplyCode(), is(equalTo(ErrorCodes.NOT_ALLOWED)));
}
}
use of org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody in project qpid-broker-j by apache.
the class ConnectionTest method connectionOpenUnknownVirtualHost.
@Test
@SpecificationTest(section = "1.4.2.7", description = "The client tried to work with an unknown virtual host.")
public void connectionOpenUnknownVirtualHost() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
ConnectionTuneBody tune = interaction.authenticateConnection().getLatestResponse(ConnectionTuneBody.class);
ConnectionCloseBody close = interaction.connection().tuneOkChannelMax(tune.getChannelMax()).tuneOkFrameMax(tune.getFrameMax()).tuneOkHeartbeat(tune.getHeartbeat()).tuneOk().connection().openVirtualHost("unknown-virtualhost").open().consumeResponse().getLatestResponse(ConnectionCloseBody.class);
// Spec requires INVALID_PATH, but implementation uses NOT_FOUND
assertThat(close.getReplyCode(), is(anyOf(equalTo(ErrorCodes.NOT_FOUND), equalTo(ErrorCodes.INVALID_PATH))));
assertThat(String.valueOf(close.getReplyText()).toLowerCase(), containsString("unknown virtual host"));
}
}
Aggregations