Search in sources :

Example 26 with AdminCommandState

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

the class ConfigCommandsTest method testEnvSetConfig.

@Test
public void testEnvSetConfig() throws Exception {
    Properties pravegaProperties = new Properties();
    pravegaProperties.setProperty("cli.controller.rest.uri", "dummy");
    @Cleanup AdminCommandState adminCommandState = new AdminCommandState();
    adminCommandState.getConfigBuilder().include(pravegaProperties);
    TestUtils.executeCommand("config set cli.controller.rest.uri=$PWD", adminCommandState);
    String commandResult = TestUtils.executeCommand("config list", adminCommandState);
    Assert.assertTrue(commandResult.contains("cli.controller.rest.uri=" + System.getenv("PWD")));
}
Also used : Properties(java.util.Properties) Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test)

Example 27 with AdminCommandState

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

the class SecureControllerCommandsTest method testAuthConfig.

@Test
@SneakyThrows
public void testAuthConfig() {
    String scope = "testScope";
    Properties pravegaProperties = new Properties();
    pravegaProperties.setProperty("cli.security.auth.enable", "true");
    pravegaProperties.setProperty("cli.security.auth.credentials.username", "admin");
    pravegaProperties.setProperty("cli.security.auth.credentials.password", "1111_aaaa");
    cliConfig().getConfigBuilder().include(pravegaProperties);
    String commandResult = TestUtils.executeCommand("controller list-scopes", cliConfig());
    // Check that both the new scope and the system one exist.
    Assert.assertTrue(commandResult.contains("_system"));
    Assert.assertTrue(commandResult.contains(scope));
    Assert.assertNotNull(ControllerListScopesCommand.descriptor());
    // Restore config
    pravegaProperties.setProperty("cli.security.auth.enable", "false");
    cliConfig().getConfigBuilder().include(pravegaProperties);
    // Exercise response codes for REST requests.
    @Cleanup val c1 = new AdminCommandState();
    CommandArgs commandArgs = new CommandArgs(Collections.emptyList(), c1);
    ControllerListScopesCommand command = new ControllerListScopesCommand(commandArgs);
    command.printResponseInfo(Response.status(Response.Status.UNAUTHORIZED).build());
    command.printResponseInfo(Response.status(Response.Status.INTERNAL_SERVER_ERROR).build());
}
Also used : lombok.val(lombok.val) CommandArgs(io.pravega.cli.admin.CommandArgs) Properties(java.util.Properties) Cleanup(lombok.Cleanup) AdminCommandState(io.pravega.cli.admin.AdminCommandState) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

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