Search in sources :

Example 1 with Protocol

use of org.infinispan.client.rest.configuration.Protocol 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);
    }
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Protocol(org.infinispan.client.rest.configuration.Protocol)

Aggregations

RestClient (org.infinispan.client.rest.RestClient)1 RestResponse (org.infinispan.client.rest.RestResponse)1 Protocol (org.infinispan.client.rest.configuration.Protocol)1 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)1