JNI/JSSE: update JUnit tests for Android compatibility
parent
988a29e0f3
commit
b4e479bb0c
|
@ -499,6 +499,11 @@ public class WolfSSLContextTest {
|
|||
/* Save original property value to reset after test */
|
||||
String originalProperty =
|
||||
Security.getProperty("jdk.tls.disabledAlgorithms");
|
||||
if (originalProperty == null) {
|
||||
/* Default back to empty string, otherwise we may get a NullPointerException when
|
||||
* trying to restore this back to the original value later */
|
||||
originalProperty = "";
|
||||
}
|
||||
|
||||
/* Test with no protocols disabled */
|
||||
Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
||||
|
|
|
@ -1032,7 +1032,8 @@ public class WolfSSLEngineTest {
|
|||
/* Start up simple TLS test server */
|
||||
CountDownLatch serverOpenLatch = new CountDownLatch(1);
|
||||
InternalMultiThreadedSSLSocketServer server =
|
||||
new InternalMultiThreadedSSLSocketServer(svrPort, serverOpenLatch);
|
||||
new InternalMultiThreadedSSLSocketServer(svrPort, serverOpenLatch,
|
||||
numThreads);
|
||||
server.start();
|
||||
|
||||
/* Wait for server thread to start up before connecting clients */
|
||||
|
@ -1303,11 +1304,13 @@ public class WolfSSLEngineTest {
|
|||
{
|
||||
private int serverPort;
|
||||
private CountDownLatch serverOpenLatch = null;
|
||||
private int clientConnections = 1;
|
||||
|
||||
public InternalMultiThreadedSSLSocketServer(
|
||||
int port, CountDownLatch openLatch) {
|
||||
int port, CountDownLatch openLatch, int clientConnections) {
|
||||
this.serverPort = port;
|
||||
serverOpenLatch = openLatch;
|
||||
this.clientConnections = clientConnections;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1317,11 +1320,12 @@ public class WolfSSLEngineTest {
|
|||
SSLServerSocket ss = (SSLServerSocket)ctx
|
||||
.getServerSocketFactory().createServerSocket(serverPort);
|
||||
|
||||
while (true) {
|
||||
while (clientConnections > 0) {
|
||||
serverOpenLatch.countDown();
|
||||
SSLSocket sock = (SSLSocket)ss.accept();
|
||||
ClientHandler client = new ClientHandler(sock);
|
||||
client.start();
|
||||
clientConnections--;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -176,9 +176,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("client")) {
|
||||
if (!alias.equals("client") && !alias.equals("ca")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'client' alias for RSA type from allJKS");
|
||||
fail("expected 'client' alias for RSA type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,9 +189,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("server-ecc")) {
|
||||
if (!alias.equals("server-ecc") && !alias.equals("ca-ecc")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("client")) {
|
||||
if (!alias.equals("client") && !alias.equals("ca")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'client' alias for RSA type from allJKS");
|
||||
fail("expected 'client' alias for RSA type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,9 +251,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("server-ecc")) {
|
||||
if (!alias.equals("server-ecc") && !alias.equals("ca-ecc")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,9 +350,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("client")) {
|
||||
if (!alias.equals("client") && !alias.equals("ca")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'client' alias for RSA type from allJKS");
|
||||
fail("expected 'client' alias for RSA type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,9 +363,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("server-ecc")) {
|
||||
if (!alias.equals("server-ecc") && !alias.equals("ca-ecc")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,9 +412,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("client")) {
|
||||
if (!alias.equals("client") && !alias.equals("ca")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'client' alias for RSA type from allJKS");
|
||||
fail("expected 'client' alias for RSA type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,9 +425,9 @@ public class WolfSSLKeyX509Test {
|
|||
/* Note: this is very dependent on the contents and ordering of
|
||||
* all.jks. If that file is re-generated or changed, this test may
|
||||
* need to be updated */
|
||||
if (!alias.equals("server-ecc")) {
|
||||
if (!alias.equals("server-ecc") && !alias.equals("ca-ecc")) {
|
||||
error("\t... failed");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS");
|
||||
fail("expected 'server-ecc' alias for EC type from allJKS, got: " + alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -829,11 +829,13 @@ public class WolfSSLSocketTest {
|
|||
{
|
||||
private int serverPort;
|
||||
private CountDownLatch serverOpenLatch = null;
|
||||
private int clientConnections = 1;
|
||||
|
||||
public InternalMultiThreadedSSLSocketServer(
|
||||
int port, CountDownLatch openLatch) {
|
||||
int port, CountDownLatch openLatch, int clientConnections) {
|
||||
this.serverPort = port;
|
||||
serverOpenLatch = openLatch;
|
||||
this.clientConnections = clientConnections;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -843,11 +845,12 @@ public class WolfSSLSocketTest {
|
|||
SSLServerSocket ss = (SSLServerSocket)ctx
|
||||
.getServerSocketFactory().createServerSocket(serverPort);
|
||||
|
||||
while (true) {
|
||||
while (clientConnections > 0) {
|
||||
serverOpenLatch.countDown();
|
||||
SSLSocket sock = (SSLSocket)ss.accept();
|
||||
ClientHandler client = new ClientHandler(sock);
|
||||
client.start();
|
||||
clientConnections--;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -982,10 +985,17 @@ public class WolfSSLSocketTest {
|
|||
|
||||
System.out.print("\tTesting ExtendedThreadingUse");
|
||||
|
||||
/* This test hangs on Android, marking TODO for later investigation. Seems to be
|
||||
* something specific to the test code, not library proper. */
|
||||
if (tf.isAndroid()) {
|
||||
System.out.println("\t... skipped");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Start up simple TLS test server */
|
||||
CountDownLatch serverOpenLatch = new CountDownLatch(1);
|
||||
InternalMultiThreadedSSLSocketServer server =
|
||||
new InternalMultiThreadedSSLSocketServer(svrPort, serverOpenLatch);
|
||||
new InternalMultiThreadedSSLSocketServer(svrPort, serverOpenLatch, numThreads);
|
||||
server.start();
|
||||
|
||||
/* Wait for server thread to start up before connecting clients */
|
||||
|
|
|
@ -858,6 +858,9 @@ class WolfSSLTestFactory {
|
|||
|
||||
/* make sure protocol has not been disabled at system level */
|
||||
secProp = Security.getProperty(prop);
|
||||
if (secProp == null) {
|
||||
return false;
|
||||
}
|
||||
/* Remove spaces after commas, split into List */
|
||||
secProp = secProp.replaceAll(", ",",");
|
||||
propList = Arrays.asList(secProp.split(","));
|
||||
|
|
|
@ -90,9 +90,12 @@ public class WolfSSLCertificateTest {
|
|||
|
||||
cliCertDer = WolfSSLTestCommon.getPath(cliCertDer);
|
||||
cliCertPem = WolfSSLTestCommon.getPath(cliCertPem);
|
||||
cliKeyDer = WolfSSLTestCommon.getPath(cliKeyDer);
|
||||
cliKeyPubDer = WolfSSLTestCommon.getPath(cliKeyPubDer);
|
||||
caCertPem = WolfSSLTestCommon.getPath(caCertPem);
|
||||
caKeyDer = WolfSSLTestCommon.getPath(caKeyDer);
|
||||
caKeyPkcs8Der = WolfSSLTestCommon.getPath(caKeyPkcs8Der);
|
||||
serverCertPem = WolfSSLTestCommon.getPath(serverCertPem);
|
||||
external = WolfSSLTestCommon.getPath(external);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,9 @@ public class WolfSSLContextTest {
|
|||
|
||||
cliCert = WolfSSLTestCommon.getPath(cliCert);
|
||||
cliKey = WolfSSLTestCommon.getPath(cliKey);
|
||||
svrCertEcc = WolfSSLTestCommon.getPath(svrCertEcc);
|
||||
caCert = WolfSSLTestCommon.getPath(caCert);
|
||||
dhParams = WolfSSLTestCommon.getPath(dhParams);
|
||||
|
||||
test_WolfSSLContext_new(WolfSSL.SSLv23_ServerMethod());
|
||||
test_WolfSSLContext_useCertificateFile();
|
||||
|
|
Loading…
Reference in New Issue