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")));
}
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());
}
Aggregations