Skip to content

Commit

Permalink
Move DropwizardSSLConnectionSocketFactoryTest to io.dropwizard.client (
Browse files Browse the repository at this point in the history
…dropwizard#3657)

This puts it in the same package as the class it's testing, which lets us expose the HostnameVerifier to the tests without relying on reflection of a private field.
  • Loading branch information
rhowe committed Jan 18, 2021
1 parent aa9f895 commit b476ef8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Expand Up @@ -29,7 +29,7 @@ public class DropwizardSSLConnectionSocketFactory {
private final TlsConfiguration configuration;

@Nullable
private final HostnameVerifier verifier;
final HostnameVerifier verifier;

public DropwizardSSLConnectionSocketFactory(TlsConfiguration configuration) {
this(configuration, null);
Expand Down
@@ -1,17 +1,14 @@
package io.dropwizard.client.ssl;
package io.dropwizard.client;

import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.client.DropwizardSSLConnectionSocketFactory;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.client.JerseyClientConfiguration;
import io.dropwizard.client.ssl.TlsConfiguration;
import io.dropwizard.setup.Environment;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import io.dropwizard.util.Duration;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLInitializationException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
Expand All @@ -35,7 +32,6 @@
import javax.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.SocketException;
import java.security.Security;
import java.util.Collections;
Expand Down Expand Up @@ -115,13 +111,8 @@ void setUp() {
}

@Test
void configOnlyConstructorShouldSetNullCustomVerifier() throws Exception {
final DropwizardSSLConnectionSocketFactory socketFactory;
socketFactory = new DropwizardSSLConnectionSocketFactory(tlsConfiguration);

final Field verifierField =
FieldUtils.getField(DropwizardSSLConnectionSocketFactory.class, "verifier", true);
assertThat(verifierField.get(socketFactory)).isNull();
void configOnlyConstructorShouldSetNullCustomVerifier() {
assertThat(new DropwizardSSLConnectionSocketFactory(tlsConfiguration).verifier).isNull();
}

@Test
Expand Down

0 comments on commit b476ef8

Please sign in to comment.