Search in sources :

Example 56 with RestClientConfigurationBuilder

use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.

the class AuthenticationKerberosIT method testRest.

public void testRest(Protocol protocol) {
    RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
    if (!mechanism.isEmpty()) {
        builder.protocol(protocol).security().authentication().mechanism(mechanism).clientSubject(Common.createSubject("admin", "INFINISPAN.ORG", "strongPassword".toCharArray()));
    }
    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());
    }
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient)

Aggregations

RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)56 Test (org.junit.Test)26 RestClient (org.infinispan.client.rest.RestClient)25 RestResponse (org.infinispan.client.rest.RestResponse)22 RestClientConfiguration (org.infinispan.client.rest.configuration.RestClientConfiguration)8 RestServerHelper (org.infinispan.rest.helper.RestServerHelper)6 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)5 InetSocketAddress (java.net.InetSocketAddress)4 RestCacheClient (org.infinispan.client.rest.RestCacheClient)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)4 RestServer (org.infinispan.rest.RestServer)4 RestServerConfigurationBuilder (org.infinispan.rest.configuration.RestServerConfigurationBuilder)4 AbstractRestResourceTest (org.infinispan.rest.resources.AbstractRestResourceTest)4 DummyServerManagement (org.infinispan.server.core.DummyServerManagement)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 RestEntity (org.infinispan.client.rest.RestEntity)3 Json (org.infinispan.commons.dataconversion.internal.Json)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 Router (org.infinispan.server.router.Router)3