use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class Main method main.
public static void main(String... args) {
try {
final CommandLine commandLine = new CommandLine(new MigrationCliAdapter());
commandLine.registerConverter(Config.class, new ConfigConverter()).setSeparator(" ").setCaseInsensitiveEnumValuesAllowed(true);
commandLine.execute(args);
final CliResult cliResult = commandLine.getExecutionResult();
System.exit(cliResult.getStatus());
} catch (final Exception ex) {
System.err.println(ex.toString());
System.exit(1);
}
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method updatingPasswordsDoesntProcessOtherOptions.
@Test
public void updatingPasswordsDoesntProcessOtherOptions() throws Exception {
final InputStream oldIn = System.in;
final InputStream inputStream = new ByteArrayInputStream((System.lineSeparator() + System.lineSeparator()).getBytes());
System.setIn(inputStream);
final KeyDataConfig startingKey = JaxbUtil.unmarshal(getClass().getResourceAsStream("/lockedprivatekey.json"), KeyDataConfig.class);
final Path key = Files.createTempFile("key", ".key");
Files.write(key, JaxbUtil.marshalToString(startingKey).getBytes());
final CliResult result = cliDelegate.execute("-updatepassword", "--keys.keyData.privateKeyPath", key.toString(), "--keys.passwords", "testpassword");
assertThat(result).isNotNull();
System.setIn(oldIn);
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method overrideAlwaysSendTo.
@Test
public void overrideAlwaysSendTo() throws Exception {
String alwaysSendToKey = "giizjhZQM6peq52O7icVFxdTmTYinQSUsvyhXzgZqkE=";
Path configFile = Paths.get(getClass().getResource("/sample-config.json").toURI());
CliResult result = null;
try {
result = cliDelegate.execute("-configfile", configFile.toString(), "-o", Strings.join("alwaysSendTo[1]=", alwaysSendToKey).with(""));
} catch (Exception ex) {
fail(ex.getMessage());
}
assertThat(result).isNotNull();
assertThat(result.getConfig()).isPresent();
assertThat(result.getConfig().get().getAlwaysSendTo()).hasSize(2);
assertThat(result.getConfig().get().getAlwaysSendTo()).containsExactly("/+UuD63zItL1EbjxkKUljMgG8Z1w0AJ8pNOR4iq2yQc=", alwaysSendToKey);
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method suppressStartupForKeygenOption.
@Test
public void suppressStartupForKeygenOption() throws Exception {
when(keyGenerator.generate(anyString(), eq(null), eq(null))).thenReturn(mock(DirectKeyPair.class));
final CliResult cliResult = cliDelegate.execute("-keygen", "--encryptor.type", "NACL");
assertThat(cliResult.isSuppressStartup()).isTrue();
verify(keyGenerator).generate(anyString(), eq(null), eq(null));
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method overridePeers.
@Test
public void overridePeers() throws Exception {
Path configFile = Paths.get(getClass().getResource("/sample-config.json").toURI());
CliResult result = cliDelegate.execute("-configfile", configFile.toString(), "-o", "peer[2].url=http://anotherpeer", "--override", "peer[3].url=http://yetanotherpeer");
assertThat(result).isNotNull();
assertThat(result.getConfig()).isPresent();
assertThat(result.getConfig().get().getPeers()).hasSize(4);
assertThat(result.getConfig().get().getPeers().stream().map(Peer::getUrl)).containsExactlyInAnyOrder("http://anotherpeer", "http://yetanotherpeer", "http://bogus1.com", "http://bogus2.com");
}
Aggregations