zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] arankin-irl commented on a change in pull request #728: ZOOKEEPER-3160: Custom User SSLContext
Date Fri, 18 Jan 2019 08:54:41 GMT
arankin-irl commented on a change in pull request #728: ZOOKEEPER-3160: Custom User SSLContext
URL: https://github.com/apache/zookeeper/pull/728#discussion_r248965659
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/common/X509UtilTest.java
 ##########
 @@ -406,26 +407,30 @@ public void testGetSslHandshakeDetectionTimeoutMillisProperty() {
         }
     }
 
+    @Test(expected = X509Exception.SSLContextException.class)
+    public void testCreateSSLContext_invalidCustomSSLContextClass() throws Exception {
+        ZKConfig zkConfig = new ZKConfig();
+        ClientX509Util clientX509Util = new ClientX509Util();
+        zkConfig.setProperty(clientX509Util.getSslContextSupplierClassProperty(), String.class.getCanonicalName());
+        clientX509Util.createSSLContext(zkConfig);
+    }
+
     @Test
-    public void testCreateSSLContext_invalidCustomSSLContextClass() {
+    public void testCreateSSLContext_validNullCustomSSLContextClass() throws X509Exception.SSLContextException
{
         ZKConfig zkConfig = new ZKConfig();
         ClientX509Util clientX509Util = new ClientX509Util();
-        zkConfig.setProperty(clientX509Util.getSslClientContextProperty(), String.class.getCanonicalName());
-        try {
-            clientX509Util.createSSLContext(zkConfig);
-            fail("SSLContextException expected.");
-        } catch (X509Exception.SSLContextException e) {
-            assertTrue(e.getMessage().contains(clientX509Util.getSslClientContextProperty()));
-        }
+        zkConfig.setProperty(clientX509Util.getSslContextSupplierClassProperty(), X509UtilTest.class.getCanonicalName()
+ "$" + NullSslContextSupplier.class.getSimpleName());
+        final SSLContext sslContext = clientX509Util.createSSLContext(zkConfig);
+        assertNull(sslContext);
     }
 
     @Test
     public void testCreateSSLContext_validCustomSSLContextClass() throws X509Exception.SSLContextException
{
         ZKConfig zkConfig = new ZKConfig();
         ClientX509Util clientX509Util = new ClientX509Util();
-        zkConfig.setProperty(clientX509Util.getSslClientContextProperty(), ZKTestClientSSLContext.class.getCanonicalName());
+        zkConfig.setProperty(clientX509Util.getSslContextSupplierClassProperty(), X509UtilTest.class.getCanonicalName()
+ "$" + SslContextSupplier.class.getSimpleName());
         final SSLContext sslContext = clientX509Util.createSSLContext(zkConfig);
-        assertNull(sslContext);
+        assertNotNull(sslContext);
 
 Review comment:
   Good point - getDefault() returns a singleton representing the default SSLContext, so it'll
be the same object.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message