use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotAdminServer.
@Test
public void testRestNonAdminsMustNotAdminServer() {
for (TestUser user : TestUser.NON_ADMINS) {
RestClientConfigurationBuilder userConfig = restBuilders.get(user);
RestClient client = getServerTest().rest().withClientConfiguration(userConfig).get();
assertStatus(FORBIDDEN, client.server().report());
assertStatus(FORBIDDEN, client.server().connectorStop("endpoint-default"));
assertStatus(FORBIDDEN, client.server().connectorStart("endpoint-default"));
assertStatus(FORBIDDEN, client.server().connectorIpFilterSet("endpoint-default", Collections.emptyList()));
assertStatus(FORBIDDEN, client.server().connectorIpFiltersClear("endpoint-default"));
assertStatus(FORBIDDEN, client.server().memory());
assertStatus(FORBIDDEN, client.server().env());
assertStatus(FORBIDDEN, client.server().configuration());
}
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotModifyCacheIgnores.
@Test
public void testRestNonAdminsMustNotModifyCacheIgnores() {
for (TestUser user : TestUser.NON_ADMINS) {
RestClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get();
assertStatus(FORBIDDEN, client.server().ignoreCache("default", "predefined"));
assertStatus(FORBIDDEN, client.server().unIgnoreCache("default", "predefined"));
}
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class GracefulShutdownRestartIT method testGracefulShutdownRestart.
@Test
public void testGracefulShutdownRestart() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC).persistence().addSingleFileStore().segmented(false);
RemoteCache<Object, Object> hotRod = SERVER_TEST.hotrod().withServerConfiguration(builder).create();
for (int i = 0; i < 100; i++) {
hotRod.put(String.format("k%03d", i), String.format("v%03d", i));
}
RestClientConfigurationBuilder restClientBuilder = new RestClientConfigurationBuilder().socketTimeout(RestClientConfigurationProperties.DEFAULT_SO_TIMEOUT * 60).connectionTimeout(RestClientConfigurationProperties.DEFAULT_CONNECT_TIMEOUT * 60);
RestClient rest = SERVER_TEST.rest().withClientConfiguration(restClientBuilder).get();
sync(rest.cluster().stop(), 5, TimeUnit.MINUTES);
ContainerInfinispanServerDriver serverDriver = (ContainerInfinispanServerDriver) SERVER.getServerDriver();
Eventually.eventually("Cluster did not shutdown within timeout", () -> (!serverDriver.isRunning(0) && !serverDriver.isRunning(1)), serverDriver.getTimeout(), 1, TimeUnit.SECONDS);
serverDriver.restartCluster();
for (int i = 0; i < 100; i++) {
assertEquals(String.format("v%03d", i), hotRod.get(String.format("k%03d", i)));
}
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RestAuthentication method testRestReadWrite.
@Test
public void testRestReadWrite() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
if (!mechanism.isEmpty()) {
builder.protocol(protocol).security().authentication().mechanism(mechanism).realm("default").username("all_user").password("all");
}
if (mechanism.isEmpty()) {
Exceptions.expectException(SecurityException.class, () -> SERVER_TEST.rest().withClientConfiguration(builder).create());
} else {
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestResponse response = sync(client.cache(SERVER_TEST.getMethodName()).post("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(client.cache(SERVER_TEST.getMethodName()).get("k1"));
assertEquals(200, response.getStatus());
assertEquals(protocol, response.getProtocol());
assertEquals("v1", response.getBody());
}
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method searchActions.
private void searchActions(TestUser user, String indexedCache, int status, int noContentStatus) {
RestClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get();
assertStatus(status, client.cache(indexedCache).clearSearchStats());
assertStatus(noContentStatus, client.cache(indexedCache).reindex());
assertStatus(noContentStatus, client.cache(indexedCache).clearIndex());
}
Aggregations