use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestConnectorTest method testUrlWithoutCredentials.
@Test
public void testUrlWithoutCredentials() {
RestConnector connector = new RestConnector();
RestConnection connection = (RestConnection) connector.getConnection("http://localhost:11222", null);
RestClientConfigurationBuilder builder = connection.getBuilder();
RestClientConfiguration configuration = builder.build();
assertEquals(11222, configuration.servers().get(0).port());
assertEquals("localhost", configuration.servers().get(0).host());
assertFalse(configuration.security().authentication().enabled());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestConnectorTest method testUrlWithSSL.
@Test
public void testUrlWithSSL() throws NoSuchAlgorithmException {
RestConnector connector = new RestConnector();
RestConnection connection = (RestConnection) connector.getConnection("https://localhost", null);
RestClientConfigurationBuilder builder = connection.getBuilder();
builder.security().ssl().sslContext(SSLContext.getDefault()).trustManagers(new TrustManager[] { new ZeroSecurityTrustManager() });
RestClientConfiguration configuration = builder.build();
assertEquals(443, configuration.servers().get(0).port());
assertEquals("localhost", configuration.servers().get(0).host());
assertFalse(configuration.security().authentication().enabled());
assertTrue(configuration.security().ssl().enabled());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestConnectorTest method testPlainHostPort.
@Test
public void testPlainHostPort() {
RestConnector connector = new RestConnector();
RestConnection connection = (RestConnection) connector.getConnection("my.host.com:12345", null);
RestClientConfigurationBuilder builder = connection.getBuilder();
RestClientConfiguration configuration = builder.build();
assertEquals(12345, configuration.servers().get(0).port());
assertEquals("my.host.com", configuration.servers().get(0).host());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class CertificateTest method shouldAllowProperCertificate.
@Test
public void shouldAllowProperCertificate() throws Exception {
restServer = RestServerHelper.defaultRestServer().withAuthenticator(new ClientCertAuthenticator()).withKeyStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withTrustStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withClientAuth().start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder config = new RestClientConfigurationBuilder();
config.security().ssl().enable().trustStoreFileName(CLIENT_KEY_STORE).trustStorePassword(STORE_PASSWORD).trustStoreType(STORE_TYPE).keyStoreFileName(CLIENT_KEY_STORE).keyStorePassword(STORE_PASSWORD).keyStoreType(STORE_TYPE).hostnameVerifier((hostname, session) -> true).addServer().host("localhost").port(restServer.getPort());
client = RestClient.forConfiguration(config.build());
// when
CompletionStage<RestResponse> response = client.raw().get("/rest/v2/caches/default/test", Collections.emptyMap());
// then
assertEquals(404, response.toCompletableFuture().get(10, TimeUnit.MINUTES).getStatus());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class StaticResourceTest method createBeforeClass.
@BeforeClass(alwaysRun = true)
public void createBeforeClass() throws Throwable {
super.createBeforeClass();
RestClientConfigurationBuilder builder = super.getClientConfig("admin", "admin");
builder.followRedirects(false).addServer().host(restServer().getHost()).port(restServer().getPort());
noRedirectsClient = RestClient.forConfiguration(builder.build());
}
Aggregations