diff --git a/doorman/src/integration-test/kotlin/com/r3/corda/doorman/DoormanIntegrationTest.kt b/doorman/src/integration-test/kotlin/com/r3/corda/doorman/DoormanIntegrationTest.kt index 1a3dc2280f..d0485fa66b 100644 --- a/doorman/src/integration-test/kotlin/com/r3/corda/doorman/DoormanIntegrationTest.kt +++ b/doorman/src/integration-test/kotlin/com/r3/corda/doorman/DoormanIntegrationTest.kt @@ -2,13 +2,15 @@ package com.r3.corda.doorman import com.google.common.net.HostAndPort import com.nhaarman.mockito_kotlin.whenever -import com.r3.corda.doorman.persistence.CertificationRequestStorage -import com.r3.corda.doorman.persistence.DBCertificateRequestStorage +import com.r3.corda.doorman.persistence.ApprovingAllCertificateRequestStorage import com.r3.corda.doorman.persistence.DoormanSchemaService +import com.r3.corda.doorman.signer.DefaultCsrHandler +import com.r3.corda.doorman.signer.LocalSigner import net.corda.core.crypto.Crypto import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name -import net.corda.core.utilities.* +import net.corda.core.utilities.cert +import net.corda.core.utilities.subject import net.corda.node.utilities.* import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NetworkRegistrationHelper @@ -29,21 +31,19 @@ class DoormanIntegrationTest { @Test fun `Network Registration With Doorman`() { val rootCAKey = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) - val rootCACert = X509Utilities.createSelfSignedCACertificate(getX500Name(CN = "Integration Test Corda Node Root CA", O = "R3 Ltd", L = "London", C = "GB"), rootCAKey) + val rootCACert = X509Utilities.createSelfSignedCACertificate(CordaX500Name(commonName = "Integration Test Corda Node Root CA", organisation = "R3 Ltd", + locality = "London", country = "GB").x500Name, rootCAKey) val intermediateCAKey = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) val intermediateCACert = X509Utilities.createCertificate(CertificateType.INTERMEDIATE_CA, rootCACert, rootCAKey, - getX500Name(CN = "Integration Test Corda Node Intermediate CA", L = "London", C = "GB", O = "R3 Ltd"), intermediateCAKey.public) + CordaX500Name(commonName = "Integration Test Corda Node Intermediate CA", locality = "London", country = "GB", organisation = "R3 Ltd"), intermediateCAKey.public) val database = configureDatabase(makeTestDataSourceProperties(), null, { DoormanSchemaService() }, createIdentityService = { // Identity service not needed doorman, corda persistence is not very generic. throw UnsupportedOperationException() }) //Start doorman server - val doorman = DoormanServer(HostAndPort.fromParts("localhost", 0), CertificateAndKeyPair(intermediateCACert, intermediateCAKey), rootCACert.toX509Certificate(), - object : CertificationRequestStorage by DBCertificateRequestStorage(database) { - // The doorman is in approve all mode, returns all pending request id as approved request id. - override fun getApprovedRequestIds() = getPendingRequestIds() - }) + val storage = ApprovingAllCertificateRequestStorage(database) + val doorman = DoormanServer(HostAndPort.fromParts("localhost", 0), DefaultCsrHandler(storage, LocalSigner(storage, CertificateAndKeyPair(intermediateCACert, intermediateCAKey), rootCACert.toX509Certificate()))) doorman.start() // Start Corda network registration. @@ -68,7 +68,7 @@ class DoormanIntegrationTest { loadKeyStore(config.sslKeystore, config.keyStorePassword).apply { assert(containsAlias(X509Utilities.CORDA_CLIENT_TLS)) - assertEquals(ALICE.name.x500Name, getX509Certificate(X509Utilities.CORDA_CLIENT_TLS).subject) + assertEquals(ALICE.name.copy(commonName = X509Utilities.CORDA_CLIENT_CA_CN).x500Name, getX509Certificate(X509Utilities.CORDA_CLIENT_TLS).subject) assertEquals(listOf(intermediateCACert.cert, rootCACert.cert), getCertificateChain(X509Utilities.CORDA_CLIENT_TLS).drop(2).toList()) } diff --git a/doorman/src/main/kotlin/com/r3/corda/doorman/persistence/ApprovingAllCertificateRequestStorage.kt b/doorman/src/main/kotlin/com/r3/corda/doorman/persistence/ApprovingAllCertificateRequestStorage.kt index 8e8c83050d..31d5b67b7f 100644 --- a/doorman/src/main/kotlin/com/r3/corda/doorman/persistence/ApprovingAllCertificateRequestStorage.kt +++ b/doorman/src/main/kotlin/com/r3/corda/doorman/persistence/ApprovingAllCertificateRequestStorage.kt @@ -7,7 +7,7 @@ import net.corda.node.utilities.CordaPersistence */ class ApprovingAllCertificateRequestStorage(private val database: CordaPersistence) : DBCertificateRequestStorage(database) { override fun saveRequest(certificationData: CertificationRequestData): String { - val requestId = saveRequest(certificationData) + val requestId = super.saveRequest(certificationData) approveRequest(requestId) return requestId }