|
@@ -32,6 +32,8 @@ import java.io.FileWriter;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.lang.annotation.Retention;
|
|
|
+import java.lang.annotation.RetentionPolicy;
|
|
|
import java.math.BigInteger;
|
|
|
import java.net.InetSocketAddress;
|
|
|
import java.net.URLDecoder;
|
|
@@ -116,11 +118,24 @@ import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
|
|
|
import org.bouncycastle.util.io.pem.PemWriter;
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
import org.junit.jupiter.api.Timeout;
|
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
|
|
+import org.junit.jupiter.params.provider.ValueSource;
|
|
|
|
|
|
public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
|
|
|
+ @Retention(RetentionPolicy.RUNTIME)
|
|
|
+ @ParameterizedTest(name = "fipsEnabled = {0}")
|
|
|
+ @ValueSource(booleans = { false, true})
|
|
|
+ private @interface TestBothFipsModes {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Retention(RetentionPolicy.RUNTIME)
|
|
|
+ @ParameterizedTest(name = "fipsEnabled = {0}")
|
|
|
+ @ValueSource(booleans = { false })
|
|
|
+ private @interface TestNoFipsOnly {
|
|
|
+ }
|
|
|
+
|
|
|
private static final String SSL_QUORUM_ENABLED = "sslQuorum=true\n";
|
|
|
private static final String PORT_UNIFICATION_ENABLED = "portUnification=true\n";
|
|
|
private static final String PORT_UNIFICATION_DISABLED = "portUnification=false\n";
|
|
@@ -478,9 +493,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
System.clearProperty(quorumX509Util.getSslProtocolProperty());
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testQuorumSSL() throws Exception {
|
|
|
+ public void testQuorumSSL(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
|
|
|
q2 = new MainThread(2, clientPortQp2, quorumConfiguration, SSL_QUORUM_ENABLED);
|
|
|
|
|
@@ -499,9 +516,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
assertFalse(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testQuorumSSL_withPasswordFromFile() throws Exception {
|
|
|
+ public void testQuorumSSL_withPasswordFromFile(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
final Path secretFile = SecretUtilsTest.createSecretFile(String.valueOf(PASSWORD));
|
|
|
|
|
|
System.clearProperty(quorumX509Util.getSslKeystorePasswdProperty());
|
|
@@ -523,9 +542,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testQuorumSSLWithMultipleAddresses() throws Exception {
|
|
|
+ public void testQuorumSSLWithMultipleAddresses(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
System.setProperty(QuorumPeer.CONFIG_KEY_MULTI_ADDRESS_ENABLED, "true");
|
|
|
quorumConfiguration = generateMultiAddressQuorumConfiguration();
|
|
|
|
|
@@ -548,9 +569,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testRollingUpgrade() throws Exception {
|
|
|
+ public void testRollingUpgrade(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
// Form a quorum without ssl
|
|
|
q1 = new MainThread(1, clientPortQp1, quorumConfiguration);
|
|
|
q2 = new MainThread(2, clientPortQp2, quorumConfiguration);
|
|
@@ -596,9 +619,10 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationWithInvalidHostname() throws Exception {
|
|
|
+ public void testHostnameVerificationWithInvalidHostname(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
|
|
|
X509Certificate badHostCert = buildEndEntityCert(
|
|
|
defaultKeyPair,
|
|
@@ -613,9 +637,10 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
testHostnameVerification(badhostnameKeystorePath, false);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationWithInvalidIPAddress() throws Exception {
|
|
|
+ public void testHostnameVerificationWithInvalidIPAddress(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
|
|
|
X509Certificate badHostCert = buildEndEntityCert(
|
|
|
defaultKeyPair,
|
|
@@ -630,9 +655,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
testHostnameVerification(badhostnameKeystorePath, false);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationWithInvalidIpAddressAndInvalidHostname() throws Exception {
|
|
|
+ public void testHostnameVerificationWithInvalidIpAddressAndInvalidHostname(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
|
|
|
X509Certificate badHostCert = buildEndEntityCert(
|
|
|
defaultKeyPair,
|
|
@@ -647,9 +674,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
testHostnameVerification(badhostnameKeystorePath, false);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationForInvalidMultiAddressServerConfig() throws Exception {
|
|
|
+ public void testHostnameVerificationForInvalidMultiAddressServerConfig(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
System.setProperty(QuorumPeer.CONFIG_KEY_MULTI_ADDRESS_ENABLED, "true");
|
|
|
quorumConfiguration = generateMultiAddressQuorumConfiguration();
|
|
|
|
|
@@ -667,9 +696,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
testHostnameVerification(badhostnameKeystorePath, false);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationWithInvalidIpAddressAndValidHostname() throws Exception {
|
|
|
+ public void testHostnameVerificationWithInvalidIpAddressAndValidHostname(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
|
|
|
X509Certificate badHostCert = buildEndEntityCert(
|
|
|
defaultKeyPair,
|
|
@@ -684,9 +715,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
testHostnameVerification(badhostnameKeystorePath, true);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestNoFipsOnly
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testHostnameVerificationWithValidIpAddressAndInvalidHostname() throws Exception {
|
|
|
+ public void testHostnameVerificationWithValidIpAddressAndInvalidHostname(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
|
|
|
X509Certificate badHostCert = buildEndEntityCert(
|
|
|
defaultKeyPair,
|
|
@@ -751,9 +784,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testCertificateRevocationList() throws Exception {
|
|
|
+ public void testCertificateRevocationList(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
|
|
|
q2 = new MainThread(2, clientPortQp2, quorumConfiguration, SSL_QUORUM_ENABLED);
|
|
|
|
|
@@ -817,9 +852,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
assertFalse(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testOCSP() throws Exception {
|
|
|
+ public void testOCSP(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
Integer ocspPort = PortAssignment.unique();
|
|
|
|
|
|
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
|
|
@@ -891,9 +928,11 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testCipherSuites() throws Exception {
|
|
|
+ public void testCipherSuites(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
+
|
|
|
// Get default cipher suites from JDK
|
|
|
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
|
|
|
List<String> defaultCiphers = new ArrayList<>();
|
|
@@ -932,9 +971,10 @@ public class QuorumSSLTest extends QuorumPeerTestBase {
|
|
|
assertFalse(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
+ @TestBothFipsModes
|
|
|
@Timeout(value = 5, unit = TimeUnit.MINUTES)
|
|
|
- public void testProtocolVersion() throws Exception {
|
|
|
+ public void testProtocolVersion(boolean fipsEnabled) throws Exception {
|
|
|
+ System.setProperty(quorumX509Util.getFipsModeProperty(), Boolean.toString(fipsEnabled));
|
|
|
System.setProperty(quorumX509Util.getSslProtocolProperty(), "TLSv1.2");
|
|
|
|
|
|
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
|