use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class DropwizardSSLConnectionSocketFactoryTest method shouldErrorIfHostnameVerificationOnAndServerHostnameMatchesAndFailVerifierSpecified.
@Test
public void shouldErrorIfHostnameVerificationOnAndServerHostnameMatchesAndFailVerifierSpecified() throws Exception {
final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).using(new FailVerifier()).build("bad_host_broken_fail_verifier");
final Throwable exn = catchThrowable(() -> client.target(String.format("https://localhost:%d", TLS_APP_RULE.getLocalPort())).request().get());
assertThat(exn).hasCauseExactlyInstanceOf(SSLPeerUnverifiedException.class);
assertThat(exn.getCause()).hasMessage("Certificate for <localhost> doesn't match any of the subject alternative names: []");
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class DropwizardSSLConnectionSocketFactoryTest method shouldErrorIfHostnameVerificationOnAndServerHostnameDoesntMatch.
@Test
public void shouldErrorIfHostnameVerificationOnAndServerHostnameDoesntMatch() throws Exception {
final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("bad_host_broken");
final Throwable exn = catchThrowable(() -> client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(3))).request().get());
assertThat(exn).hasCauseExactlyInstanceOf(SSLPeerUnverifiedException.class);
assertThat(exn.getCause()).hasMessage("Certificate for <localhost> doesn't match any of the subject alternative names: []");
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class DropwizardSSLConnectionSocketFactoryTest method shouldErrorIfClientAuthFails.
@Test
public void shouldErrorIfClientAuthFails() throws Exception {
tlsConfiguration.setKeyStorePath(new File(ResourceHelpers.resourceFilePath("stores/server/self_sign_keycert.p12")));
tlsConfiguration.setKeyStorePassword("password");
tlsConfiguration.setKeyStoreType("PKCS12");
final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).build("client_auth_broken");
final Throwable exn = catchThrowable(() -> client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(2))).request().get());
assertThat(exn).isInstanceOf(ProcessingException.class);
assertThat(exn.getCause()).isInstanceOfAny(SocketException.class, SSLHandshakeException.class);
}
use of io.dropwizard.client.JerseyClientBuilder in project dropwizard by dropwizard.
the class DropwizardSSLConnectionSocketFactoryTest method shouldBeOkIfHostnameVerificationOnAndServerHostnameDoesntMatchAndNoopVerifierSpecified.
@Test
public void shouldBeOkIfHostnameVerificationOnAndServerHostnameDoesntMatchAndNoopVerifierSpecified() throws Exception {
final Client client = new JerseyClientBuilder(TLS_APP_RULE.getEnvironment()).using(jerseyClientConfiguration).using(new NoopHostnameVerifier()).build("bad_host_noop_verifier_working");
final Response response = client.target(String.format("https://localhost:%d", TLS_APP_RULE.getPort(3))).request().get();
assertThat(response.getStatus()).isEqualTo(200);
}
use of io.dropwizard.client.JerseyClientBuilder in project textdb by TextDB.
the class NewQueryPlanResourceTest method checkSampleEndpoint.
/**
* Tests the query plan execution endpoint.
*/
@Test
public void checkSampleEndpoint() throws Exception {
Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
client.property(ClientProperties.CONNECT_TIMEOUT, 5000);
client.property(ClientProperties.READ_TIMEOUT, 5000);
Response response = client.target(String.format(queryPlanEndpoint, RULE.getLocalPort())).request().post(Entity.entity(new ObjectMapper().writeValueAsString(getLogicalPlan1()), MediaType.APPLICATION_JSON));
System.out.println("resposne is: " + response);
assertThat(response.getStatus()).isEqualTo(200);
}
Aggregations