Search in sources :

Example 1 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell in project infinispan by infinispan.

the class CliBackupManagerIT method cli.

private AeshTestConnection cli(Cluster cluster) {
    AeshTestConnection t = new AeshTestConnection();
    CLI.main(new AeshDelegatingShell(t), new String[] {}, new Properties());
    String host = cluster.driver.getServerAddress(0).getHostAddress();
    int port = cluster.driver.getServerSocket(0, 11222).getPort();
    t.send(String.format("connect %s:%d", host, port));
    t.assertContains("//containers/default]>");
    t.clear();
    return t;
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Properties(java.util.Properties)

Example 2 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell 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\"");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 3 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell 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");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 4 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell 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\"");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) File(java.io.File) Test(org.junit.Test)

Example 5 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell 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("[]");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Aggregations

AeshDelegatingShell (org.infinispan.cli.impl.AeshDelegatingShell)19 AeshTestConnection (org.infinispan.server.test.core.AeshTestConnection)18 Test (org.junit.Test)9 IOException (java.io.IOException)2 Properties (java.util.Properties)2 File (java.io.File)1 CommandRegistry (org.aesh.command.registry.CommandRegistry)1 SettingsBuilder (org.aesh.command.settings.SettingsBuilder)1 ReadlineConsole (org.aesh.readline.ReadlineConsole)1 ContextAwareCommandActivatorProvider (org.infinispan.cli.activators.ContextAwareCommandActivatorProvider)1 ContextAwareCompleterInvocationProvider (org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider)1 CliAliasManager (org.infinispan.cli.impl.CliAliasManager)1 CliCommandNotFoundHandler (org.infinispan.cli.impl.CliCommandNotFoundHandler)1 ContextAwareCommandInvocationProvider (org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)1 ContextAwareQuitHandler (org.infinispan.cli.impl.ContextAwareQuitHandler)1