Search in sources :

Example 21 with AdminCommandState

use of io.pravega.cli.admin.AdminCommandState in project pravega by pravega.

the class PasswordFileCreatorCommandTest method testPasswordFileCreatorCommand.

@Test
public void testPasswordFileCreatorCommand() throws Exception {
    final String fileName = "passwordFileTest";
    try {
        @Cleanup val c1 = new AdminCommandState();
        TestUtils.executeCommand("password create-password-file " + fileName + " user:password:acl", c1);
        Assert.assertTrue(Files.exists(Paths.get(fileName)));
        // Test wrong input arguments.
        @Cleanup val c2 = new AdminCommandState();
        TestUtils.executeCommand("password create-password-file " + fileName + " wrong", c2);
        @Cleanup val c3 = new AdminCommandState();
        TestUtils.executeCommand("password create-password-file wrong", c3);
    // Remove generated file by command.
    } finally {
        Files.delete(Paths.get(fileName));
    }
}
Also used : lombok.val(lombok.val) Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test)

Example 22 with AdminCommandState

use of io.pravega.cli.admin.AdminCommandState in project pravega by pravega.

the class PasswordFileCreatorCommandTest method testPasswordFileCreatorCommandParsesAuthFormat.

@Test
public void testPasswordFileCreatorCommandParsesAuthFormat() throws Exception {
    final String fileName = "fileWithAuthFormat";
    try {
        @Cleanup val c1 = new AdminCommandState();
        TestUtils.executeCommand("password create-password-file " + fileName + " user:password:prn::/scope:scope1,READ_UPDATE,", c1);
        Assert.assertTrue(Files.exists(Paths.get(fileName)));
    } finally {
        Files.delete(Paths.get(fileName));
    }
}
Also used : lombok.val(lombok.val) Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test)

Example 23 with AdminCommandState

use of io.pravega.cli.admin.AdminCommandState in project pravega by pravega.

the class ConfigUtilsTest method testConfigUtilsWithValidFile.

@Test
public void testConfigUtilsWithValidFile() throws IOException {
    @Cleanup AdminCommandState commandState = new AdminCommandState();
    System.setProperty("pravega.configurationFile", "../../config/admin-cli.properties");
    System.setProperty("pravegaservice", "pravegaservice");
    ConfigUtils.loadProperties(commandState);
}
Also used : Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test)

Example 24 with AdminCommandState

use of io.pravega.cli.admin.AdminCommandState in project pravega by pravega.

the class TestUtils method createAdminCLIConfig.

/**
 * Creates the admin state with the necessary CLI properties to use during testing.
 *
 * @param controllerRestUri the controller REST URI.
 * @param controllerUri the controller URI.
 * @param zkConnectUri the zookeeper URI.
 * @param containerCount the container count.
 * @param authEnabled whether the cli requires authentication to access the cluster.
 * @param tlsEnabled whether the cli requires TLS to access the cluster.
 * @param accessTokenTtl how long the access token will last
 */
@SneakyThrows
public static AdminCommandState createAdminCLIConfig(String controllerRestUri, String controllerUri, String zkConnectUri, int containerCount, boolean authEnabled, boolean tlsEnabled, Duration accessTokenTtl) {
    AdminCommandState state = new AdminCommandState();
    Properties pravegaProperties = new Properties();
    System.out.println("REST URI: " + controllerRestUri);
    pravegaProperties.setProperty("cli.controller.connect.rest.uri", controllerRestUri);
    pravegaProperties.setProperty("cli.controller.connect.grpc.uri", controllerUri);
    pravegaProperties.setProperty("pravegaservice.zk.connect.uri", zkConnectUri);
    pravegaProperties.setProperty("pravegaservice.container.count", Integer.toString(containerCount));
    pravegaProperties.setProperty("cli.channel.auth", Boolean.toString(authEnabled));
    pravegaProperties.setProperty("cli.credentials.username", SecurityConfigDefaults.AUTH_ADMIN_USERNAME);
    pravegaProperties.setProperty("cli.credentials.pwd", SecurityConfigDefaults.AUTH_ADMIN_PASSWORD);
    pravegaProperties.setProperty("cli.channel.tls", Boolean.toString(tlsEnabled));
    pravegaProperties.setProperty("cli.trustStore.location", pathToConfig() + SecurityConfigDefaults.TLS_CA_CERT_FILE_NAME);
    pravegaProperties.setProperty("cli.trustStore.access.token.ttl.seconds", Long.toString(accessTokenTtl.toSeconds()));
    state.getConfigBuilder().include(pravegaProperties);
    return state;
}
Also used : Properties(java.util.Properties) AdminCommandState(io.pravega.cli.admin.AdminCommandState) SneakyThrows(lombok.SneakyThrows)

Example 25 with AdminCommandState

use of io.pravega.cli.admin.AdminCommandState in project pravega by pravega.

the class ConfigCommandsTest method testNonExistentEnvSetConfig.

@Test(expected = IllegalArgumentException.class)
public void testNonExistentEnvSetConfig() throws Exception {
    Properties pravegaProperties = new Properties();
    pravegaProperties.setProperty("cli.controller.rest.uri", "test");
    @Cleanup AdminCommandState adminCommandState = new AdminCommandState();
    adminCommandState.getConfigBuilder().include(pravegaProperties);
    TestUtils.executeCommand("config set hello=$world", adminCommandState);
    TestUtils.executeCommand("config list", adminCommandState);
}
Also used : Properties(java.util.Properties) Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test)

Aggregations

AdminCommandState (io.pravega.cli.admin.AdminCommandState)27 Properties (java.util.Properties)23 Test (org.junit.Test)22 Cleanup (lombok.Cleanup)14 SegmentProperties (io.pravega.segmentstore.contracts.SegmentProperties)13 CommandArgs (io.pravega.cli.admin.CommandArgs)11 lombok.val (lombok.val)9 TestUtils (io.pravega.cli.admin.utils.TestUtils)6 BookKeeperLogFactory (io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)5 DeleteSegmentOperation (io.pravega.segmentstore.server.logs.operations.DeleteSegmentOperation)4 ClientConfig (io.pravega.client.ClientConfig)3 AttributeUpdateCollection (io.pravega.segmentstore.contracts.AttributeUpdateCollection)3 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)3 DefaultCredentials (io.pravega.shared.security.auth.DefaultCredentials)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 CompositeByteArraySegment (io.pravega.common.util.CompositeByteArraySegment)2 ImmutableDate (io.pravega.common.util.ImmutableDate)2 AttributeId (io.pravega.segmentstore.contracts.AttributeId)2