use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliIT method testCliAuthorization.
@Test
public void testCliAuthorization() {
try (AeshTestConnection terminal = new AeshTestConnection()) {
CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
connect(terminal);
terminal.send("user roles ls");
terminal.assertContains("\"admin\"");
terminal.send("user roles create --permissions=ALL_WRITE wizard");
terminal.send("user roles create --permissions=ALL_READ cleric");
terminal.clear();
terminal.send("user roles ls");
terminal.assertContains("\"wizard\"");
terminal.assertContains("\"cleric\"");
terminal.send("user roles grant --roles=wizard,cleric,admin admin");
terminal.clear();
terminal.send("user roles ls admin");
terminal.assertContains("\"wizard\"");
terminal.assertContains("\"cleric\"");
terminal.send("user roles deny --roles=cleric admin");
terminal.clear();
terminal.send("user roles ls admin");
terminal.assertContains("\"wizard\"");
terminal.assertNotContains("\"cleric\"");
terminal.send("user roles remove wizard");
terminal.clear();
terminal.send("user roles ls");
terminal.assertContains("\"cleric\"");
terminal.assertNotContains("\"wizard\"");
}
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliIT method testCliCacheAvailability.
@Test
public void testCliCacheAvailability() {
try (AeshTestConnection terminal = new AeshTestConnection()) {
CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
connect(terminal);
terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
terminal.assertContains("AVAILABLE");
terminal.send("availability --mode=DEGRADED_MODE " + CLUSTERED_LOCK_CACHE_NAME);
terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
terminal.assertContains("DEGRADED_MODE");
terminal.send("availability --mode=AVAILABILITY " + CLUSTERED_LOCK_CACHE_NAME);
terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
terminal.assertContains("AVAILABLE");
}
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliIT method testCliTasks.
@Test
public void testCliTasks() {
try (AeshTestConnection terminal = new AeshTestConnection()) {
CLI.main(new AeshDelegatingShell(terminal), new String[] { "-c", connectionUrl() }, properties);
connect(terminal);
terminal.send("cd tasks");
terminal.send("ls");
terminal.assertContains("@@cache@names");
terminal.clear();
terminal.send("task exec @@cache@names");
terminal.assertContains("\"___script_cache\"");
terminal.clear();
File resource = getCliResource("hello.js");
terminal.send("task upload --file=" + resource.getPath() + " hello");
terminal.send("task exec hello -Pgreetee=world");
terminal.assertContains("\"Hello world\"");
}
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliIT method testCliUploadProtobufSchemas.
@Test
public void testCliUploadProtobufSchemas() {
try (AeshTestConnection terminal = new AeshTestConnection()) {
CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
// connect
connect(terminal);
// upload
terminal.send("schema upload --file=" + getCliResource("person.proto").getPath() + " person.proto");
terminal.assertContains("\"error\" : null");
terminal.clear();
terminal.send("cd /containers/default/schemas");
terminal.send("ls");
terminal.assertContains("person.proto");
terminal.clear();
terminal.send("schema ls");
terminal.assertContains("person.proto");
terminal.send("schema get person.proto");
terminal.assertContains("PhoneNumber");
terminal.send("schema remove person.proto");
terminal.clear();
terminal.send("schema ls");
terminal.assertContains("[]");
}
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class XSiteCliOperations method extractView.
private static List<String> extractView(AeshTestConnection terminal) {
terminal.send("describe");
// make sure the command succeed
terminal.assertContains("//containers/default");
String allOutput = terminal.getOutputBuffer();
Pattern pattern = Pattern.compile("^\\s*\"cluster_members\"\\s*:\\s*\\[\\s+(.*)\\s+],\\s*$");
for (String line : allOutput.split(Config.getLineSeparator())) {
line = line.trim();
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
terminal.clear();
return Stream.of(matcher.group(1).split(",")).map(s -> s.replaceAll("[\\[\\]\"]", "")).collect(Collectors.toList());
}
}
terminal.clear();
throw new IllegalStateException("Unable to find 'cluster_members' in:\n" + allOutput);
}
Aggregations