use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class CreateContainerTest method testCreateWithStat.
@Test
@Timeout(value = 30)
public void testCreateWithStat() throws KeeperException, InterruptedException {
Stat stat = createWithStatVerifyResult("/foo");
Stat childStat = createWithStatVerifyResult("/foo/child");
// Don't expect to get the same stats for different creates.
assertFalse(stat.equals(childStat));
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class X509UtilTest method testCreateSSLServerSocketWithPort.
@ParameterizedTest
@MethodSource("data")
@Timeout(value = 5)
public void testCreateSSLServerSocketWithPort(X509KeyType caKeyType, X509KeyType certKeyType, String keyPassword, Integer paramIndex) throws Exception {
init(caKeyType, certKeyType, keyPassword, paramIndex);
setCustomCipherSuites();
int port = PortAssignment.unique();
SSLServerSocket sslServerSocket = x509Util.createSSLServerSocket(port);
assertEquals(sslServerSocket.getLocalPort(), port);
assertArrayEquals(customCipherSuites, sslServerSocket.getEnabledCipherSuites());
assertTrue(sslServerSocket.getNeedClientAuth());
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testQuorumSSL_withPasswordFromFile.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testQuorumSSL_withPasswordFromFile() throws Exception {
final Path secretFile = SecretUtilsTest.createSecretFile(String.valueOf(PASSWORD));
System.clearProperty(quorumX509Util.getSslKeystorePasswdProperty());
System.setProperty(quorumX509Util.getSslKeystorePasswdPathProperty(), secretFile.toString());
System.clearProperty(quorumX509Util.getSslTruststorePasswdProperty());
System.setProperty(quorumX509Util.getSslTruststorePasswdPathProperty(), secretFile.toString());
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
q2 = new MainThread(2, clientPortQp2, quorumConfiguration, SSL_QUORUM_ENABLED);
q3 = new MainThread(3, clientPortQp3, quorumConfiguration, SSL_QUORUM_ENABLED);
q1.start();
q2.start();
q3.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testHostnameVerificationWithInvalidIpAddressAndValidHostname.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testHostnameVerificationWithInvalidIpAddressAndValidHostname() throws Exception {
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
X509Certificate badHostCert = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), "localhost", "140.211.11.105", null, null);
writeKeystore(badHostCert, defaultKeyPair, badhostnameKeystorePath);
testHostnameVerification(badhostnameKeystorePath, true);
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testOCSP.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testOCSP() throws Exception {
Integer ocspPort = PortAssignment.unique();
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
q2 = new MainThread(2, clientPortQp2, quorumConfiguration, SSL_QUORUM_ENABLED);
q1.start();
q2.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
String revokedInOCSPKeystorePath = tmpDir + "/ocsp_revoked.jks";
X509Certificate revokedInOCSPCert = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), HOSTNAME, null, null, ocspPort);
writeKeystore(revokedInOCSPCert, defaultKeyPair, revokedInOCSPKeystorePath);
HttpServer ocspServer = HttpServer.create(new InetSocketAddress(ocspPort), 0);
try {
ocspServer.createContext("/", new OCSPHandler(revokedInOCSPCert));
ocspServer.start();
System.setProperty(quorumX509Util.getSslKeystoreLocationProperty(), revokedInOCSPKeystorePath);
// This server should join successfully
q3 = new MainThread(3, clientPortQp3, quorumConfiguration, SSL_QUORUM_ENABLED);
q3.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
q1.shutdown();
q2.shutdown();
q3.shutdown();
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
setSSLSystemProperties();
System.setProperty(quorumX509Util.getSslOcspEnabledProperty(), "true");
X509Certificate validCertificate = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), HOSTNAME, null, null, ocspPort);
writeKeystore(validCertificate, defaultKeyPair, validKeystorePath);
q1.start();
q2.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
System.setProperty(quorumX509Util.getSslKeystoreLocationProperty(), revokedInOCSPKeystorePath);
q3.start();
assertFalse(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
} finally {
ocspServer.stop(0);
}
}
Aggregations