mirror of
https://github.com/corda/corda.git
synced 2025-02-05 18:49:14 +00:00
Stop using reference.conf from corda node in doorman
This commit is contained in:
parent
d394a30471
commit
df74024b22
@ -2,17 +2,18 @@ package com.r3.corda.doorman
|
||||
|
||||
import com.r3.corda.doorman.OptionParserHelper.toConfigWithOptions
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.typesafe.config.ConfigParseOptions
|
||||
import net.corda.core.div
|
||||
import net.corda.node.services.config.ConfigHelper
|
||||
import net.corda.node.services.config.getOrElse
|
||||
import net.corda.node.services.config.getValue
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
|
||||
class DoormanParameters(args: Array<String>) {
|
||||
private val argConfig = args.toConfigWithOptions {
|
||||
accepts("basedir", "Overriding configuration filepath, default to current directory.").withRequiredArg().describedAs("filepath")
|
||||
accepts("basedir", "Overriding configuration filepath, default to current directory.").withRequiredArg().defaultsTo(".").describedAs("filepath")
|
||||
accepts("configFile", "Overriding configuration file, default to <<current directory>>/node.conf.").withRequiredArg().describedAs("filepath")
|
||||
accepts("keygen", "Generate CA keypair and certificate using provide Root CA key.").withOptionalArg()
|
||||
accepts("rootKeygen", "Generate Root CA keypair and certificate.").withOptionalArg()
|
||||
accepts("keystorePath", "CA keystore filepath, default to [basedir]/certificates/caKeystore.jks.").withRequiredArg().describedAs("filepath")
|
||||
@ -24,8 +25,9 @@ class DoormanParameters(args: Array<String>) {
|
||||
accepts("host", "Doorman web service host override").withRequiredArg().describedAs("hostname")
|
||||
accepts("port", "Doorman web service port override").withRequiredArg().ofType(Int::class.java).describedAs("port number")
|
||||
}
|
||||
private val basedir by argConfig.getOrElse { Paths.get(".") }
|
||||
private val config = argConfig.withFallback(ConfigHelper.loadConfig(basedir, allowMissingConfig = true))
|
||||
private val basedir: Path by argConfig
|
||||
private val configFile by argConfig.getOrElse { basedir / "node.conf" }
|
||||
private val config = argConfig.withFallback(ConfigFactory.parseFile(configFile.toFile(), ConfigParseOptions.defaults().setAllowMissing(true))).resolve()
|
||||
val keystorePath: Path by config.getOrElse { basedir / "certificates" / "caKeystore.jks" }
|
||||
val rootStorePath: Path by config.getOrElse { basedir / "certificates" / "rootCAKeystore.jks" }
|
||||
val keystorePassword: String? by config.getOrElse { null }
|
||||
|
@ -3,7 +3,6 @@ package com.r3.corda.doorman
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class DoormanParametersTest {
|
||||
|
||||
@ -11,7 +10,8 @@ class DoormanParametersTest {
|
||||
|
||||
@Test
|
||||
fun `parse arg correctly`() {
|
||||
val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath))
|
||||
val ref = javaClass.getResource("/reference.conf")
|
||||
val params = DoormanParameters(arrayOf("--keygen", "--keystorePath", testDummyPath, "--configFile", ref.path))
|
||||
assertEquals(DoormanParameters.Mode.CA_KEYGEN, params.mode)
|
||||
assertEquals(testDummyPath, params.keystorePath.toString())
|
||||
assertEquals(0, params.port)
|
||||
|
Loading…
x
Reference in New Issue
Block a user