mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Use JUnit 5 for unit test execution (#3620)
Change the unit test execution to use the Junit5 JUnitPlatform. This allows for a mix of junit 4 and junit 5 tests and for a gradual migration to junit 5 instead of a big bang. One class depended on junit 4 exceptions and was updated. Two tests depending on native libraries fail gracefully on mac (and only mac). Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 22.1.4
|
||||
## 22.4.0-RC1
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
### Additions and Improvements
|
||||
- Unit tests are now executed with JUnit5 [#3620](https://github.com/hyperledger/besu/pull/3620)
|
||||
|
||||
## 22.1.3
|
||||
|
||||
|
||||
@@ -11,8 +11,11 @@ dependencies {
|
||||
implementation 'com.google.auto.service:auto-service'
|
||||
implementation 'info.picocli:picocli'
|
||||
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
task testPluginsJar(type: Jar) {
|
||||
|
||||
@@ -53,17 +53,17 @@ dependencies {
|
||||
testImplementation 'io.grpc:grpc-core'
|
||||
testImplementation 'io.grpc:grpc-netty'
|
||||
testImplementation 'io.grpc:grpc-stub'
|
||||
testImplementation 'io.jaegertracing:jaeger-client'
|
||||
testImplementation 'io.jaegertracing:jaeger-proto'
|
||||
testImplementation 'io.netty:netty-all'
|
||||
testImplementation 'io.opentelemetry.proto:opentelemetry-proto'
|
||||
testImplementation 'io.opentelemetry:opentelemetry-api'
|
||||
testImplementation 'io.opentelemetry:opentelemetry-exporter-otlp'
|
||||
testImplementation 'io.opentelemetry:opentelemetry-sdk'
|
||||
testImplementation 'io.opentelemetry:opentelemetry-sdk-trace'
|
||||
testImplementation 'io.opentelemetry:opentelemetry-exporter-otlp'
|
||||
testImplementation 'io.opentelemetry.proto:opentelemetry-proto'
|
||||
testImplementation 'io.opentracing.contrib:opentracing-okhttp3'
|
||||
testImplementation 'io.opentracing:opentracing-api'
|
||||
testImplementation 'io.opentracing:opentracing-util'
|
||||
testImplementation 'io.jaegertracing:jaeger-client'
|
||||
testImplementation 'io.jaegertracing:jaeger-proto'
|
||||
testImplementation 'io.vertx:vertx-core'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.apache.commons:commons-compress'
|
||||
@@ -71,10 +71,12 @@ dependencies {
|
||||
testImplementation 'org.apache.tuweni:tuweni-crypto'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.testcontainers:testcontainers'
|
||||
testImplementation 'org.web3j:abi'
|
||||
testImplementation 'org.web3j:besu'
|
||||
|
||||
testImplementation 'org.testcontainers:testcontainers'
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
test.enabled = false
|
||||
|
||||
@@ -84,16 +84,19 @@ dependencies {
|
||||
testImplementation project(path: ':crypto', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'tech.pegasys.discovery:discovery'
|
||||
testImplementation 'com.google.auto.service:auto-service'
|
||||
testImplementation 'com.squareup.okhttp3:okhttp'
|
||||
testImplementation 'commons-io:commons-io'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.apache.commons:commons-text'
|
||||
testImplementation 'org.apache.tuweni:tuweni-bytes'
|
||||
testImplementation 'org.apache.tuweni:tuweni-units'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'commons-io:commons-io'
|
||||
testImplementation 'org.testcontainers:testcontainers'
|
||||
testImplementation 'tech.pegasys.discovery:discovery'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -258,6 +258,7 @@ allprojects {
|
||||
systemProperty name, System.getProperty(name)
|
||||
}
|
||||
}
|
||||
useJUnitPlatform {}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
|
||||
@@ -43,7 +43,10 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
configurations { testArtifacts }
|
||||
|
||||
@@ -58,5 +58,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -55,8 +55,11 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
testSupportImplementation project( path: ':crypto', configuration: 'testSupportArtifacts')
|
||||
testSupportImplementation project( path: ':ethereum:core', configuration: 'testSupportArtifacts')
|
||||
|
||||
@@ -69,7 +69,10 @@ dependencies {
|
||||
integrationTestImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -44,5 +44,8 @@ dependencies {
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation project(':ethereum:core')
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -80,10 +80,6 @@ dependencies {
|
||||
integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts')
|
||||
integrationTestImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation project(path: ':crypto', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(path: ':config', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(path: ':consensus:common', configuration: 'testArtifacts')
|
||||
@@ -95,6 +91,14 @@ dependencies {
|
||||
testImplementation project(':metrics:core')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
integrationTestImplementation project(':crypto')
|
||||
integrationTestImplementation project(path: ':crypto', configuration: 'testSupportArtifacts')
|
||||
integrationTestImplementation project(path: ':consensus:common', configuration: 'testSupportArtifacts')
|
||||
|
||||
@@ -20,9 +20,12 @@ dependencies {
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.testcontainers:testcontainers'
|
||||
testImplementation 'org.web3j:core'
|
||||
testImplementation 'org.web3j:quorum'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
test.enabled = false
|
||||
|
||||
@@ -43,7 +43,10 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
|
||||
@@ -40,6 +40,9 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
configurations { testArtifacts }
|
||||
|
||||
@@ -16,6 +16,9 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
// integration test dependencies.
|
||||
integrationTestImplementation project(':testutil')
|
||||
|
||||
@@ -37,6 +37,9 @@ dependencies {
|
||||
testImplementation 'com.google.errorprone:error_prone_test_helpers'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
epJavac 'com.google.errorprone:error_prone_check_api'
|
||||
}
|
||||
|
||||
@@ -88,14 +88,17 @@ dependencies {
|
||||
testResourceGeneration project(':besu')
|
||||
|
||||
testImplementation 'com.squareup.okhttp3:okhttp'
|
||||
|
||||
testImplementation 'io.vertx:vertx-auth-jwt'
|
||||
testImplementation 'io.vertx:vertx-unit'
|
||||
testImplementation 'io.vertx:vertx-web-client'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.apache.logging.log4j:log4j-core'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'io.vertx:vertx-web-client'
|
||||
testImplementation 'io.vertx:vertx-auth-jwt'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
testSupportImplementation 'org.bouncycastle:bcpkix-jdk15on'
|
||||
|
||||
integrationTestImplementation project(':config')
|
||||
|
||||
@@ -34,9 +34,12 @@ dependencies {
|
||||
testImplementation project(':metrics:core')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -80,8 +80,11 @@ dependencies {
|
||||
testImplementation 'org.apache.tuweni:tuweni-io'
|
||||
testImplementation 'org.apache.tuweni:tuweni-units'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts')
|
||||
integrationTestImplementation project(':testutil')
|
||||
|
||||
|
||||
@@ -71,11 +71,14 @@ dependencies {
|
||||
testImplementation project(path: ':metrics:core', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
testSupportImplementation 'junit:junit'
|
||||
testSupportImplementation 'org.mockito:mockito-core'
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
package org.hyperledger.besu.ethereum.eth.transactions;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import org.hyperledger.besu.crypto.KeyPair;
|
||||
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
|
||||
@@ -27,24 +29,23 @@ import java.util.concurrent.TimeUnit;
|
||||
import io.vertx.core.Vertx;
|
||||
import org.apache.tuweni.bytes.Bytes32;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.ComparisonFailure;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TransactionPoolPropagationTest {
|
||||
class TransactionPoolPropagationTest {
|
||||
|
||||
final DiscoveryConfiguration noDiscovery = DiscoveryConfiguration.create().setActive(false);
|
||||
|
||||
private Vertx vertx;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
vertx = Vertx.vertx();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
vertx.close();
|
||||
}
|
||||
|
||||
@@ -67,8 +68,8 @@ public class TransactionPoolPropagationTest {
|
||||
* 2nd order test to verify the framework correctly fails if a disconnect occurs It could have a
|
||||
* more detailed exception check - more than just the class.
|
||||
*/
|
||||
@Test(expected = ComparisonFailure.class)
|
||||
public void disconnectShouldThrow() throws Exception {
|
||||
@Test
|
||||
void disconnectShouldThrow() throws Exception {
|
||||
|
||||
try (final TestNodeList txNodes = new TestNodeList()) {
|
||||
// Create & Start Nodes
|
||||
@@ -80,7 +81,7 @@ public class TransactionPoolPropagationTest {
|
||||
|
||||
node1.network.getPeers().iterator().next().disconnect(DisconnectReason.BREACH_OF_PROTOCOL);
|
||||
|
||||
wrapup(txNodes);
|
||||
assertThatThrownBy(() -> wrapup(txNodes)).isInstanceOf(AssertionError.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ public class TransactionPoolPropagationTest {
|
||||
* node. Verify that all nodes get the correct number of pending transactions.
|
||||
*/
|
||||
@Test
|
||||
public void shouldPropagateLocalAndRemoteTransactions() throws Exception {
|
||||
void shouldPropagateLocalAndRemoteTransactions() throws Exception {
|
||||
try (final TestNodeList nodes = new TestNodeList()) {
|
||||
// Create & Start Nodes
|
||||
final TestNode node1 = nodes.create(vertx, null, null, noDiscovery);
|
||||
|
||||
@@ -59,5 +59,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -62,7 +62,10 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
mainClassName = 'org.hyperledger.besu.evmtool.EvmTool'
|
||||
|
||||
@@ -37,6 +37,9 @@ dependencies {
|
||||
implementation 'io.vertx:vertx-core'
|
||||
implementation 'org.apache.tuweni:tuweni-bytes'
|
||||
|
||||
testImplementation "junit:junit"
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ dependencies {
|
||||
testImplementation project(path: ':crypto', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
testImplementation('io.pkts:pkts-core') {
|
||||
exclude group: 'io.pkts', module: 'pkts-sdp'
|
||||
exclude group: 'io.pkts', module: 'pkts-sip'
|
||||
@@ -75,6 +76,8 @@ dependencies {
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.hyperledger.besu.pki.keystore.HardwareKeyStoreWrapper;
|
||||
import org.hyperledger.besu.pki.keystore.KeyStoreWrapper;
|
||||
import org.hyperledger.besu.pki.keystore.SoftwareKeyStoreWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
@@ -45,16 +44,16 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.Assume;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TLSContextFactoryTest {
|
||||
class TLSContextFactoryTest {
|
||||
|
||||
private static final String JKS = "JKS";
|
||||
private static final String validKeystorePassword = "test123";
|
||||
@@ -86,19 +85,36 @@ public class TLSContextFactoryTest {
|
||||
private Server server;
|
||||
private Client client;
|
||||
|
||||
@Parameterized.Parameter public String keyStoreWrapperDescription;
|
||||
static Collection<Object[]> hardwareKeysData() {
|
||||
return Arrays.asList(
|
||||
new Object[][] {
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientPartner2Client1 SuccessfulConnection",
|
||||
true,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner2client1JKSKeystore, partner2client1JKSTruststore, partner2client1CRL)
|
||||
},
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientInvalidPartner1Client1 FailedConnection",
|
||||
false,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
invalidPartner1client1JKSKeystore,
|
||||
invalidPartner1client1JKSTruststore,
|
||||
invalidPartner1client1CRL)
|
||||
},
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientPartner1Client2rvk FailedConnection",
|
||||
false,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner1client2rvkJKSKeystore, partner1client2rvkJKSTruststore, null)
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
public boolean testSuccess;
|
||||
|
||||
@Parameterized.Parameter(2)
|
||||
public KeyStoreWrapper serverKeyStoreWrapper;
|
||||
|
||||
@Parameterized.Parameter(3)
|
||||
public KeyStoreWrapper clientKeyStoreWrapper;
|
||||
|
||||
@Parameterized.Parameters(name = "{index}: {0}")
|
||||
public static Collection<Object[]> data() {
|
||||
static Collection<Object[]> softwareKeysData() {
|
||||
return Arrays.asList(
|
||||
new Object[][] {
|
||||
{
|
||||
@@ -117,13 +133,6 @@ public class TLSContextFactoryTest {
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner1client1JKSKeystore, partner1client1JKSTruststore, partner1client1CRL)
|
||||
},
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientPartner2Client1 SuccessfulConnection",
|
||||
true,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner2client1JKSKeystore, partner2client1JKSTruststore, partner2client1CRL)
|
||||
},
|
||||
{
|
||||
"JKS serverPartner1Client1 -> JKS clientInvalidPartner1Client1 FailedConnection",
|
||||
false,
|
||||
@@ -144,15 +153,6 @@ public class TLSContextFactoryTest {
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner1client1JKSKeystore, partner1client1JKSTruststore, partner1client1CRL)
|
||||
},
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientInvalidPartner1Client1 FailedConnection",
|
||||
false,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
invalidPartner1client1JKSKeystore,
|
||||
invalidPartner1client1JKSTruststore,
|
||||
invalidPartner1client1CRL)
|
||||
},
|
||||
{
|
||||
"JKS serverPartner1Client2rvk -> JKS clientPartner2Client1 FailedConnection",
|
||||
false,
|
||||
@@ -169,13 +169,6 @@ public class TLSContextFactoryTest {
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner1client2rvkJKSKeystore, partner1client2rvkJKSTruststore, null)
|
||||
},
|
||||
{
|
||||
"PKCS11 serverPartner1Client1 -> JKS clientPartner1Client2rvk FailedConnection",
|
||||
false,
|
||||
getHardwareKeyStoreWrapper(partner1client1PKCS11Config, partner1client1CRL),
|
||||
getSoftwareKeyStoreWrapper(
|
||||
partner1client2rvkJKSKeystore, partner1client2rvkJKSTruststore, null)
|
||||
},
|
||||
{
|
||||
"JKS serverPartner2Client2rvk -> JKS clientPartner1Client1 FailedConnection",
|
||||
false,
|
||||
@@ -195,11 +188,11 @@ public class TLSContextFactoryTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() throws IOException, InterruptedException {}
|
||||
@BeforeEach
|
||||
void init() {}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
if (client != null) {
|
||||
client.stop();
|
||||
}
|
||||
@@ -217,7 +210,13 @@ public class TLSContextFactoryTest {
|
||||
try {
|
||||
return new HardwareKeyStoreWrapper(
|
||||
validKeystorePassword, toPath(config), toPath(crlLocation));
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
if (OS.MAC.isCurrentOs()) {
|
||||
// nss3 is difficult to setup on mac correctly, don't let it break unit tests for dev
|
||||
// machines.
|
||||
Assume.assumeNoException("Failed to initialize hardware keystore", e);
|
||||
}
|
||||
// Not a mac, probably a production build. Full failure.
|
||||
throw new PkiException("Failed to initialize hardware keystore", e);
|
||||
}
|
||||
}
|
||||
@@ -233,13 +232,38 @@ public class TLSContextFactoryTest {
|
||||
toPath(trustStore),
|
||||
null,
|
||||
toPath(crl));
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new PkiException("Failed to initialize software keystore", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnection() throws Exception {
|
||||
@ParameterizedTest(name = "{index}: {0}")
|
||||
@MethodSource("softwareKeysData")
|
||||
void testConnectionSoftwareKeys(
|
||||
final String ignoredTestDescription,
|
||||
final boolean testSuccess,
|
||||
final KeyStoreWrapper serverKeyStoreWrapper,
|
||||
final KeyStoreWrapper clientKeyStoreWrapper)
|
||||
throws Exception {
|
||||
testConnection(testSuccess, serverKeyStoreWrapper, clientKeyStoreWrapper);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{index}: {0}")
|
||||
@MethodSource("hardwareKeysData")
|
||||
void testConnectionHardwareKeys(
|
||||
final String ignoredTestDescription,
|
||||
final boolean testSuccess,
|
||||
final KeyStoreWrapper serverKeyStoreWrapper,
|
||||
final KeyStoreWrapper clientKeyStoreWrapper)
|
||||
throws Exception {
|
||||
testConnection(testSuccess, serverKeyStoreWrapper, clientKeyStoreWrapper);
|
||||
}
|
||||
|
||||
private void testConnection(
|
||||
final boolean testSuccess,
|
||||
final KeyStoreWrapper serverKeyStoreWrapper,
|
||||
final KeyStoreWrapper clientKeyStoreWrapper)
|
||||
throws Exception {
|
||||
final CountDownLatch serverLatch = new CountDownLatch(MAX_NUMBER_MESSAGES);
|
||||
final CountDownLatch clientLatch = new CountDownLatch(MAX_NUMBER_MESSAGES);
|
||||
server = startServer(serverKeyStoreWrapper, serverLatch);
|
||||
@@ -255,7 +279,7 @@ public class TLSContextFactoryTest {
|
||||
client.getChannelFuture().channel().writeAndFlush(Unpooled.copyInt(0)).sync();
|
||||
serverLatch.await(2, TimeUnit.SECONDS);
|
||||
assertThat(client.getChannelFuture().channel().isActive()).isFalse();
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
@@ -282,7 +306,7 @@ public class TLSContextFactoryTest {
|
||||
private final String id;
|
||||
private final CountDownLatch latch;
|
||||
|
||||
public MessageHandler(final String id, final CountDownLatch latch) {
|
||||
MessageHandler(final String id, final CountDownLatch latch) {
|
||||
this.id = id;
|
||||
this.latch = latch;
|
||||
}
|
||||
@@ -312,7 +336,7 @@ public class TLSContextFactoryTest {
|
||||
private ChannelFuture channelFuture;
|
||||
private final EventLoopGroup group = new NioEventLoopGroup();
|
||||
|
||||
public ChannelFuture getChannelFuture() {
|
||||
ChannelFuture getChannelFuture() {
|
||||
return channelFuture;
|
||||
}
|
||||
|
||||
@@ -335,7 +359,7 @@ public class TLSContextFactoryTest {
|
||||
new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
protected void initChannel(final SocketChannel socketChannel) throws Exception {
|
||||
SslContext sslContext =
|
||||
final SslContext sslContext =
|
||||
TLSContextFactory.getInstance(keystorePassword, keyStoreWrapper)
|
||||
.createNettyClientSslContext();
|
||||
|
||||
@@ -346,11 +370,10 @@ public class TLSContextFactoryTest {
|
||||
}
|
||||
});
|
||||
|
||||
final ChannelFuture cf = b.connect("127.0.0.1", this.port).sync();
|
||||
this.channelFuture = cf;
|
||||
this.channelFuture = b.connect("127.0.0.1", this.port).sync();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
void stop() {
|
||||
group.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
@@ -362,7 +385,6 @@ public class TLSContextFactoryTest {
|
||||
private final CountDownLatch latch;
|
||||
|
||||
private Channel channel;
|
||||
private ChannelFuture channelFuture;
|
||||
|
||||
private final EventLoopGroup parentGroup = new NioEventLoopGroup();
|
||||
private final EventLoopGroup childGroup = new NioEventLoopGroup();
|
||||
@@ -376,10 +398,6 @@ public class TLSContextFactoryTest {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public ChannelFuture getChannelFuture() {
|
||||
return channelFuture;
|
||||
}
|
||||
|
||||
void start() throws Exception {
|
||||
final ServerBootstrap sb = new ServerBootstrap();
|
||||
sb.group(parentGroup, childGroup)
|
||||
@@ -388,7 +406,7 @@ public class TLSContextFactoryTest {
|
||||
new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(final SocketChannel socketChannel) throws Exception {
|
||||
SslContext sslContext =
|
||||
final SslContext sslContext =
|
||||
TLSContextFactory.getInstance(keystorePassword, keyStoreWrapper)
|
||||
.createNettyServerSslContext();
|
||||
final SslHandler sslHandler = sslContext.newHandler(channel.alloc());
|
||||
@@ -400,11 +418,10 @@ public class TLSContextFactoryTest {
|
||||
|
||||
final ChannelFuture cf = sb.bind(0).sync();
|
||||
this.channel = cf.channel();
|
||||
this.channelFuture = cf;
|
||||
this.port = ((InetSocketAddress) channel.localAddress()).getPort();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
void stop() {
|
||||
childGroup.shutdownGracefully();
|
||||
parentGroup.shutdownGracefully();
|
||||
}
|
||||
|
||||
@@ -49,8 +49,12 @@ dependencies {
|
||||
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(':evm')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'io.vertx:vertx-core'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -52,5 +52,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ dependencies {
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -44,11 +44,14 @@ dependencies {
|
||||
implementation 'org.apache.tuweni:tuweni-bytes'
|
||||
implementation 'org.apache.tuweni:tuweni-units'
|
||||
|
||||
testImplementation project(path: ':metrics:core', configuration: 'testSupportArtifacts')
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
testImplementation project(path: ':metrics:core', configuration: 'testSupportArtifacts')
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -47,7 +47,10 @@ dependencies {
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.apache.tuweni:tuweni-units'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
test { exclude 'org/hyperledger/besu/ethereum/trie/TrieRefTest.class' }
|
||||
|
||||
@@ -46,7 +46,10 @@ dependencies {
|
||||
testImplementation 'info.picocli:picocli'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version=22.1.4-SNAPSHOT
|
||||
version=22.4.0-RC1
|
||||
|
||||
# Workaround for Java 16 and spotless bug 834 https://github.com/diffplug/spotless/issues/834
|
||||
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
||||
|
||||
@@ -154,6 +154,9 @@ dependencyManagement {
|
||||
dependency 'org.jupnp:org.jupnp.support:2.6.0'
|
||||
dependency 'org.jupnp:org.jupnp:2.6.0'
|
||||
|
||||
dependency 'org.junit.jupiter:junit-jupiter:5.8.2'
|
||||
dependency 'org.junit.vintage:junit-vintage-engine:5.8.2'
|
||||
|
||||
dependency 'org.mockito:mockito-core:4.4.0'
|
||||
|
||||
dependency 'org.openjdk.jmh:jmh-core:1.34'
|
||||
|
||||
@@ -66,8 +66,11 @@ dependencies {
|
||||
testImplementation 'com.squareup.okhttp3:okhttp'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
|
||||
testSupportImplementation 'org.mockito:mockito-core'
|
||||
}
|
||||
|
||||
|
||||
@@ -43,5 +43,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
configurations { testArtifacts }
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.stream.Stream;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
public class HardwareKeyStoreFileWrapperTest extends BaseKeyStoreFileWrapperTest {
|
||||
@@ -60,7 +61,13 @@ public class HardwareKeyStoreFileWrapperTest extends BaseKeyStoreFileWrapperTest
|
||||
.map(provider -> new HardwareKeyStoreWrapper(validKeystorePassword, provider, crlPath))
|
||||
.orElseGet(() -> new HardwareKeyStoreWrapper(validKeystorePassword, path, crlPath));
|
||||
} catch (final Exception e) {
|
||||
throw new PkiException("Failed to initialize NSS keystore", e);
|
||||
if (OS.MAC.isCurrentOs()) {
|
||||
// nss3 is difficult to setup on mac correctly, don't let it break unit tests for dev
|
||||
// machines.
|
||||
Assume.assumeNoException("Failed to initialize hardware keystore", e);
|
||||
}
|
||||
// Not a mac, probably a production build. Full failure.
|
||||
throw new PkiException("Failed to initialize hardware keystore", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,5 +51,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -44,5 +44,8 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -40,5 +40,8 @@ dependencies {
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -42,4 +42,7 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
@@ -40,8 +40,11 @@ dependencies {
|
||||
implementation 'org.apache.tuweni:tuweni-units'
|
||||
implementation 'org.xerial.snappy:snappy-java'
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'io.vertx:vertx-unit'
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
|
||||
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user