From 8baa978560e936fa43990c8b3acccf4d2ca1aaf0 Mon Sep 17 00:00:00 2001 From: Mariano Barrios Date: Sun, 7 Jul 2024 20:25:13 +0200 Subject: [PATCH] Remove problematic Netty native test --- build.gradle | 8 -- .../java/tlschannel/NettySslEngineTest.java | 96 ------------------- 2 files changed, 104 deletions(-) delete mode 100644 src/test/java/tlschannel/NettySslEngineTest.java diff --git a/build.gradle b/build.gradle index 0b3f0ff1..0e96fb15 100644 --- a/build.gradle +++ b/build.gradle @@ -17,8 +17,6 @@ java { } } -println(javaToolchain) - compileJava { if (javaToolchain != "8") { options.release = 8 @@ -43,12 +41,6 @@ dependencies { testImplementation 'org.slf4j:jul-to-slf4j:2.0.13' testRuntimeOnly 'ch.qos.logback:logback-classic:1.3.14' - // pinned due to netty-tcnative-boringssl-static being pinned - testImplementation 'io.netty:netty-buffer:4.1.73.Final' - testImplementation 'io.netty:netty-handler:4.1.73.Final' - // pinned: https://github.com/netty/netty-tcnative/issues/716 - testRuntimeOnly 'io.netty:netty-tcnative-boringssl-static:2.0.47.Final' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' diff --git a/src/test/java/tlschannel/NettySslEngineTest.java b/src/test/java/tlschannel/NettySslEngineTest.java deleted file mode 100644 index 27fdd7ae..00000000 --- a/src/test/java/tlschannel/NettySslEngineTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package tlschannel; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import io.netty.buffer.ByteBufAllocator; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.SslProvider; -import io.netty.handler.ssl.util.SimpleTrustManagerFactory; -import java.net.Socket; -import java.nio.ByteBuffer; -import java.nio.channels.ByteChannel; -import java.security.KeyStore; -import java.security.cert.X509Certificate; -import javax.net.ssl.*; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; - -@TestInstance(Lifecycle.PER_CLASS) -public class NettySslEngineTest { - - // dummy handshake as minimal sanity test - @Test - void testDummyHandshake() throws SSLException { - io.netty.handler.ssl.SslContext ctx = SslContextBuilder.forClient() - .sslProvider(SslProvider.OPENSSL) - .trustManager(dummyTrustManagerFactory) - .protocols("TLSv1.3") - .build(); - SSLEngine sslEngine = ctx.newEngine(ByteBufAllocator.DEFAULT, "test", 0); - - ClientTlsChannel channel = ClientTlsChannel.newBuilder(new DummyByteChannel(), sslEngine) - .withEncryptedBufferAllocator(new HeapBufferAllocator()) - .build(); - - assertThrows(NeedsWriteException.class, () -> channel.handshake()); - } - - private final TrustManagerFactory dummyTrustManagerFactory = new SimpleTrustManagerFactory() { - @Override - public void engineInit(KeyStore keyStore) {} - - @Override - public void engineInit(ManagerFactoryParameters params) {} - - @Override - public TrustManager[] engineGetTrustManagers() { - return new TrustManager[] {new DummyTrustManager()}; - } - }; - - private static class DummyByteChannel implements ByteChannel { - @Override - public boolean isOpen() { - return false; - } - - @Override - public void close() {} - - @Override - public int write(ByteBuffer src) { - return 0; - } - - @Override - public int read(ByteBuffer dst) { - return 0; - } - } - - private static class DummyTrustManager extends X509ExtendedTrustManager { - @Override - public void checkClientTrusted(X509Certificate[] certs, String s) {} - - @Override - public void checkServerTrusted(X509Certificate[] certs, String s) {} - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - @Override - public void checkClientTrusted(X509Certificate[] certs, String s, Socket socket) {} - - @Override - public void checkServerTrusted(X509Certificate[] certs, String s, Socket socket) {} - - @Override - public void checkClientTrusted(X509Certificate[] certs, String s, SSLEngine sslEngine) {} - - @Override - public void checkServerTrusted(X509Certificate[] certs, String s, SSLEngine sslEngine) {} - } -}