Author: markt Date: Thu Dec 17 20:09:25 2015 New Revision: 1720640 URL: http://svn.apache.org/viewvc?rev=1720640&view=rev Log: Refactor testing to take account of OpenSSL giving equal preference to some ciphers.
Modified: tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParser.java tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParserOnly.java Modified: tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParser.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParser.java?rev=1720640&r1=1720639&r2=1720640&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParser.java (original) +++ tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParser.java Thu Dec 17 20:09:25 2015 @@ -660,16 +660,26 @@ public class TestOpenSSLCipherConfigurat TesterOpenSSL.removeUnimplementedCiphersJsse(jsseCipherListFromParser); - Assert.assertEquals("Tested '" + specification + "': ", - listToString(jsseCipherListFromOpenSSL), listToString(jsseCipherListFromParser)); + // First check the lists have the same entries + Assert.assertEquals(jsseCipherListFromOpenSSL.size(), jsseCipherListFromParser.size()); + Assert.assertTrue(jsseCipherListFromOpenSSL.containsAll(jsseCipherListFromParser)); + + // OpenSSL treats many ciphers as having equal preference. The order + // returned depends on the order they are requested. The following code + // checks that the Parser produces a cipher list that is consistent with + // OpenSSL's preference order by confirming that running through OPenSSL + // does not change the order. + String parserOrderedExpression = listToString(jsseCipherListFromParser, ':'); + Assert.assertEquals(TesterOpenSSL.getOpenSSLCiphersAsExpression( + parserOrderedExpression), parserOrderedExpression); } - private String listToString(List<String> list) { + private String listToString(List<String> list, char separator) { StringBuilder sb = new StringBuilder(); for (String entry : list) { sb.append(entry); - sb.append(','); + sb.append(separator); } return sb.toString(); } Modified: tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParserOnly.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParserOnly.java?rev=1720640&r1=1720639&r2=1720640&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParserOnly.java (original) +++ tomcat/trunk/test/org/apache/tomcat/util/net/openssl/ciphers/TestOpenSSLCipherConfigurationParserOnly.java Thu Dec 17 20:09:25 2015 @@ -53,7 +53,7 @@ public class TestOpenSSLCipherConfigurat public void testDefaultSort02() throws Exception { // Reproducing a failure observed on Gump with OpenSSL 1.1.x - // ECHDE beats AES + // ECHDE should beat AES LinkedHashSet<Cipher> input = new LinkedHashSet<>(); input.add(Cipher.TLS_RSA_WITH_AES_256_CBC_SHA); input.add(Cipher.TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org