use of org.infinispan.rest.helper.RestServerHelper in project infinispan by infinispan.
the class IndexedCacheNonIndexedEntityTest method createCacheManager.
@Override
protected EmbeddedCacheManager createCacheManager() {
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder().nonClusteredDefault();
EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(gcb, getDefaultStandaloneCacheConfig(false));
restServer = new RestServerHelper(cm);
restServer.start(TestResourceTracker.getCurrentTestShortName() + "-" + cm.getAddress());
RestClientConfigurationBuilder clientConfigurationBuilder = new RestClientConfigurationBuilder();
clientConfigurationBuilder.addServer().host(restServer.getHost()).port(restServer.getPort());
client = RestClient.forConfiguration(clientConfigurationBuilder.build());
return cm;
}
use of org.infinispan.rest.helper.RestServerHelper in project infinispan by infinispan.
the class XSiteResourceTest method startServers.
@BeforeClass
public void startServers() {
sites.forEach(site -> {
String siteName = site.getSiteName();
EmbeddedCacheManager cm = site.cacheManagers().iterator().next();
RestServerHelper restServerHelper = new RestServerHelper(cm);
restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
restServerPerSite.put(siteName, restServerHelper);
RestClientConfiguration clientConfig = new RestClientConfigurationBuilder().addServer().host("127.0.0.1").port(restServerHelper.getPort()).build();
RestClient client = RestClient.forConfiguration(clientConfig);
clientPerSite.put(siteName, client);
});
}
use of org.infinispan.rest.helper.RestServerHelper 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.rest.helper.RestServerHelper in project infinispan by infinispan.
the class CacheResourceTest method testCORSAllOrigins.
@Test
public void testCORSAllOrigins() throws IOException {
RestServerHelper restServerHelper = null;
RestClient client = null;
try {
RestServerConfigurationBuilder restBuilder = new RestServerConfigurationBuilder();
restBuilder.cors().addNewRule().allowOrigins(new String[] { "*" });
restBuilder.host("localhost").port(0);
restServerHelper = RestServerHelper.defaultRestServer();
RestServerConfiguration build = restBuilder.build();
restServerHelper.withConfiguration(build).start("test");
client = restServerHelper.createClient();
RestResponse response = join(client.cache("default").get("test", singletonMap(ORIGIN.toString(), "http://host.example.com:5576")));
assertThat(response).containsAllHeaders("access-control-allow-origin");
} finally {
client.close();
if (restServerHelper != null)
restServerHelper.stop();
}
}
use of org.infinispan.rest.helper.RestServerHelper in project infinispan by infinispan.
the class AbstractRestResourceTest method createCacheManagers.
@Override
protected void createCacheManagers() throws Exception {
Security.doAs(ADMIN, () -> {
for (int i = 0; i < NUM_SERVERS; i++) {
GlobalConfigurationBuilder configForNode = getGlobalConfigForNode(i);
addClusterEnabledCacheManager(new GlobalConfigurationBuilder().read(configForNode.build()), getDefaultCacheBuilder(), TransportFlags.minimalXsiteFlags());
}
cacheManagers.forEach(this::defineCaches);
cacheManagers.forEach(cm -> cm.defineConfiguration("invalid", getDefaultCacheBuilder().encoding().mediaType(APPLICATION_OBJECT_TYPE).indexing().enabled(true).addIndexedEntities("invalid").build()));
serverStateManager = new DummyServerStateManager();
for (EmbeddedCacheManager cm : cacheManagers) {
BasicComponentRegistry bcr = SecurityActions.getGlobalComponentRegistry(cm).getComponent(BasicComponentRegistry.class.getName());
bcr.registerComponent(ServerStateManager.class, serverStateManager, false);
cm.getClassAllowList().addClasses(TestClass.class);
waitForClusterToForm(cm.getCacheNames().stream().filter(name -> {
try {
cm.getCache(name);
return true;
} catch (CacheConfigurationException ignored) {
return false;
}
}).toArray(String[]::new));
RestServerHelper restServerHelper = new RestServerHelper(cm);
if (isSecurityEnabled()) {
BasicAuthenticator basicAuthenticator = new BasicAuthenticator(new SimpleSecurityDomain(ADMIN, USER), REALM);
restServerHelper.withAuthenticator(basicAuthenticator);
}
if (ssl) {
restServerHelper.withKeyStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withTrustStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE);
}
restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
restServers.add(restServerHelper);
}
});
adminClient = RestClient.forConfiguration(getClientConfig("admin", "admin").build());
client = RestClient.forConfiguration(getClientConfig("user", "user").build());
}
Aggregations