use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method assertXSiteOps.
private void assertXSiteOps(TestUser user, int status, int noContentStatus, int notModifiedStatus) {
RestClientConfigurationBuilder userConfig = restBuilders.get(user);
RestClient client = getServerTest().rest().withClientConfiguration(userConfig).get();
RestCacheClient xsiteCache = client.cache("xsite");
assertStatus(status, xsiteCache.takeSiteOffline("NYC"));
assertStatus(status, xsiteCache.bringSiteOnline("NYC"));
assertStatus(status, xsiteCache.cancelPushState("NYC"));
assertStatus(status, xsiteCache.cancelReceiveState("NYC"));
assertStatus(status, xsiteCache.clearPushStateStatus());
assertStatus(status, xsiteCache.pushSiteState("NYC"));
assertStatus(status, xsiteCache.pushStateStatus());
assertStatus(status, xsiteCache.xsiteBackups());
assertStatus(status, xsiteCache.backupStatus("NYC"));
assertStatus(status, xsiteCache.getXSiteTakeOfflineConfig("NYC"));
assertStatus(noContentStatus, xsiteCache.updateXSiteTakeOfflineConfig("NYC", 10, 1000));
assertStatus(status, xsiteCache.xSiteStateTransferMode("NYC"));
assertStatus(notModifiedStatus, xsiteCache.xSiteStateTransferMode("NYC", XSiteStateTransferMode.MANUAL));
RestCacheManagerClient xsiteCacheManager = client.cacheManager("default");
assertStatus(status, xsiteCacheManager.bringBackupOnline("NYC"));
assertStatus(status, xsiteCacheManager.takeOffline("NYC"));
assertStatus(status, xsiteCacheManager.backupStatuses());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotPerformSearchActions.
@Test
public void testRestNonAdminsMustNotPerformSearchActions() {
String schema = Exceptions.unchecked(() -> Util.getResourceAsString("/sample_bank_account/bank.proto", this.getClass().getClassLoader()));
assertStatus(OK, getServerTest().rest().withClientConfiguration(restBuilders.get(TestUser.ADMIN)).get().schemas().put(BANK_PROTO, schema));
org.infinispan.configuration.cache.ConfigurationBuilder builder = new org.infinispan.configuration.cache.ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
builder.indexing().enable().addIndexedEntity("sample_bank_account.User").statistics().enable();
RestClient restClient = getServerTest().rest().withClientConfiguration(restBuilders.get(TestUser.ADMIN)).withServerConfiguration(builder).create();
String indexedCache = getServerTest().getMethodName();
RestCacheClient cache = restClient.cache(indexedCache);
for (TestUser user : TestUser.NON_ADMINS) {
searchActions(user, indexedCache, FORBIDDEN, FORBIDDEN);
}
searchActions(TestUser.ADMIN, indexedCache, OK, NO_CONTENT);
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthorization method testAnonymousHealthPredefinedCache.
@Test
public void testAnonymousHealthPredefinedCache() {
RestClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(TestUser.ANONYMOUS)).get();
assertEquals("HEALTHY", sync(client.cacheManager("default").healthStatus()).getBody());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class StatefulSetRollingUpgradeIT method assertLiveness.
private void assertLiveness(int server) {
RestClient rest = methodRule.rest().get(server);
RestResponse rsp = sync(rest.cacheManager(CACHE_MANAGER).healthStatus(), 10, TimeUnit.SECONDS);
assertEquals(HttpResponseStatus.OK.code(), rsp.getStatus());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class AbstractAuthenticationKeyCloak method testRestReadWrite.
@Test
public void testRestReadWrite() {
String token = getToken();
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.security().authentication().mechanism("BEARER_TOKEN").username(token);
RestClient client = getServerTest().rest().withClientConfiguration(builder).create();
RestResponse response = sync(client.cache(getServerTest().getMethodName()).post("k1", "v1"));
assertEquals(204, response.getStatus());
response = sync(client.cache(getServerTest().getMethodName()).get("k1"));
assertEquals(200, response.getStatus());
assertEquals("v1", response.getBody());
}
Aggregations