mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-11-30 00:56:50 +00:00
Always release SslContext during test teardown
This commit is contained in:
1 parent
56b7cdb179
commit
db4ad89a5d
3 files changed
+23
-2
No files matched your search
+3
@@ -6,11 +6,14 @@ package org.whispersystems.textsecuregcm.grpc.net;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import io.netty.util.test.LeakPresenceExtension;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
@ExtendWith(LeakPresenceExtension.class)
|
||||
class BoringSslServerKeyManagerTest {
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
@@ -30,6 +30,8 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import io.netty.pkitesting.CertificateBuilder;
|
||||
import io.netty.pkitesting.X509Bundle;
|
||||
import io.netty.util.Mapping;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import io.netty.util.test.LeakPresenceExtension;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.KeyStore;
|
||||
@@ -53,11 +55,13 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@ExtendWith(LeakPresenceExtension.class)
|
||||
class SniMapperTest {
|
||||
|
||||
// Configuration for precomputed keystore blob defined in sni-mapper-test-keystore.p12
|
||||
@@ -139,6 +143,10 @@ class SniMapperTest {
|
||||
@AfterAll
|
||||
static void tearDownAfterAll() throws InterruptedException {
|
||||
eventLoopGroup.shutdownGracefully(1, 1000, TimeUnit.MILLISECONDS).sync();
|
||||
sniMappingsByProvider.values().forEach(sniMapping -> {
|
||||
ReferenceCountUtil.release(sniMapping.map(FOO_DOMAIN));
|
||||
ReferenceCountUtil.release(sniMapping.map(BAR_DOMAIN));
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
+12
-2
@@ -33,6 +33,8 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import io.netty.pkitesting.CertificateBuilder;
|
||||
import io.netty.pkitesting.X509Bundle;
|
||||
import io.netty.util.Mapping;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import io.netty.util.test.LeakPresenceExtension;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.KeyStore;
|
||||
@@ -51,9 +53,11 @@ import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
@ExtendWith(LeakPresenceExtension.class)
|
||||
class TlsHandshakeMetricsHandlerTest {
|
||||
|
||||
private static final String DOMAIN = "example.org";
|
||||
@@ -64,6 +68,7 @@ class TlsHandshakeMetricsHandlerTest {
|
||||
|
||||
private SimpleMeterRegistry meterRegistry;
|
||||
private SslContext clientSslContext;
|
||||
private Mapping<String, SslContext> sniMapping;
|
||||
private Channel serverChannel;
|
||||
|
||||
/// Completed by the server once the handshake event has passed the metrics handler
|
||||
@@ -108,6 +113,9 @@ class TlsHandshakeMetricsHandlerTest {
|
||||
if (serverChannel != null) {
|
||||
serverChannel.close().sync();
|
||||
}
|
||||
if (sniMapping != null) {
|
||||
ReferenceCountUtil.release(sniMapping.map(DOMAIN));
|
||||
}
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@@ -118,7 +126,8 @@ class TlsHandshakeMetricsHandlerTest {
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = SslProvider.class, names = {"JDK", "OPENSSL"})
|
||||
void handshake(final SslProvider sslProvider) throws Exception {
|
||||
final AtomicReference<Channel> lastServerChildChannel = startServer(buildSniMapping(sslProvider));
|
||||
sniMapping = buildSniMapping(sslProvider);
|
||||
final AtomicReference<Channel> lastServerChildChannel = startServer(sniMapping);
|
||||
connect(null);
|
||||
|
||||
assertEquals(1, getCount(true));
|
||||
@@ -130,7 +139,8 @@ class TlsHandshakeMetricsHandlerTest {
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = SslProvider.class, names = {"JDK", "OPENSSL"})
|
||||
void failedHandshake(final SslProvider sslProvider) throws Exception {
|
||||
startServer(buildSniMapping(sslProvider));
|
||||
sniMapping = buildSniMapping(sslProvider);
|
||||
startServer(sniMapping);
|
||||
|
||||
// The server only holds an Ed25519 key
|
||||
connect(new String[] { "rsa_pss_rsae_sha256" });
|
||||
|
||||
Reference in new issue
Block a user