mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
address PR issues
This commit is contained in:
parent
df74024b22
commit
db2840c76a
@ -1,24 +1,32 @@
|
|||||||
package com.r3.corda.doorman
|
package com.r3.corda.doorman
|
||||||
|
|
||||||
|
import com.typesafe.config.ConfigException
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertFailsWith
|
||||||
|
|
||||||
class DoormanParametersTest {
|
class DoormanParametersTest {
|
||||||
|
|
||||||
private val testDummyPath = ".${File.separator}testDummyPath.jks"
|
private val testDummyPath = ".${File.separator}testDummyPath.jks"
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `parse arg correctly`() {
|
fun `parse arg correctly`() {
|
||||||
val ref = javaClass.getResource("/reference.conf")
|
val ref = javaClass.getResource("/node.conf")
|
||||||
val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", ref.path))
|
val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", ref.path))
|
||||||
assertEquals(DoormanParameters.Mode.CA_KEYGEN, params.mode)
|
assertEquals(DoormanParameters.Mode.CA_KEYGEN, params.mode)
|
||||||
assertEquals(testDummyPath, params.keystorePath.toString())
|
assertEquals(testDummyPath, params.keystorePath.toString())
|
||||||
assertEquals(0, params.port)
|
assertEquals(8080, params.port)
|
||||||
|
|
||||||
val params2 = DoormanParameters(arrayOf("--keystorePath", testDummyPath, "--port", "1000"))
|
val params2 = DoormanParameters(arrayOf("--keystorePath", testDummyPath, "--port", "1000"))
|
||||||
assertEquals(DoormanParameters.Mode.DOORMAN, params2.mode)
|
assertEquals(DoormanParameters.Mode.DOORMAN, params2.mode)
|
||||||
assertEquals(testDummyPath, params2.keystorePath.toString())
|
assertEquals(testDummyPath, params2.keystorePath.toString())
|
||||||
assertEquals(1000, params2.port)
|
assertEquals(1000, params2.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should fail when config missing`() {
|
||||||
|
// dataSourceProperties is missing from node_fail.conf and it should fail when accessed, and shouldn't use default from reference.conf.
|
||||||
|
val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", javaClass.getResource("/node_fail.conf").path))
|
||||||
|
assertFailsWith<ConfigException.Missing> { params.dataSourceProperties }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
13
doorman/src/test/resources/node.conf
Normal file
13
doorman/src/test/resources/node.conf
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
keystorePath = "/opt/doorman/certificates/caKeystore.jks"
|
||||||
|
keyStorePassword = "password"
|
||||||
|
caPrivateKeyPassword = "password"
|
||||||
|
host = "localhost"
|
||||||
|
port = 8080
|
||||||
|
h2port = 0
|
||||||
|
|
||||||
|
dataSourceProperties {
|
||||||
|
"dataSourceClassName" = org.h2.jdbcx.JdbcDataSource
|
||||||
|
"dataSource.url" = "jdbc:h2:file:"${basedir}"/persistence;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;WRITE_DELAY=0;AUTO_SERVER_PORT="${h2port}
|
||||||
|
"dataSource.user" = sa
|
||||||
|
"dataSource.password" = ""
|
||||||
|
}
|
6
doorman/src/test/resources/node_fail.conf
Normal file
6
doorman/src/test/resources/node_fail.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
keystorePath = "/opt/doorman/certificates/caKeystore.jks"
|
||||||
|
keyStorePassword = "password"
|
||||||
|
caPrivateKeyPassword = "password"
|
||||||
|
host = "localhost"
|
||||||
|
port = 8080
|
||||||
|
h2port = 0
|
Loading…
Reference in New Issue
Block a user