From 03814a0f775cee3003bba03d3617bcd5ea727d8b Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Wed, 10 Jun 2015 09:50:31 -0700 Subject: SSLSocketTest: add test with no ciphers If there are no ciphers set, there should just be a handshake failure. However, Conscrypt was throwing InvalidArgumentException in this configuration. (cherry picked from commit def50a267d0100fa560cf7bbcd0b9a9d5f5e068f) Bug: 21195269 Change-Id: I73cfc4927041ca9b1331b58859382573e7de6f63 --- .../java/libcore/javax/net/ssl/SSLSocketTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'luni') diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java index 8e4519d..56a639c 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java @@ -420,6 +420,37 @@ public class SSLSocketTest extends TestCase { c.close(); } + public void test_SSLSocket_NoEnabledCipherSuites_Failure() throws Exception { + TestSSLContext c = TestSSLContext.create(null, null, null, null, null, null, null, null, + SSLContext.getDefault(), SSLContext.getDefault()); + SSLSocket client = (SSLSocket) c.clientContext.getSocketFactory().createSocket(c.host, + c.port); + client.setEnabledCipherSuites(new String[0]); + final SSLSocket server = (SSLSocket) c.serverSocket.accept(); + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future future = executor.submit(new Callable() { + @Override + public Void call() throws Exception { + try { + server.startHandshake(); + fail(); + } catch (SSLHandshakeException expected) { + } + return null; + } + }); + executor.shutdown(); + try { + client.startHandshake(); + fail(); + } catch (SSLHandshakeException expected) { + } + future.get(); + server.close(); + client.close(); + c.close(); + } + public void test_SSLSocket_startHandshake_noKeyStore() throws Exception { TestSSLContext c = TestSSLContext.create(null, null, null, null, null, null, null, null, SSLContext.getDefault(), SSLContext.getDefault()); -- cgit v1.1