Search in sources :

Example 51 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class ConnectionTest method connectionSecure.

@Test
@SpecificationTest(section = "1.4.2.3", description = "security challenge data")
public void connectionSecure() 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(), getBrokerAdmin().getValidPassword()).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 ConnectionSecureBody secure = interaction.connection().startOkMechanism(PLAIN).startOk().consumeResponse().getLatestResponse(ConnectionSecureBody.class);
        assertThat(secure.getChallenge(), is(anyOf(nullValue(), equalTo(new byte[0]))));
        final ConnectionTuneBody tune = interaction.connection().secureOk(initialResponse).consumeResponse().getLatestResponse(ConnectionTuneBody.class);
        interaction.connection().tuneOkChannelMax(tune.getChannelMax()).tuneOkFrameMax(tune.getFrameMax()).tuneOk().connection().open().consumeResponse(ConnectionOpenOkBody.class);
    }
}
Also used : ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) Matchers.containsString(org.hamcrest.Matchers.containsString) ConnectionSecureBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionSecureBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 52 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport 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"));
    }
}
Also used : ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 53 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class QueueTest method queueDeclareServerAssignedName.

@Test
@SpecificationTest(section = "1.7.2.1", description = "The queue name MAY be empty, in which case the server MUST create a new queue with a unique " + "generated name and return this to the client in the Declare-Ok method.")
public void queueDeclareServerAssignedName() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        QueueDeclareOkBody response = interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        String serverAssignedQueueName = response.getQueue().toString();
        assertThat(serverAssignedQueueName, is(not(emptyString())));
        QueueDeclareOkBody passive = interaction.queue().declareName(serverAssignedQueueName).declarePassive(true).declare().consumeResponse().getLatestResponse(QueueDeclareOkBody.class);
        assertThat(passive.getQueue(), is(equalTo(AMQShortString.valueOf(serverAssignedQueueName))));
    }
}
Also used : QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 54 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class QueueTest method queueUnbind.

@Test
@SpecificationTest(section = "1.7.2.5", description = "unbind a queue from an exchange")
public void queueUnbind() throws Exception {
    getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        String testExchange = "testExchange";
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey("rk1").bind().consumeResponse(QueueBindOkBody.class).queue().unbindName(testExchange).unbindQueueName(BrokerAdmin.TEST_QUEUE_NAME).unbindRoutingKey("rk1").unbind().consumeResponse(QueueUnbindOkBody.class);
    }
}
Also used : Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 55 with org.apache.qpid.server.protocol.v0_8.transport

use of org.apache.qpid.server.protocol.v0_8.transport in project qpid-broker-j by apache.

the class QueueTest method queueUnbindDefaultQueue.

@Test
@SpecificationTest(section = "1.7.2.5", description = "The client MUST either specify a queue name or have previously declared a queue on the " + "same channel")
public void queueUnbindDefaultQueue() throws Exception {
    try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
        final Interaction interaction = transport.newInteraction();
        String testExchange = "testExchange";
        interaction.negotiateOpen().channel().open().consumeResponse(ChannelOpenOkBody.class).queue().declareName(BrokerAdmin.TEST_QUEUE_NAME).declare().consumeResponse(QueueDeclareOkBody.class).exchange().declareName(testExchange).declare().consumeResponse(ExchangeDeclareOkBody.class).queue().bindName(testExchange).bindQueueName(BrokerAdmin.TEST_QUEUE_NAME).bindRoutingKey("rk1").bind().consumeResponse(QueueBindOkBody.class).queue().unbindName(testExchange).unbindRoutingKey("rk1").unbind().consumeResponse(QueueUnbindOkBody.class);
    }
}
Also used : QueueBindOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueBindOkBody) ExchangeDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody) Matchers.emptyString(org.hamcrest.Matchers.emptyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) QueueDeclareOkBody(org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Test (org.junit.Test)88 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)72 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)44 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)32 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)21 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)20 Matchers.emptyString (org.hamcrest.Matchers.emptyString)18 ChannelCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody)17 QueueDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.QueueDeclareOkBody)15 ConnectionCloseBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody)13 ConnectionTuneBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody)12 ExchangeBoundOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeBoundOkBody)11 ExchangeDeclareOkBody (org.apache.qpid.server.protocol.v0_8.transport.ExchangeDeclareOkBody)11 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)9 BasicConsumeOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody)8 BasicDeliverBody (org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody)8 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)8 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)7 ConnectionStartBody (org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody)7 BasicQosOkBody (org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody)6