diff --git a/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt b/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt index 037068326d..6995761dde 100644 --- a/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt +++ b/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt @@ -12,7 +12,9 @@ package net.corda.bridge import net.corda.bridge.services.api.BridgeMode import net.corda.core.identity.CordaX500Name +import net.corda.core.internal.div import net.corda.core.utilities.NetworkHostAndPort +import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyVersion import net.corda.testing.core.SerializationEnvironmentRule import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -20,6 +22,7 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import java.nio.file.Paths +import kotlin.test.assertFailsWith class ConfigTest { @Rule @@ -104,4 +107,27 @@ class ConfigTest { assertEquals("tunneltrustpassword", config.floatOuterConfig!!.customSSLConfiguration!!.trustStorePassword) assertNull(config.floatInnerConfig) } + + @Test + fun `Load config withsocks support`() { + val configResource = "/net/corda/bridge/withsocks/bridge.conf" + val config = createAndLoadConfigFromResource(tempFolder.root.toPath(), configResource) + assertEquals(SocksProxyVersion.SOCKS5, config.outboundConfig!!.socksProxyConfig!!.version) + assertEquals(NetworkHostAndPort("localhost", 12345), config.outboundConfig!!.socksProxyConfig!!.proxyAddress) + assertEquals("proxyUser", config.outboundConfig!!.socksProxyConfig!!.userName) + assertEquals("pwd", config.outboundConfig!!.socksProxyConfig!!.password) + val badConfigResource4 = "/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf" + assertFailsWith { + createAndLoadConfigFromResource(tempFolder.root.toPath() / "4", badConfigResource4) + } + val badConfigResource5 = "/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf" + assertFailsWith { + createAndLoadConfigFromResource(tempFolder.root.toPath() / "5", badConfigResource5) + } + val badConfigResource = "/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf" + assertFailsWith { + createAndLoadConfigFromResource(tempFolder.root.toPath() / "bad", badConfigResource) + } + + } } \ No newline at end of file diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf new file mode 100644 index 0000000000..44b905f655 --- /dev/null +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf @@ -0,0 +1,23 @@ +// +// R3 Proprietary and Confidential +// +// Copyright (c) 2018 R3 Limited. All rights reserved. +// +// The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. +// +// Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. + +bridgeMode = SenderReceiver +outboundConfig : { + artemisBrokerAddress = "localhost:11005" + socksProxyConfig : { + version = 4 + proxyAddress = "localhost:12345" + userName = "proxyUser" + password = "pwd" + } +} +inboundConfig : { + listeningAddress = "0.0.0.0:10005" +} +networkParametersPath = network-parameters diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf new file mode 100644 index 0000000000..6b06755651 --- /dev/null +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf @@ -0,0 +1,23 @@ +// +// R3 Proprietary and Confidential +// +// Copyright (c) 2018 R3 Limited. All rights reserved. +// +// The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. +// +// Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. + +bridgeMode = SenderReceiver +outboundConfig : { + artemisBrokerAddress = "localhost:11005" + socksProxyConfig : { + version = 5 + proxyAddress = "localhost:12345" + userName = "proxyUser" + password = "pwd" + } +} +inboundConfig : { + listeningAddress = "0.0.0.0:10005" +} +networkParametersPath = network-parameters diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf new file mode 100644 index 0000000000..3386bc109e --- /dev/null +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf @@ -0,0 +1,23 @@ +// +// R3 Proprietary and Confidential +// +// Copyright (c) 2018 R3 Limited. All rights reserved. +// +// The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. +// +// Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. + +bridgeMode = SenderReceiver +outboundConfig : { + artemisBrokerAddress = "localhost:11005" + socksProxyConfig : { + version = SOCKS4 + proxyAddress = "localhost:12345" + userName = "proxyUser" + password = "pwd" + } +} +inboundConfig : { + listeningAddress = "0.0.0.0:10005" +} +networkParametersPath = network-parameters diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/bridge.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/bridge.conf new file mode 100644 index 0000000000..b4f38dfa8f --- /dev/null +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/bridge.conf @@ -0,0 +1,23 @@ +// +// R3 Proprietary and Confidential +// +// Copyright (c) 2018 R3 Limited. All rights reserved. +// +// The intellectual and technical concepts contained herein are proprietary to R3 and its suppliers and are protected by trade secret law. +// +// Distribution of this file or any portion thereof via any medium without the express permission of R3 is strictly prohibited. + +bridgeMode = SenderReceiver +outboundConfig : { + artemisBrokerAddress = "localhost:11005" + socksProxyConfig : { + version = SOCKS5 + proxyAddress = "localhost:12345" + userName = "proxyUser" + password = "pwd" + } +} +inboundConfig : { + listeningAddress = "0.0.0.0:10005" +} +networkParametersPath = network-parameters