You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/02/12 16:11:47 UTC
[2/3] qpid-broker-j git commit: QPID-8038: [Broker-J] Add
authentication timeout protocol tests
QPID-8038: [Broker-J] Add authentication timeout protocol tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/cc8b3c0b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/cc8b3c0b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/cc8b3c0b
Branch: refs/heads/master
Commit: cc8b3c0bffdcc45086a35ef5e4a129969a791ae7
Parents: fa2b1ff
Author: Keith Wall <kw...@apache.org>
Authored: Fri Feb 9 17:08:06 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Mon Feb 12 13:55:30 2018 +0000
----------------------------------------------------------------------
.../authtimeout/AuthenticationTimeoutTest.java | 55 ++++++
.../TransactionTimeoutTest.java | 171 -------------------
.../authtimeout/AuthenticationTimeoutTest.java | 68 ++++++++
.../qpid/SaslAuthenticationTimeoutTest.java | 78 +++++++++
4 files changed, 201 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cc8b3c0b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/authtimeout/AuthenticationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/authtimeout/AuthenticationTimeoutTest.java b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/authtimeout/AuthenticationTimeoutTest.java
new file mode 100644
index 0000000..cc9d8d6
--- /dev/null
+++ b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/authtimeout/AuthenticationTimeoutTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.tests.protocol.v0_10.extensions.authtimeout;
+
+import static org.junit.Assert.assertThat;
+
+import java.net.InetSocketAddress;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart;
+import org.apache.qpid.tests.protocol.v0_10.FrameTransport;
+import org.apache.qpid.tests.protocol.v0_10.Interaction;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@ConfigItem(name = Port.CONNECTION_MAXIMUM_AUTHENTICATION_DELAY, value = "500")
+public class AuthenticationTimeoutTest extends BrokerAdminUsingTestBase
+{
+ @Test
+ public void authenticationTimeout() throws Exception
+ {
+ InetSocketAddress brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
+ try(FrameTransport transport = new FrameTransport(brokerAddress).connect())
+ {
+ final Interaction interaction = transport.newInteraction();
+ final ConnectionStart start = interaction.negotiateProtocol()
+ .consumeResponse()
+ .consumeResponse()
+ .getLatestResponse(ConnectionStart.class);
+ assertThat(start.getMechanisms(), CoreMatchers.hasItem("PLAIN"));
+ transport.assertNoMoreResponsesAndChannelClosed();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cc8b3c0b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extentions/transactiontimeout/TransactionTimeoutTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extentions/transactiontimeout/TransactionTimeoutTest.java b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extentions/transactiontimeout/TransactionTimeoutTest.java
deleted file mode 100644
index ce2c320..0000000
--- a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extentions/transactiontimeout/TransactionTimeoutTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.tests.protocol.v0_10.extentions.transactiontimeout;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.qpid.tests.utils.BrokerAdmin.KIND_BROKER_J;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import java.net.InetSocketAddress;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.qpid.server.protocol.v0_10.transport.ConnectionClose;
-import org.apache.qpid.server.protocol.v0_10.transport.ConnectionCloseCode;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageAcceptMode;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageAcquireMode;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageCreditUnit;
-import org.apache.qpid.server.protocol.v0_10.transport.MessageTransfer;
-import org.apache.qpid.server.protocol.v0_10.transport.Range;
-import org.apache.qpid.server.protocol.v0_10.transport.RangeSet;
-import org.apache.qpid.server.protocol.v0_10.transport.SessionCompleted;
-import org.apache.qpid.tests.protocol.Response;
-import org.apache.qpid.tests.protocol.v0_10.FrameTransport;
-import org.apache.qpid.tests.protocol.v0_10.Interaction;
-import org.apache.qpid.tests.utils.BrokerAdmin;
-import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-import org.apache.qpid.tests.utils.BrokerSpecific;
-import org.apache.qpid.tests.utils.ConfigItem;
-
-@BrokerSpecific(kind = KIND_BROKER_J)
-@ConfigItem(name = "virtualhost.storeTransactionOpenTimeoutClose", value = "1000")
-public class TransactionTimeoutTest extends BrokerAdminUsingTestBase
-{
- private InetSocketAddress _brokerAddress;
-
- @Before
- public void setUp()
- {
- _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
- getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
- }
-
- @Test
- public void publishTransactionTimeout() throws Exception
- {
- try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
- {
- final Interaction interaction = transport.newInteraction();
- byte[] sessionName = "test".getBytes(UTF_8);
- interaction.openAnonymousConnection()
- .channelId(1)
- .attachSession(sessionName)
- .tx().selectId(0).select()
- .message()
- .transferDestination(BrokerAdmin.TEST_QUEUE_NAME)
- .transferId(1)
- .transfer()
- .session()
- .flushCompleted()
- .flush();
-
- SessionCompleted completed;
- do
- {
- completed = interaction.consumeResponse().getLatestResponse(SessionCompleted.class);
- }
- while (!completed.getCommands().includes(1));
-
- int queueDepthMessages = getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME);
- assertThat(queueDepthMessages, is(equalTo(0)));
-
- ConnectionClose close = receiveResponse(interaction, ConnectionClose.class);
- assertThat(close.getReplyCode(), is(equalTo(ConnectionCloseCode.CONNECTION_FORCED)));
- assertThat(close.getReplyText(), containsString("transaction timed out"));
-
- assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
- }
- }
-
- @Test
- public void consumeTransactionTimeout() throws Exception
- {
- String testMessageBody = "testMessage";
- getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, testMessageBody);
- try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
- {
- final Interaction interaction = transport.newInteraction();
- byte[] sessionName = "testSession".getBytes(UTF_8);
- final String subscriberName = "testSubscriber";
- interaction.openAnonymousConnection()
- .channelId(1)
- .attachSession(sessionName)
- .tx().selectId(0).select()
- .message()
- .subscribeAcceptMode(MessageAcceptMode.EXPLICIT)
- .subscribeAcquireMode(MessageAcquireMode.PRE_ACQUIRED)
- .subscribeDestination(subscriberName)
- .subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME)
- .subscribeId(0)
- .subscribe()
- .message()
- .flowId(1)
- .flowDestination(subscriberName)
- .flowUnit(MessageCreditUnit.MESSAGE)
- .flowValue(1)
- .flow()
- .message()
- .flowId(2)
- .flowDestination(subscriberName)
- .flowUnit(MessageCreditUnit.BYTE)
- .flowValue(-1)
- .flow();
-
- MessageTransfer transfer = receiveResponse(interaction, MessageTransfer.class);
-
- assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
-
- RangeSet transfers = Range.newInstance(transfer.getId());
- interaction.message().acceptId(3).acceptTransfers(transfers).accept()
- .session()
- .flushCompleted()
- .flush();
-
- SessionCompleted completed = receiveResponse(interaction, SessionCompleted.class);
-
- assertThat(completed.getCommands(), is(notNullValue()));
- assertThat(completed.getCommands().includes(3), is(equalTo(true)));
-
- ConnectionClose close = receiveResponse(interaction, ConnectionClose.class);
- assertThat(close.getReplyCode(), is(equalTo(ConnectionCloseCode.CONNECTION_FORCED)));
- assertThat(close.getReplyText(), containsString("transaction timed out"));
- }
- }
-
- private <T> T receiveResponse(final Interaction interaction, Class<T> clazz) throws Exception
- {
- T result = null;
- do
- {
- Response<?> response = interaction.consumeResponse().getLatestResponse();
- if (clazz.isInstance(response.getBody()))
- {
- result = (T) response.getBody();
- }
- }
- while (result == null);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cc8b3c0b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/authtimeout/AuthenticationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/authtimeout/AuthenticationTimeoutTest.java b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/authtimeout/AuthenticationTimeoutTest.java
new file mode 100644
index 0000000..3e16ded
--- /dev/null
+++ b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/authtimeout/AuthenticationTimeoutTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.tests.protocol.v0_8.extension.authtimeout;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assume.assumeThat;
+
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+
+import org.junit.Test;
+
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.protocol.v0_8.transport.ConnectionSecureBody;
+import org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody;
+import org.apache.qpid.tests.protocol.v0_8.FrameTransport;
+import org.apache.qpid.tests.protocol.v0_8.Interaction;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@ConfigItem(name = Port.CONNECTION_MAXIMUM_AUTHENTICATION_DELAY, value = "500")
+public class AuthenticationTimeoutTest extends BrokerAdminUsingTestBase
+{
+ @Test
+ public void authenticationTimeout() throws Exception
+ {
+ assumeThat(getBrokerAdmin().isSASLMechanismSupported("PLAIN"), is(true));
+
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
+
+ try (FrameTransport transport = new FrameTransport(addr).connect())
+ {
+ final Interaction interaction = transport.newInteraction();
+ final ConnectionStartBody start = interaction.negotiateProtocol()
+ .consumeResponse()
+ .getLatestResponse(ConnectionStartBody.class);
+
+ assertThat(Arrays.asList(new String(start.getMechanisms()).split(" ")), hasItem("PLAIN"));
+
+ interaction.connection()
+ .startOkMechanism("PLAIN")
+ .startOk()
+ .consumeResponse(ConnectionSecureBody.class);
+
+ transport.assertNoMoreResponsesAndChannelClosed();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/cc8b3c0b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/extensions/qpid/SaslAuthenticationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/extensions/qpid/SaslAuthenticationTimeoutTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/extensions/qpid/SaslAuthenticationTimeoutTest.java
new file mode 100644
index 0000000..2867699
--- /dev/null
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/security/sasl/extensions/qpid/SaslAuthenticationTimeoutTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.tests.protocol.v1_0.transport.security.sasl.extensions.qpid;
+
+import static org.apache.qpid.tests.utils.BrokerAdmin.KIND_BROKER_J;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assume.assumeThat;
+
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
+import org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms;
+import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
+import org.apache.qpid.tests.protocol.v1_0.Interaction;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.utils.BrokerSpecific;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@BrokerSpecific(kind = KIND_BROKER_J)
+@ConfigItem(name = Port.CONNECTION_MAXIMUM_AUTHENTICATION_DELAY, value = "500")
+public class SaslAuthenticationTimeoutTest extends BrokerAdminUsingTestBase
+{
+ private static final Symbol PLAIN = Symbol.getSymbol("PLAIN");
+ private static final byte[] SASL_AMQP_HEADER_BYTES = "AMQP\3\1\0\0".getBytes(StandardCharsets.UTF_8);
+
+ @Before
+ public void setUp()
+ {
+ assumeThat(getBrokerAdmin().isSASLSupported(), is(true));
+ assumeThat(getBrokerAdmin().isSASLMechanismSupported(PLAIN.toString()), is(true));
+ }
+
+ @Test
+ public void authenticationTimeout() throws Exception
+ {
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP);
+ try (FrameTransport transport = new FrameTransport(addr, true).connect())
+ {
+ final Interaction interaction = transport.newInteraction();
+ final byte[] saslHeaderResponse = interaction.protocolHeader(SASL_AMQP_HEADER_BYTES)
+ .negotiateProtocol().consumeResponse()
+ .getLatestResponse(byte[].class);
+ assertThat(saslHeaderResponse, is(equalTo(SASL_AMQP_HEADER_BYTES)));
+
+ SaslMechanisms mechanismsResponse = interaction.consumeResponse().getLatestResponse(SaslMechanisms.class);
+ assertThat(Arrays.asList(mechanismsResponse.getSaslServerMechanisms()), hasItem(PLAIN));
+
+ transport.assertNoMoreResponsesAndChannelClosed();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org