use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ThinClientPermissionCheckTest method testSysOperation.
/**
*/
@Test
public void testSysOperation() throws Exception {
try (IgniteClient sysPrmClnt = startClient(CLIENT_SYS_PERM)) {
sysPrmClnt.createCache(DYNAMIC_CACHE);
assertTrue(sysPrmClnt.cacheNames().contains(DYNAMIC_CACHE));
sysPrmClnt.destroyCache(DYNAMIC_CACHE);
assertFalse(sysPrmClnt.cacheNames().contains(DYNAMIC_CACHE));
}
List<IgniteBiTuple<Consumer<IgniteClient>, String>> ops = Arrays.asList(t(c -> c.createCache(DYNAMIC_CACHE), "createCache"), t(c -> c.destroyCache(CACHE), "destroyCache"));
for (IgniteBiTuple<Consumer<IgniteClient>, String> op : ops) assertThrowsWithCause(() -> runOperation(CLIENT, op), ClientAuthorizationException.class);
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class IgniteClientContainSubjectAddressTest method testAuthenticate.
/**
*/
@Test
public void testAuthenticate() throws Exception {
startGrid();
try (IgniteClient client = Ignition.startClient(getClientConfiguration())) {
client.cluster().state(ACTIVE);
}
Assert.assertTrue(containsAddr);
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class AdditionalSecurityCheckTest method testClientInfoIgniteClientFail.
/**
*/
@Test
public void testClientInfoIgniteClientFail() throws Exception {
Ignite ignite = startGrids(2);
assertEquals(2, ignite.cluster().topologyVersion());
startGrid(2);
assertEquals(3, ignite.cluster().topologyVersion());
fail = true;
try (IgniteClient client = Ignition.startClient(getClientConfiguration())) {
fail();
} catch (ClientAuthenticationException e) {
assertTrue(e.getMessage().contains("Client version is not found"));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class AdditionalSecurityCheckTest method testClientInfo.
/**
*/
@Test
public void testClientInfo() throws Exception {
Ignite ignite = startGrids(2);
assertEquals(2, ignite.cluster().topologyVersion());
startGrid(2);
assertEquals(3, ignite.cluster().topologyVersion());
assertFalse(ignite.cluster().active());
try (GridClient client = GridClientFactory.start(getGridClientConfiguration())) {
assertTrue(client.connected());
client.state().state(ACTIVE, false);
}
try (IgniteClient client = Ignition.startClient(getClientConfiguration())) {
client.createCache("test_cache");
assertEquals(1, client.cacheNames().size());
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class MultipleSSLContextsTest method testThinClients.
/**
* Checks that thin clients with SSL enabled can join the cluster and perform some work on it.
*
* @throws Exception If failed.
*/
@Test
public void testThinClients() throws Exception {
int clientsNum = 3;
int keysNum = 1000;
String cacheName = "thinClientCache";
List<IgniteClient> clients = new ArrayList<>(clientsNum);
try {
for (int i = 0; i < clientsNum; i++) {
IgniteClient client = Ignition.startClient(clientConfiguration("127.0.0.1:1080" + i));
clients.add(client);
}
Map<Integer, Integer> expMap = new HashMap<>();
for (int i = 0; i < keysNum; i++) {
int clientId = keysNum % clientsNum;
ClientCache<Integer, Integer> cache = clients.get(clientId).getOrCreateCache(cacheName);
cache.put(i, i);
expMap.put(i, i);
}
IgniteCache<Integer, Integer> cache = grid(0).cache(cacheName);
assertCacheContent(expMap, cache);
} catch (ClientException ex) {
ex.printStackTrace();
fail("Failed to start thin Java clients: " + ex.getMessage());
} finally {
for (IgniteClient client : clients) client.close();
IgniteCache cache = grid(0).cache(cacheName);
if (cache != null)
cache.destroy();
}
}
Aggregations