mirror of
https://github.com/corda/corda.git
synced 2024-12-29 01:08:57 +00:00
[ENT-1552] Delete temporary truststore once the test is complete. (#484)
This commit is contained in:
parent
60c44a0358
commit
26c388003c
@ -5,15 +5,29 @@ import net.corda.core.internal.div
|
|||||||
import net.corda.nodeapi.internal.crypto.X509KeyStore
|
import net.corda.nodeapi.internal.crypto.X509KeyStore
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||||
|
import org.junit.BeforeClass
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.slf4j.event.Level
|
import org.slf4j.event.Level
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
|
|
||||||
class ArgsParserTest {
|
class ArgsParserTest {
|
||||||
private val parser = ArgsParser()
|
private val parser = ArgsParser()
|
||||||
private val workingDirectory = Paths.get(".").normalize().toAbsolutePath()
|
|
||||||
|
companion object {
|
||||||
|
private lateinit var workingDirectory: Path
|
||||||
|
private lateinit var buildDirectory: Path
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
@JvmStatic
|
||||||
|
fun initDirectories() {
|
||||||
|
workingDirectory = Paths.get(".").normalize().toAbsolutePath()
|
||||||
|
buildDirectory = workingDirectory.resolve("build")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `no command line arguments`() {
|
fun `no command line arguments`() {
|
||||||
@ -113,17 +127,21 @@ class ArgsParserTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `initial-registration`() {
|
fun `initial-registration`() {
|
||||||
val truststorePath = workingDirectory / "truststore" / "file.jks"
|
// Create this temporary file in the "build" directory so that "clean" can delete it.
|
||||||
|
val truststorePath = buildDirectory / "truststore" / "file.jks"
|
||||||
assertThatExceptionOfType(IllegalArgumentException::class.java).isThrownBy {
|
assertThatExceptionOfType(IllegalArgumentException::class.java).isThrownBy {
|
||||||
parser.parse("--initial-registration", "--network-root-truststore", "$truststorePath", "--network-root-truststore-password", "password-test")
|
parser.parse("--initial-registration", "--network-root-truststore", "$truststorePath", "--network-root-truststore-password", "password-test")
|
||||||
}.withMessageContaining("Network root trust store path").withMessageContaining("doesn't exist")
|
}.withMessageContaining("Network root trust store path").withMessageContaining("doesn't exist")
|
||||||
|
|
||||||
X509KeyStore.fromFile(truststorePath, "dummy_password", createNew = true)
|
X509KeyStore.fromFile(truststorePath, "dummy_password", createNew = true)
|
||||||
|
try {
|
||||||
val cmdLineOptions = parser.parse("--initial-registration", "--network-root-truststore", "$truststorePath", "--network-root-truststore-password", "password-test")
|
val cmdLineOptions = parser.parse("--initial-registration", "--network-root-truststore", "$truststorePath", "--network-root-truststore-password", "password-test")
|
||||||
assertNotNull(cmdLineOptions.nodeRegistrationConfig)
|
assertNotNull(cmdLineOptions.nodeRegistrationConfig)
|
||||||
assertEquals(truststorePath.toAbsolutePath(), cmdLineOptions.nodeRegistrationConfig?.networkRootTrustStorePath)
|
assertEquals(truststorePath.toAbsolutePath(), cmdLineOptions.nodeRegistrationConfig?.networkRootTrustStorePath)
|
||||||
assertEquals("password-test", cmdLineOptions.nodeRegistrationConfig?.networkRootTrustStorePassword)
|
assertEquals("password-test", cmdLineOptions.nodeRegistrationConfig?.networkRootTrustStorePassword)
|
||||||
|
} finally {
|
||||||
|
Files.delete(truststorePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user