tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1827297 - /tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java
Date Tue, 20 Mar 2018 11:58:21 GMT
Author: markt
Date: Tue Mar 20 11:58:20 2018
New Revision: 1827297

URL: http://svn.apache.org/viewvc?rev=1827297&view=rev
Log:
REfactor unit test to accept multiple commands

Modified:
    tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java

Modified: tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java?rev=1827297&r1=1827296&r2=1827297&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/openssl/TestOpenSSLConf.java Tue Mar 20 11:58:20
2018
@@ -39,7 +39,10 @@ public class TestOpenSSLConf extends Tom
     private static final String[] ENABLED_PROTOCOLS = {"TLSv1.1"};
     private static final String[] DISABLED_PROTOCOLS = {"SSLv3", "TLSv1", "TLSv1.2"};
 
-    public SSLHostConfig initOpenSSLConfCmdCipher(String name, String value) throws Exception
{
+    public SSLHostConfig initOpenSSLConfCmdCipher(String... commands) throws Exception {
+        Assert.assertNotNull(commands);
+        Assert.assertTrue("Invalid length", commands.length % 2 == 0);
+
         Tomcat tomcat = getTomcatInstance();
 
         TesterSupport.initSsl(tomcat);
@@ -53,11 +56,14 @@ public class TestOpenSSLConf extends Tom
                     sslImplementation.contains("openssl"));
         }
 
-        OpenSSLConfCmd cmd = new OpenSSLConfCmd();
-        cmd.setName(name);
-        cmd.setValue(value);
         OpenSSLConf conf = new OpenSSLConf();
-        conf.addCmd(cmd);
+        for (int i = 0; i < commands.length;) {
+            OpenSSLConfCmd cmd = new OpenSSLConfCmd();
+            cmd.setName(commands[i++]);
+            cmd.setValue(commands[i++]);
+            conf.addCmd(cmd);
+        }
+
         SSLHostConfig[] sslHostConfigs = tomcat.getConnector().
                                          getProtocolHandler().findSslHostConfigs();
         Assert.assertEquals("Wrong SSLHostConfigCount", 1, sslHostConfigs.length);
@@ -72,8 +78,7 @@ public class TestOpenSSLConf extends Tom
 
     @Test
     public void testOpenSSLConfCmdCipher() throws Exception {
-        SSLHostConfig sslHostConfig = initOpenSSLConfCmdCipher("CipherString",
-                                                               ENABLED_CIPHER);
+        SSLHostConfig sslHostConfig = initOpenSSLConfCmdCipher("CipherString", ENABLED_CIPHER);
         String[] ciphers = sslHostConfig.getEnabledCiphers();
         Assert.assertThat("Wrong HostConfig ciphers", ciphers,
                 CoreMatchers.is(EXPECTED_CIPHERS));
@@ -92,8 +97,7 @@ public class TestOpenSSLConf extends Tom
         for (String protocol : ENABLED_PROTOCOLS) {
             sb.append(",").append(protocol);
         }
-        SSLHostConfig sslHostConfig = initOpenSSLConfCmdCipher("Protocol",
-                                                               sb.substring(1));
+        SSLHostConfig sslHostConfig = initOpenSSLConfCmdCipher("Protocol", sb.substring(1));
         String[] protocols = sslHostConfig.getEnabledProtocols();
         for (String protocol : protocols) {
             Assert.assertFalse("Protocol " + protocol + " is not allowed",



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message