From 49ff35417b43f449b4346c5d90e0a8020b307f9b Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Wed, 2 Nov 2022 14:29:48 -0400 Subject: [PATCH 1/3] OpenSSLTest is not using the OpenSSL Provider Signed-off-by: Andriy Redko --- build.gradle | 6 ++++++ src/test/java/org/opensearch/security/ssl/SSLTest.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index e8978a2c85..0f4c00b638 100644 --- a/build.gradle +++ b/build.gradle @@ -58,6 +58,7 @@ plugins { id "org.gradle.test-retry" version "1.4.1" id 'eclipse' id "com.github.spotbugs" version "5.0.13" + id "com.google.osdetector" version "1.7.1" } allprojects { @@ -413,6 +414,11 @@ dependencies { testImplementation 'org.springframework:spring-beans:5.3.20' testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + // Only osx-x86_64, osx-aarch_64, linux-x86_64, linux-aarch_64, windows-x86_64 are available + if (osdetector.classifier in ["osx-x86_64", "osx-aarch_64", "linux-x86_64", "linux-aarch_64", "windows-x86_64"]) { + testImplementation "io.netty:netty-tcnative-classes:2.0.54.Final" + testImplementation "io.netty:netty-tcnative-boringssl-static:2.0.54.Final:${osdetector.classifier}" + } // JUnit build requirement testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0' // Kafka test execution diff --git a/src/test/java/org/opensearch/security/ssl/SSLTest.java b/src/test/java/org/opensearch/security/ssl/SSLTest.java index d150353aeb..65181d66b9 100644 --- a/src/test/java/org/opensearch/security/ssl/SSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/SSLTest.java @@ -89,9 +89,9 @@ public void testHttps() throws Exception { .put(SSLConfigConstants.SECURITY_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.SECURITY_SSL_HTTP_CLIENTAUTH_MODE, "REQUIRE") .putList(SSLConfigConstants.SECURITY_SSL_HTTP_ENABLED_PROTOCOLS, "TLSv1.1", "TLSv1.2") - .putList(SSLConfigConstants.SECURITY_SSL_HTTP_ENABLED_CIPHERS, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256") + .putList(SSLConfigConstants.SECURITY_SSL_HTTP_ENABLED_CIPHERS, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256") .putList(SSLConfigConstants.SECURITY_SSL_TRANSPORT_ENABLED_PROTOCOLS, "TLSv1.1", "TLSv1.2") - .putList(SSLConfigConstants.SECURITY_SSL_TRANSPORT_ENABLED_CIPHERS, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256") + .putList(SSLConfigConstants.SECURITY_SSL_TRANSPORT_ENABLED_CIPHERS, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256") .put(SSLConfigConstants.SECURITY_SSL_HTTP_KEYSTORE_FILEPATH, FileHelper.getAbsoluteFilePathFromClassPath("ssl/node-0-keystore.jks")) .put(SSLConfigConstants.SECURITY_SSL_HTTP_TRUSTSTORE_FILEPATH, FileHelper.getAbsoluteFilePathFromClassPath("ssl/truststore.jks")) .build(); From 56115da50ea3c0660cad06148d3c1d665b50047f Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 8 Dec 2022 12:23:46 -0500 Subject: [PATCH 2/3] Enable OpenSSLTest on Windows Signed-off-by: Andriy Redko --- src/test/java/org/opensearch/security/ssl/OpenSSLTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java index 6990df9ea7..6d473c0160 100644 --- a/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java +++ b/src/test/java/org/opensearch/security/ssl/OpenSSLTest.java @@ -66,7 +66,6 @@ public static void restoreNettyDefaultAllocator() { @Before public void setup() { - Assume.assumeFalse(PlatformDependent.isWindows()); allowOpenSSL = true; } From edf89c259da03c28d56245c5142f1cb8b7ec6e62 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 8 Dec 2022 16:00:39 -0500 Subject: [PATCH 3/3] Extracted OpenSSL test into separate task to eliminate mess with system properties Signed-off-by: Andriy Redko --- build.gradle | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0f4c00b638..85c7f73dca 100644 --- a/build.gradle +++ b/build.gradle @@ -122,6 +122,7 @@ test { include '**/*.class' filter { excludeTestsMatching "org.opensearch.security.sanity.tests.*" + excludeTestsMatching "org.opensearch.security.ssl.OpenSSL*" } maxParallelForks = 8 jvmArgs += "-Xmx3072m" @@ -149,13 +150,37 @@ test { } } +//add new task that runs OpenSSL tests +task opensslTest(type: Test) { + include '**/OpenSSL*.class' + retry { + failOnPassedAfterRetry = false + maxRetries = 5 + } + jacoco { + excludes = [ + "com.sun.jndi.dns.*", + "com.sun.security.sasl.gsskerb.*", + "java.sql.*", + "javax.script.*", + "org.jcp.xml.dsig.internal.dom.*", + "sun.nio.cs.ext.*", + "sun.security.ec.*", + "sun.security.jgss.*", + "sun.security.pkcs11.*", + "sun.security.smartcardio.*", + "sun.util.resources.provider.*" + ] + } +} + task copyExtraTestResources(dependsOn: testClasses) { copy { from 'src/test/resources' into 'build/testrun/test/src/test/resources' } } -tasks.test.dependsOn(copyExtraTestResources) +tasks.test.dependsOn(copyExtraTestResources, opensslTest) jacoco { reportsDirectory = file("$buildDir/reports/jacoco")