From 158993edb182a6eb6ca3ef61e64e664d833e7de5 Mon Sep 17 00:00:00 2001 From: Katarzyna Streich Date: Thu, 14 Dec 2017 11:25:02 +0000 Subject: [PATCH] Fix broken doorman tests after OS -> ENT merge --- .../doorman/DoormanIntegrationTest.kt | 22 +++++++++++-------- .../hsm/SigningServiceIntegrationTest.kt | 15 +++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt index d82e21e25a..368e5337ed 100644 --- a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt +++ b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt @@ -12,6 +12,7 @@ import net.corda.core.crypto.sign import net.corda.core.identity.CordaX500Name import net.corda.core.identity.PartyAndCertificate import net.corda.core.internal.cert +import net.corda.core.internal.createDirectories import net.corda.core.node.NodeInfo import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort @@ -26,7 +27,6 @@ import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.testNodeConfiguration import org.bouncycastle.cert.X509CertificateHolder -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -44,8 +44,6 @@ class DoormanIntegrationTest { @JvmField val testSerialization = SerializationEnvironmentRule(true) - // TODO: fix me (see commented out code in this test) - @Ignore @Test fun `initial registration`() { val rootCertAndKey = createDoormanRootCertificateAndKeyPair() @@ -62,8 +60,12 @@ class DoormanIntegrationTest { whenever(it.compatibilityZoneURL).thenReturn(URL("http://${doormanHostAndPort.host}:${doormanHostAndPort.port}")) whenever(it.emailAddress).thenReturn("iTest@R3.com") } -// config.rootCaCertFile.parent.createDirectories() -// X509Utilities.saveCertificateAsPEMFile(rootCertAndKey.certificate.toX509Certificate(), config.rootCaCertFile) + + config.trustStoreFile.parent.createDirectories() + loadOrCreateKeyStore(config.trustStoreFile, config.trustStorePassword).also { + it.addOrReplaceCertificate(X509Utilities.CORDA_ROOT_CA, rootCertAndKey.certificate.cert) + it.save(config.trustStoreFile, config.trustStorePassword) + } NetworkRegistrationHelper(config, HTTPNetworkRegistrationService(config.compatibilityZoneURL!!)).buildKeystore() @@ -95,8 +97,6 @@ class DoormanIntegrationTest { doorman.close() } - // TODO: fix me (see commented out code in this test) - @Ignore @Test fun `nodeInfo is published to the network map`() { // Given @@ -114,8 +114,12 @@ class DoormanIntegrationTest { whenever(it.compatibilityZoneURL).thenReturn(URL("http://${doormanHostAndPort.host}:${doormanHostAndPort.port}")) whenever(it.emailAddress).thenReturn("iTest@R3.com") } -// config.rootCaCertFile.parent.createDirectories() -// X509Utilities.saveCertificateAsPEMFile(rootCertAndKey.certificate.toX509Certificate(), config.rootCaCertFile) + + config.trustStoreFile.parent.createDirectories() + loadOrCreateKeyStore(config.trustStoreFile, config.trustStorePassword).also { + it.addOrReplaceCertificate(X509Utilities.CORDA_ROOT_CA, rootCertAndKey.certificate.cert) + it.save(config.trustStoreFile, config.trustStorePassword) + } NetworkRegistrationHelper(config, HTTPNetworkRegistrationService(config.compatibilityZoneURL!!)).buildKeystore() diff --git a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt index 566b8bf38d..cbb85829d8 100644 --- a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt +++ b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt @@ -15,13 +15,14 @@ import com.r3.corda.networkmanage.hsm.persistence.SignedCertificateRequestStorag import com.r3.corda.networkmanage.hsm.signer.HsmCsrSigner import net.corda.core.crypto.Crypto import net.corda.core.identity.CordaX500Name +import net.corda.core.internal.cert +import net.corda.core.internal.createDirectories import net.corda.core.internal.uncheckedCast import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.seconds import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NetworkRegistrationHelper -import net.corda.nodeapi.internal.crypto.CertificateType -import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.crypto.* import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.ALICE_NAME import net.corda.testing.BOB_NAME @@ -93,8 +94,6 @@ class SigningServiceIntegrationTest { } } - // TODO: fix me (see commented out code in this test) - @Ignore @Test fun `Signing service signs approved CSRs`() { //Start doorman server @@ -132,8 +131,11 @@ class SigningServiceIntegrationTest { // [org.hibernate.tool.schema.spi.SchemaManagementException] being thrown as the schema is missing. } } -// config.rootCaCertFile.parent.createDirectories() -// X509Utilities.saveCertificateAsPEMFile(rootCACert, config.rootCaCertFile) + config.trustStoreFile.parent.createDirectories() + loadOrCreateKeyStore(config.trustStoreFile, config.trustStorePassword).also { + it.addOrReplaceCertificate(X509Utilities.CORDA_ROOT_CA, rootCACert.cert) + it.save(config.trustStoreFile, config.trustStorePassword) + } NetworkRegistrationHelper(config, HTTPNetworkRegistrationService(config.compatibilityZoneURL!!)).buildKeystore() verify(hsmSigner).sign(any()) } @@ -148,7 +150,6 @@ class SigningServiceIntegrationTest { * */ @Test - @Ignore fun `DEMO - Create CSR and poll`() { //Start doorman server val database = configureDatabase(makeTestDataSourceProperties(), DatabaseConfig())