From 8bc46d9f7d4dfd98a61b960869a159650cb6673d Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Tue, 11 Sep 2018 13:02:02 +0100 Subject: [PATCH] Porting over missing CRL soft fail check unit test from ENT (#3926) --- .../net/corda/node/amqp/ProtonWrapperTests.kt | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt index d89481abb8..bc717e7109 100644 --- a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt @@ -16,13 +16,13 @@ import net.corda.nodeapi.internal.ArtemisMessagingClient import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.P2P_PREFIX import net.corda.nodeapi.internal.ArtemisTcpTransport import net.corda.nodeapi.internal.config.MutualSslConfiguration -import net.corda.nodeapi.internal.registerDevP2pCertificates -import net.corda.nodeapi.internal.crypto.* +import net.corda.nodeapi.internal.crypto.X509Utilities import net.corda.nodeapi.internal.protonwrapper.messages.MessageStatus import net.corda.nodeapi.internal.protonwrapper.netty.AMQPClient import net.corda.nodeapi.internal.protonwrapper.netty.AMQPConfiguration import net.corda.nodeapi.internal.protonwrapper.netty.AMQPServer import net.corda.nodeapi.internal.protonwrapper.netty.init +import net.corda.nodeapi.internal.registerDevP2pCertificates import net.corda.nodeapi.internal.registerDevSigningCertificates import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME @@ -89,6 +89,22 @@ class ProtonWrapperTests { } } + @Test + fun `AMPQ Client fails to connect when crl soft fail check is disabled`() { + val amqpServer = createServer(serverPort, CordaX500Name("Rogue 1", "London", "GB"), + maxMessageSize = MAX_MESSAGE_SIZE, crlCheckSoftFail = false) + amqpServer.use { + amqpServer.start() + val amqpClient = createClient() + amqpClient.use { + val clientConnected = amqpClient.onConnection.toFuture() + amqpClient.start() + val clientConnect = clientConnected.get() + assertEquals(false, clientConnect.connected) + } + } + } + @Test fun `AMPQ Client refuses to connect to unexpected server`() { val amqpServer = createServer(serverPort, CordaX500Name("Rogue 1", "London", "GB")) @@ -470,7 +486,10 @@ class ProtonWrapperTests { sharedThreadPool = sharedEventGroup) } - private fun createServer(port: Int, name: CordaX500Name = ALICE_NAME, maxMessageSize: Int = MAX_MESSAGE_SIZE): AMQPServer { + private fun createServer(port: Int, + name: CordaX500Name = ALICE_NAME, + maxMessageSize: Int = MAX_MESSAGE_SIZE, + crlCheckSoftFail: Boolean = true): AMQPServer { val baseDirectory = temporaryFolder.root.toPath() / "server" val certificatesDirectory = baseDirectory / "certificates" val signingCertificateStore = CertificateStoreStubs.Signing.withCertificatesDirectory(certificatesDirectory) @@ -481,7 +500,7 @@ class ProtonWrapperTests { doReturn(name).whenever(it).myLegalName doReturn(signingCertificateStore).whenever(it).signingCertificateStore doReturn(p2pSslConfiguration).whenever(it).p2pSslOptions - doReturn(true).whenever(it).crlCheckSoftFail + doReturn(crlCheckSoftFail).whenever(it).crlCheckSoftFail } serverConfig.configureWithDevSSLCertificate()