use of org.infinispan.client.rest.RestResponse 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.RestResponse in project infinispan by infinispan.
the class AuthenticationMultiEndpointIT method testRest.
private void testRest() {
Protocol proto = Protocol.valueOf(protocol);
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder().followRedirects(false);
if (useAuth) {
builder.protocol(proto).security().authentication().mechanism(mechanism).realm(realm).username(userPrefix + "all_user").password("all");
}
try {
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).withPort(port).create();
validateSuccess();
RestResponse response = sync(client.cache(SERVER_TEST.getMethodName()).post("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(proto, response.getProtocol());
response = sync(client.cache(SERVER_TEST.getMethodName()).get("k1"));
assertEquals(200, response.getStatus());
assertEquals(proto, response.getProtocol());
assertEquals("v1", response.getBody());
response = sync(client.raw().get("/"));
assertEquals(isAdmin ? 307 : 404, response.getStatus());
response = sync(client.server().info());
assertEquals(isAdmin ? 200 : 404, response.getStatus());
} catch (SecurityException e) {
validateException(e);
}
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class RestOperations method taskFilter.
@Test
public void taskFilter() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.protocol(protocol);
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestResponse tasks = sync(client.tasks().list(ResultType.USER));
List<Json> taskListNode = Json.read(tasks.getBody()).asJsonList();
taskListNode.forEach(n -> assertFalse(n.at("name").asString().startsWith("@@")));
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class RestOperations method testRestOperations.
@Test
public void testRestOperations() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.protocol(protocol);
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestCacheClient cache = client.cache(SERVER_TEST.getMethodName());
RestResponse response = sync(cache.put("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(cache.get("k1"));
assertEquals(200, response.getStatus());
assertEquals(protocol, response.getProtocol());
assertEquals("v1", response.getBody());
response = sync(cache.remove("k1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(cache.get("k1"));
assertEquals(404, response.getStatus());
assertEquals(protocol, response.getProtocol());
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class RestServerResource method testCacheManagerNames.
@Test
public void testCacheManagerNames() {
RestClient client = SERVER_TEST.rest().create();
RestResponse restResponse = sync(client.cacheManagers());
assertEquals(200, restResponse.getStatus());
Json cacheManagers = Json.read(restResponse.getBody());
Set<String> cmNames = cacheManagers.asJsonList().stream().map(Json::asString).collect(Collectors.toSet());
assertEquals(cmNames, Sets.newHashSet("default"));
}
Aggregations