|
| 1 | +#!/bin/bash |
| 2 | + |
1 | 3 | set -exo pipefail |
2 | 4 | MVOPTS="--batch-mode" |
3 | 5 | if [ "x$EX_MVN" == "x" ] ; then |
4 | 6 | EX_MVN=mvn |
5 | 7 | fi |
6 | 8 |
|
| 9 | +DISABLE_testNoExplicitEnabledProtocols="true" |
| 10 | +DISABLE_testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange="true" |
| 11 | +DISABLE_testCipherSuiteConverter="true" |
| 12 | +DISABLE_testAvailableProtocolsWithTLS13CipherSuites="true" |
| 13 | + |
| 14 | +function addIgnoreImport() { |
| 15 | + if ! grep -e "import org.junit.Ignore" "${1}" ; then #do not create duplicated imports |
| 16 | + sed "s/import org.junit.Test;/import org.junit.Test;import org.junit.Ignore;/" -i "${1}" |
| 17 | + fi |
| 18 | +} |
| 19 | + |
| 20 | +ignoredTests=0 |
| 21 | +function ignoreMethod() { |
| 22 | + local file=$(find -type f | grep "${2}.java$") |
| 23 | + grep -e "${1}[(]" "${file}" #check |
| 24 | + # do not inject ignore import if nothing will be sed |
| 25 | + addIgnoreImport "${file}" |
| 26 | + sed "s/${1}[(]/@Ignore ${1}(/g" -i "${file}" |
| 27 | + grep -e "@Ignore ${1}[(]" "${file}" #check |
| 28 | + let ignoredTests=$ignoredTests+1 |
| 29 | +} |
| 30 | + |
| 31 | + |
7 | 32 | # for generating patches |
8 | 33 | #GIT=git |
9 | 34 | GIT=echo |
10 | 35 |
|
| 36 | +VERSION=2.2.5.Final |
11 | 37 | rm -rf wildfly-openssl |
12 | 38 | mkdir wildfly-openssl |
13 | 39 | pushd wildfly-openssl |
14 | | - wget https://github.com/wildfly-security/wildfly-openssl/archive/1.1.1.Final.tar.gz |
15 | | - tar -xf 1.1.1.Final.tar.gz |
| 40 | + wget https://github.com/wildfly-security/wildfly-openssl/archive/refs/tags/${VERSION}.tar.gz |
| 41 | + tar -xf ${VERSION}.tar.gz |
16 | 42 | # generally the testsuite is poorly designed. see SSLTestUtils.java |
17 | 43 | # it reuses still same port, and do not release it in finally clausule, |
18 | 44 | # so although it uses setReuseAddress, any first fail will kill all subsequent tests |
19 | 45 | # as the port seems to survive junit's vm |
20 | | - pushd wildfly-openssl-1.1.1.Final |
| 46 | + pushd wildfly-openssl-${VERSION} |
21 | 47 | $GIT init |
22 | 48 | $GIT add * |
23 | 49 | $GIT commit . -m "initial commit" |
24 | | - f=`find -type f | grep BasicOpenSSLEngineTest.java$` |
25 | | - sed "s/import org.junit.Test;/import org.junit.Test;import org.junit.Ignore;/" -i $f |
26 | | - # this test fails with different crypto policies |
27 | | - sed "s/public void testNoExplicitEnabledProtocols/@Ignore public void testNoExplicitEnabledProtocols/g" -i $f |
28 | | - if [ "x$OTOOL_OS_VERSION" = "x7" -a "x$OTOOL_OS_NAME" = "xel" ] ; then |
29 | | - # tls v 1.0 is being removed |
30 | | - sed "s/public void testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange/@Ignore public void testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange/g" -i $f |
| 50 | + if [ "$DISABLE_testNoExplicitEnabledProtocols" = "true" ] ; then |
| 51 | + # this test fails with different crypto policies |
| 52 | + ignoreMethod "public void testNoExplicitEnabledProtocols" "BasicOpenSSLEngineTest" |
| 53 | + fi |
| 54 | + if [ "$DISABLE_testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange" = "true" ] ; then |
| 55 | + # tls v 1.0 is being removed |
| 56 | + ignoreMethod "public void testMultipleEnabledProtocolsWithClientProtocolWithinEnabledRange" "BasicOpenSSLEngineLegacyProtocolsTest" |
| 57 | + fi |
| 58 | + if [ "$DISABLE_testCipherSuiteConverter" = "true" ] ; then |
| 59 | + # this test fails with different crypto policies and there is no JNI at all. However to find wy it fials is interesting TODO. |
| 60 | + ignoreMethod "public void testCipherSuiteConverter" "SslCiphersTest" |
| 61 | + fi |
| 62 | + if [ "$DISABLE_testAvailableProtocolsWithTLS13CipherSuites" = "true" ] ; then |
| 63 | + # tls 1.3 |
| 64 | + ignoreMethod "public void testAvailableProtocolsWithTLS13CipherSuites" "SslCiphersTest" |
| 65 | + fi |
| 66 | + if [ $ignoredTests -gt 0 ] ; then |
| 67 | + $GIT commit . -m "disbaled $ignoredTests tests" |
| 68 | + else |
| 69 | + echo "No test ignored" |
31 | 70 | fi |
32 | | - f=`find -type f | grep SslCiphersTest.java$` |
33 | | - sed "s/import org.junit.Test;/import org.junit.Test;import org.junit.Ignore;/" -i $f |
34 | | - # this test fails with different crypto policies and there is no JNI at all. However to find wy it fials is interesting TODO. |
35 | | - sed "s/public void testCipherSuiteConverter/@Ignore public void testCipherSuiteConverter/g" -i $f |
36 | | - patch -p1 <<EOF |
37 | | ---- a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java |
38 | | -+++ a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java |
39 | | -@@ -41,8 +41,8 @@ |
40 | | - public class SSLTestUtils { |
41 | | - |
42 | | - public static final String HOST = System.getProperty("org.wildfly.openssl.test.host", "localhost"); |
43 | | -- public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", "7677")); |
44 | | -- public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", "7687")); |
45 | | -+ public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort())); |
46 | | -+ public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort())); |
47 | | - |
48 | | - private static KeyStore loadKeyStore(final String name) throws IOException { |
49 | | - final InputStream stream = BasicOpenSSLEngineTest.class.getClassLoader().getResourceAsStream(name); |
50 | | -@@ -165,6 +165,17 @@ |
51 | | - return out.toByteArray(); |
52 | | - } |
53 | | - |
54 | | -+ public static int findFreePort() { |
55 | | -+ try (ServerSocket socket = new ServerSocket(0)) { |
56 | | -+ int i = socket.getLocalPort(); |
57 | | -+ socket.close(); |
58 | | -+ Thread.sleep(1000); |
59 | | -+ return i; |
60 | | -+ } catch (Exception e) { |
61 | | -+ } |
62 | | -+ return -1; |
63 | | -+ } |
64 | | -+ |
65 | | - public static ServerSocket createServerSocket() throws IOException { |
66 | | - return createServerSocket(PORT); |
67 | | - } |
68 | | -EOF |
69 | | - $GIT commit . -m "excluded some tests" |
70 | | - patch -p1 <<EOF |
71 | | -diff --git a/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java b/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java |
72 | | -index 56d2357..f67442a 100644 |
73 | | ---- a/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java |
74 | | -+++ b/java/src/test/java/org/wildfly/openssl/AbstractOpenSSLTest.java |
75 | | -@@ -18,6 +18,7 @@ |
76 | | - package org.wildfly.openssl; |
77 | | - |
78 | | - import org.junit.BeforeClass; |
79 | | -+import org.junit.Before; |
80 | | - |
81 | | - /** |
82 | | - * @author Stuart Douglas |
83 | | -@@ -26,6 +27,12 @@ public class AbstractOpenSSLTest { |
84 | | - |
85 | | - private static boolean first = true; |
86 | | - |
87 | | -+ @Before |
88 | | -+ public void reinitPorts(){ |
89 | | -+ SSLTestUtils.resetPort(); |
90 | | -+ SSLTestUtils.resetSecondaryPort(); |
91 | | -+ } |
92 | | -+ |
93 | | - @BeforeClass |
94 | | - public static void setup() { |
95 | | - if(first) { |
96 | | -diff --git a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java b/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java |
97 | | -index f7a4261..8c4aa3d 100644 |
98 | | ---- a/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java |
99 | | -+++ b/java/src/test/java/org/wildfly/openssl/SSLTestUtils.java |
100 | | -@@ -41,8 +41,24 @@ import javax.net.ssl.TrustManagerFactory; |
101 | | - public class SSLTestUtils { |
102 | | - |
103 | | - public static final String HOST = System.getProperty("org.wildfly.openssl.test.host", "localhost"); |
104 | | -- public static final int PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort())); |
105 | | -- public static final int SECONDARY_PORT = Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort())); |
106 | | -+ public static int PORT = initPort(); |
107 | | -+ public static int SECONDARY_PORT = initSecondaryPort(); |
108 | | -+ |
109 | | -+ private static int initPort() { |
110 | | -+ return Integer.parseInt(System.getProperty("org.wildfly.openssl.test.port", ""+findFreePort())); |
111 | | -+ } |
112 | | -+ |
113 | | -+ private static int initSecondaryPort() { |
114 | | -+ return Integer.parseInt(System.getProperty("org.wildfly.openssl.test.secondary.port", ""+findFreePort())); |
115 | | -+ } |
116 | | -+ |
117 | | -+ public static void resetPort(){ |
118 | | -+ PORT=initPort(); |
119 | | -+ } |
120 | | -+ |
121 | | -+ public static void resetSecondaryPort(){ |
122 | | -+ SECONDARY_PORT=initSecondaryPort(); |
123 | | -+ } |
124 | | - |
125 | | - private static KeyStore loadKeyStore(final String name) throws IOException { |
126 | | - final InputStream stream = BasicOpenSSLEngineTest.class.getClassLoader().getResourceAsStream(name); |
127 | | -EOF |
128 | | - $GIT commit . -m "make port random/free for each method" |
129 | 71 | # it is better to set the libssl and libcrypto on our own |
130 | 72 | # the wildfly-openssl search is just tragic, and the excception throwns out of it are very missleading |
131 | 73 | # eg "not found ssl library" may be thrown from findCryptoLibray (where findSSL have passed fine) |
|
0 commit comments