mirror of
https://github.com/corda/corda.git
synced 2025-06-18 07:08:15 +00:00
Merge branch 'release/os/4.6' into dan/4.6-into-checkpoint-feature-branch-2020-05-05
# Conflicts: # node/src/main/kotlin/net/corda/node/services/statemachine/Event.kt # node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt # node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt # node/src/main/kotlin/net/corda/node/services/statemachine/transitions/TopLevelTransition.kt
This commit is contained in:
@ -15,6 +15,7 @@ import net.corda.core.crypto.Crypto.generateKeyPair
|
||||
import net.corda.core.crypto.SignatureScheme
|
||||
import net.corda.core.crypto.newSecureRandom
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.internal.JavaVersion
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
import net.corda.core.serialization.deserialize
|
||||
@ -96,6 +97,7 @@ class X509UtilitiesTest {
|
||||
Pair(ECDSA_SECP256K1_SHA256, RSA_SHA256),
|
||||
Pair(EDDSA_ED25519_SHA512, ECDSA_SECP256K1_SHA256),
|
||||
Pair(RSA_SHA256, EDDSA_ED25519_SHA512),
|
||||
Pair(EDDSA_ED25519_SHA512, ECDSA_SECP256R1_SHA256),
|
||||
Pair(SPHINCS256_SHA256, ECDSA_SECP256R1_SHA256)
|
||||
)
|
||||
|
||||
@ -115,7 +117,8 @@ class X509UtilitiesTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `create valid self-signed CA certificate`() {
|
||||
Crypto.supportedSignatureSchemes().filter { it != COMPOSITE_KEY }.forEach { validSelfSignedCertificate(it) }
|
||||
Crypto.supportedSignatureSchemes().filter { it != COMPOSITE_KEY
|
||||
&& ( !JavaVersion.isVersionAtLeast(JavaVersion.Java_11) || it != SPHINCS256_SHA256)}.forEach { validSelfSignedCertificate(it) }
|
||||
}
|
||||
|
||||
private fun validSelfSignedCertificate(signatureScheme: SignatureScheme) {
|
||||
@ -150,7 +153,8 @@ class X509UtilitiesTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `create valid server certificate chain`() {
|
||||
certChainSchemeCombinations.forEach { createValidServerCertChain(it.first, it.second) }
|
||||
certChainSchemeCombinations.filter{ !JavaVersion.isVersionAtLeast(JavaVersion.Java_11) || it.first != SPHINCS256_SHA256 }
|
||||
.forEach { createValidServerCertChain(it.first, it.second) }
|
||||
}
|
||||
|
||||
private fun createValidServerCertChain(signatureSchemeRoot: SignatureScheme, signatureSchemeChild: SignatureScheme) {
|
||||
|
@ -0,0 +1,78 @@
|
||||
package net.corda.nodeapitests.internal.persistence
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.InitiatingFlow
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.nodeapi.internal.persistence.RestrictedConnection
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.StartedMockNode
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class RestrictedConnectionFlowTest {
|
||||
private lateinit var aliceNode: StartedMockNode
|
||||
private lateinit var mockNetwork: MockNetwork
|
||||
|
||||
@InitiatingFlow
|
||||
class TestIfItIsRestrictedConnection : FlowLogic<Boolean>() {
|
||||
@Suspendable
|
||||
override fun call() : Boolean {
|
||||
val connection = serviceHub.jdbcSession()
|
||||
return connection is RestrictedConnection
|
||||
}
|
||||
}
|
||||
|
||||
@InitiatingFlow
|
||||
class TestAutoCommitMethodIsBlocked : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val connection = serviceHub.jdbcSession()
|
||||
connection.autoCommit = true
|
||||
}
|
||||
}
|
||||
|
||||
@InitiatingFlow
|
||||
class TestCloseMethodIsBlocked : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val connection = serviceHub.jdbcSession()
|
||||
connection.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
fun init() {
|
||||
mockNetwork = MockNetwork(MockNetworkParameters())
|
||||
aliceNode = mockNetwork.createPartyNode(CordaX500Name("Alice", "London", "GB"))
|
||||
}
|
||||
|
||||
@After
|
||||
fun done() {
|
||||
mockNetwork.stopNodes()
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testIfItIsRestrictedConnection() {
|
||||
assertTrue { aliceNode.startFlow(TestIfItIsRestrictedConnection()).get() }
|
||||
mockNetwork.runNetwork()
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testMethodsAreBlocked() {
|
||||
Assertions.assertThatExceptionOfType(UnsupportedOperationException::class.java)
|
||||
.isThrownBy { aliceNode.startFlow(TestAutoCommitMethodIsBlocked()).getOrThrow() }
|
||||
.withMessageContaining("This method cannot be called via ServiceHub.jdbcSession.")
|
||||
|
||||
Assertions.assertThatExceptionOfType(UnsupportedOperationException::class.java)
|
||||
.isThrownBy { aliceNode.startFlow(TestCloseMethodIsBlocked()).getOrThrow() }
|
||||
.withMessageContaining("This method cannot be called via ServiceHub.jdbcSession.")
|
||||
|
||||
mockNetwork.runNetwork()
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package net.corda.nodeapitests.internal.persistence
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.InitiatingFlow
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.nodeapi.internal.persistence.RestrictedEntityManager
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import net.corda.testing.node.MockNetworkParameters
|
||||
import net.corda.testing.node.StartedMockNode
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class RestrictedEntityManagerFlowTest {
|
||||
|
||||
private lateinit var aliceNode: StartedMockNode
|
||||
private lateinit var mockNetwork: MockNetwork
|
||||
|
||||
@InitiatingFlow
|
||||
class TestIfItIsRestrictedEntityManager : FlowLogic<Boolean>() {
|
||||
@Suspendable
|
||||
override fun call() : Boolean {
|
||||
var result = false
|
||||
serviceHub.withEntityManager() {
|
||||
result = this is RestrictedEntityManager
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@InitiatingFlow
|
||||
class TestCloseMethodIsBlocked : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
serviceHub.withEntityManager() {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@InitiatingFlow
|
||||
class TestJoinTransactionMethodIsBlocked : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
serviceHub.withEntityManager() {
|
||||
this.joinTransaction()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
fun init() {
|
||||
mockNetwork = MockNetwork(MockNetworkParameters())
|
||||
aliceNode = mockNetwork.createPartyNode(CordaX500Name("Alice", "London", "GB"))
|
||||
}
|
||||
|
||||
@After
|
||||
fun done() {
|
||||
mockNetwork.stopNodes()
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testIfItIsRestrictedConnection() {
|
||||
assertTrue { aliceNode.startFlow(TestIfItIsRestrictedEntityManager()).get() }
|
||||
mockNetwork.runNetwork()
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testMethodsAreBlocked() {
|
||||
Assertions.assertThatExceptionOfType(UnsupportedOperationException::class.java)
|
||||
.isThrownBy { aliceNode.startFlow(TestCloseMethodIsBlocked()).getOrThrow() }
|
||||
.withMessageContaining("This method cannot be called via ServiceHub.withEntityManager.")
|
||||
|
||||
Assertions.assertThatExceptionOfType(UnsupportedOperationException::class.java)
|
||||
.isThrownBy { aliceNode.startFlow(TestJoinTransactionMethodIsBlocked()).getOrThrow() }
|
||||
.withMessageContaining("This method cannot be called via ServiceHub.withEntityManager.")
|
||||
|
||||
mockNetwork.runNetwork()
|
||||
}
|
||||
}
|
@ -12,8 +12,6 @@ import net.corda.node.services.persistence.NodeAttachmentService
|
||||
import net.corda.serialization.internal.AllWhitelist
|
||||
import net.corda.serialization.internal.CheckpointSerializationContextImpl
|
||||
import net.corda.serialization.internal.CordaSerializationEncoding
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.TestIdentity
|
||||
import net.corda.testing.core.internal.CheckpointSerializationEnvironmentRule
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
Reference in New Issue
Block a user