Search in sources :

Example 1 with TestCallbackHandler

use of org.infinispan.server.hotrod.test.TestCallbackHandler in project infinispan by infinispan.

the class AuthenticationTest method testAuthenticationFailWrongAuth.

@Test(expectedExceptions = TransportException.class)
public void testAuthenticationFailWrongAuth() {
    ConfigurationBuilder clientBuilder = newClientBuilder();
    clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("user", "realm", "foobar"));
    remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
    remoteCacheManager.getCache();
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) TestCallbackHandler(org.infinispan.server.hotrod.test.TestCallbackHandler) Test(org.testng.annotations.Test)

Example 2 with TestCallbackHandler

use of org.infinispan.server.hotrod.test.TestCallbackHandler in project infinispan by infinispan.

the class AuthenticationTest method testAuthentication.

@Test
public void testAuthentication() {
    ConfigurationBuilder clientBuilder = newClientBuilder();
    clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("user", "realm", "password"));
    remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
    RemoteCache<String, String> defaultRemote = remoteCacheManager.getCache();
    defaultRemote.put("a", "a");
    assertEquals("a", defaultRemote.get("a"));
}
Also used : ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) TestCallbackHandler(org.infinispan.server.hotrod.test.TestCallbackHandler) Test(org.testng.annotations.Test)

Example 3 with TestCallbackHandler

use of org.infinispan.server.hotrod.test.TestCallbackHandler in project infinispan by infinispan.

the class SecureExecTest method testSimpleScriptExecutionWithInvalidAuth.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = ".*Unauthorized access.*")
public void testSimpleScriptExecutionWithInvalidAuth() throws IOException, PrivilegedActionException {
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = newClientBuilder();
    clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("RWEuser", "realm", "password".toCharArray()));
    runTestWithGivenScript(clientBuilder.build(), "/testRole.js");
}
Also used : TestCallbackHandler(org.infinispan.server.hotrod.test.TestCallbackHandler) Test(org.testng.annotations.Test)

Example 4 with TestCallbackHandler

use of org.infinispan.server.hotrod.test.TestCallbackHandler in project infinispan by infinispan.

the class SecureExecTest method testSimpleScriptExecutionWithoutExecPerm.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = ".*Unauthorized access.*")
public void testSimpleScriptExecutionWithoutExecPerm() throws IOException, PrivilegedActionException {
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = newClientBuilder();
    clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("RWuser", "realm", "password".toCharArray()));
    runTestWithGivenScript(clientBuilder.build(), "/testWithoutRole.js");
}
Also used : TestCallbackHandler(org.infinispan.server.hotrod.test.TestCallbackHandler) Test(org.testng.annotations.Test)

Example 5 with TestCallbackHandler

use of org.infinispan.server.hotrod.test.TestCallbackHandler in project infinispan by infinispan.

the class SecureExecTest method testUploadWithoutScriptManagerRole.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = ".*Unauthorized access.*")
public void testUploadWithoutScriptManagerRole() throws IOException, PrivilegedActionException {
    org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = newClientBuilder();
    clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("RWEuser", "realm", "password".toCharArray()));
    remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
    remoteCacheManager.getCache(ScriptingManager.SCRIPT_CACHE).put("shouldFail", "1+1");
}
Also used : TestCallbackHandler(org.infinispan.server.hotrod.test.TestCallbackHandler) Test(org.testng.annotations.Test)

Aggregations

TestCallbackHandler (org.infinispan.server.hotrod.test.TestCallbackHandler)11 Test (org.testng.annotations.Test)7 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)4 HashMap (java.util.HashMap)1 SaslClient (javax.security.sasl.SaslClient)1 EventLogListener (org.infinispan.client.hotrod.event.EventLogListener)1 InternalRemoteCacheManager (org.infinispan.client.hotrod.test.InternalRemoteCacheManager)1 CacheNotifier (org.infinispan.notifications.cachelistener.CacheNotifier)1 HotRodServerConfigurationBuilder (org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder)1 TestAuthResponse (org.infinispan.server.hotrod.test.TestAuthResponse)1