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