Add an example config with SOCKS config and a trivial test to prove we can load it.

Address PR comment
This commit is contained in:
Matthew Nesbit 2018-04-27 12:17:49 +01:00
parent 8ce718f4bf
commit 70ca8f6d6f
5 changed files with 118 additions and 0 deletions

View File

@ -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<IllegalArgumentException> {
createAndLoadConfigFromResource(tempFolder.root.toPath() / "4", badConfigResource4)
}
val badConfigResource5 = "/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf"
assertFailsWith<IllegalArgumentException> {
createAndLoadConfigFromResource(tempFolder.root.toPath() / "5", badConfigResource5)
}
val badConfigResource = "/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf"
assertFailsWith<IllegalArgumentException> {
createAndLoadConfigFromResource(tempFolder.root.toPath() / "bad", badConfigResource)
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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