use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestAccessLoggingTest method setup.
@Override
protected void setup() throws Exception {
super.setup();
testShortName = TestResourceTracker.getCurrentTestShortName();
logAppender = new StringLogAppender("org.infinispan.REST_ACCESS_LOG", Level.TRACE, t -> t.getName().startsWith("non-blocking-thread-" + testShortName), PatternLayout.newBuilder().withPattern(LOG_FORMAT).build());
logAppender.install();
restServer = new RestServerHelper(cacheManager);
restServer.start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort());
restClient = RestClient.forConfiguration(builder.create());
cacheClient = restClient.cache("default");
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class AbstractRestResourceTest method getClientConfig.
protected RestClientConfigurationBuilder getClientConfig(String username, String password) {
RestClientConfigurationBuilder clientConfigurationBuilder = new RestClientConfigurationBuilder();
if (protocol != null) {
clientConfigurationBuilder.protocol(protocol);
}
if (ssl) {
clientConfigurationBuilder.security().ssl().enable().hostnameVerifier((hostname, session) -> true).trustStoreFileName(CLIENT_KEY_STORE).trustStorePassword(STORE_PASSWORD).trustStoreType(STORE_TYPE).keyStoreFileName(CLIENT_KEY_STORE).keyStorePassword(STORE_PASSWORD).keyStoreType(STORE_TYPE);
}
if (isSecurityEnabled()) {
clientConfigurationBuilder.security().authentication().enable().username(username).password(password);
}
restServers.forEach(s -> clientConfigurationBuilder.addServer().host(s.getHost()).port(s.getPort()));
return clientConfigurationBuilder;
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class Http2Test method shouldReportErrorCorrectly.
@Test
public void shouldReportErrorCorrectly() {
restServer = RestServerHelper.defaultRestServer().withKeyStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).withTrustStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder config = new RestClientConfigurationBuilder();
config.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(HTTP_20).priorKnowledge(true).security().ssl().enable().trustStoreFileName(KEY_STORE_PATH).trustStorePassword(STORE_PASSWORD).trustStoreType(STORE_TYPE).keyStoreFileName(KEY_STORE_PATH).keyStorePassword(STORE_PASSWORD).keyStoreType(STORE_TYPE).hostnameVerifier((hostname, session) -> true);
client = RestClient.forConfiguration(config.build());
CompletionStage<RestResponse> response = client.raw().get("/invalid");
ResponseAssertion.assertThat(response).isNotFound();
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class Http2Test method clearTextUpgrade.
private void clearTextUpgrade(boolean previousKnowledge) {
restServer = RestServerHelper.defaultRestServer().start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).priorKnowledge(previousKnowledge).protocol(Protocol.HTTP_20);
client = RestClient.forConfiguration(builder.build());
CompletionStage<RestResponse> response = client.cacheManager("default").info();
ResponseAssertion.assertThat(response).isOk();
RestEntity value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, "test".getBytes(CharsetUtil.UTF_8));
response = client.cache("defaultcache").post("test", value);
Assertions.assertThat(join(response).getStatus()).isEqualTo(204);
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class Http2Test method secureUpgradeTest.
private void secureUpgradeTest(Protocol choice) {
// given
restServer = RestServerHelper.defaultRestServer().withKeyStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(choice).security().ssl().trustStoreFileName(KEY_STORE_PATH).trustStorePassword(STORE_PASSWORD).hostnameVerifier((hostname, session) -> true);
client = RestClient.forConfiguration(builder.build());
RestEntity value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, "test".getBytes(CharsetUtil.UTF_8));
CompletionStage<RestResponse> response = client.cache("defaultcache").post("test", value);
// then
ResponseAssertion.assertThat(response).isOk();
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
Aggregations