summaryrefslogtreecommitdiffstats
path: root/luni/src
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2014-04-09 09:22:13 -0700
committerKenny Root <kroot@google.com>2014-04-10 14:39:22 -0700
commit727df1258e3b8386afea4778626c9ab16ef467d6 (patch)
treed0ca628e355834d3a89bfcb5df139ed85c8a179a /luni/src
parent3ad1704dc8e4653f4ceaeb5d8315ddb28318a1bb (diff)
downloadlibcore-727df1258e3b8386afea4778626c9ab16ef467d6.zip
libcore-727df1258e3b8386afea4778626c9ab16ef467d6.tar.gz
libcore-727df1258e3b8386afea4778626c9ab16ef467d6.tar.bz2
Update SSLEngineTest for OpenSSL
Our new OpenSSL-based SSLEngine supports all the new stuff and no longer fails tests. Change-Id: I7db8e5134ca36ebd963c7081cd7ba79d91b3e5e2
Diffstat (limited to 'luni/src')
-rw-r--r--luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java50
1 files changed, 41 insertions, 9 deletions
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
index f8cee20..a7d0df2 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
@@ -82,9 +82,7 @@ public class SSLEngineTest extends TestCase {
.ca(true)
.build();
test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, false);
- if (StandardNames.IS_RI) {
- test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, true);
- }
+ test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, true);
}
private void test_SSLEngine_getSupportedCipherSuites_connect(TestKeyStore testKeyStore,
boolean secureRenegotiation)
@@ -133,8 +131,12 @@ public class SSLEngineTest extends TestCase {
testKeyStore.keyManagers[replaceIndex] = originalKeyManager;
}
+ // To catch all the errors.
+ StringBuilder error = new StringBuilder();
+
String[] cipherSuites = c.clientContext.createSSLEngine().getSupportedCipherSuites();
for (String cipherSuite : cipherSuites) {
+ try {
// Skip cipher suites that are obsoleted.
if (StandardNames.IS_RI && "TLSv1.2".equals(c.clientContext.getProtocol())
&& StandardNames.CIPHER_SUITES_OBSOLETE_TLS12.contains(cipherSuite)) {
@@ -201,8 +203,20 @@ public class SSLEngineTest extends TestCase {
assertNotConnected(p);
} catch (IOException expected) {}
}
+ } catch (Exception e) {
+ String message = ("Problem trying to connect cipher suite " + cipherSuite);
+ System.out.println(message);
+ e.printStackTrace();
+ error.append(message);
+ error.append('\n');
+ }
}
c.close();
+
+ if (error.length() > 0) {
+ throw new Exception("One or more problems in "
+ + "test_SSLEngine_getSupportedCipherSuites_connect:\n" + error);
+ }
}
private static void assertSendsCorrectly(final byte[] sourceBytes, SSLEngine source,
@@ -389,17 +403,34 @@ public class SSLEngineTest extends TestCase {
}
public void test_SSLEngine_setUseClientMode() throws Exception {
+ boolean[] finished;
+
// client is client, server is server
- assertConnected(test_SSLEngine_setUseClientMode(true, false));
+ finished = new boolean[2];
+ assertConnected(test_SSLEngine_setUseClientMode(true, false, finished));
+ assertTrue(finished[0]);
+ assertTrue(finished[1]);
// client is server, server is client
- assertConnected(test_SSLEngine_setUseClientMode(false, true));
+ finished = new boolean[2];
+ assertConnected(test_SSLEngine_setUseClientMode(false, true, finished));
+ assertTrue(finished[0]);
+ assertTrue(finished[1]);
// both are client
- assertNotConnected(test_SSLEngine_setUseClientMode(true, true));
+ /*
+ * Our implementation throws an SSLHandshakeException, but RI just
+ * stalls forever
+ */
+ try {
+ assertNotConnected(test_SSLEngine_setUseClientMode(true, true, null));
+ assertTrue(StandardNames.IS_RI);
+ } catch (SSLHandshakeException maybeExpected) {
+ assertFalse(StandardNames.IS_RI);
+ }
// both are server
- assertNotConnected(test_SSLEngine_setUseClientMode(false, false));
+ assertNotConnected(test_SSLEngine_setUseClientMode(false, false, null));
}
public void test_SSLEngine_setUseClientMode_afterHandshake() throws Exception {
@@ -419,7 +450,8 @@ public class SSLEngineTest extends TestCase {
}
private TestSSLEnginePair test_SSLEngine_setUseClientMode(final boolean clientClientMode,
- final boolean serverClientMode)
+ final boolean serverClientMode,
+ final boolean[] finished)
throws Exception {
TestSSLContext c;
if (!clientClientMode && serverClientMode) {
@@ -434,7 +466,7 @@ public class SSLEngineTest extends TestCase {
client.setUseClientMode(clientClientMode);
server.setUseClientMode(serverClientMode);
}
- });
+ }, finished);
}
public void test_SSLEngine_clientAuth() throws Exception {