use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method keygenNoArgsPrintsHelp.
@Test
public void keygenNoArgsPrintsHelp() throws Exception {
final CliResult result = cliDelegate.execute("keygen");
final String sysout = systemOutOutput.getLog();
final String syserr = systemErrOutput.getLog();
assertThat(result).isNotNull();
assertThat(result.getConfig()).isNotPresent();
assertThat(result.getStatus()).isEqualTo(0);
assertThat(result.isSuppressStartup()).isTrue();
assertThat(syserr).isEmpty();
assertThat(sysout).isNotEmpty();
assertThat(sysout).contains("Usage: tessera keygen [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method withValidConfig.
@Test
public void withValidConfig() throws Exception {
Path configFile = Paths.get(getClass().getResource("/sample-config.json").toURI());
CliResult result = cliDelegate.execute("-configfile", configFile.toString());
assertThat(result).isNotNull();
assertThat(result.getConfig()).isPresent();
assertThat(result.getStatus()).isEqualTo(0);
assertThat(result.isSuppressStartup()).isFalse();
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class PicoCliDelegateTest method keyupdateHelp.
@Test
public void keyupdateHelp() throws Exception {
final CliResult result = cliDelegate.execute("keyupdate", "help");
final String sysout = systemOutOutput.getLog();
final String syserr = systemErrOutput.getLog();
assertThat(result).isNotNull();
assertThat(result.getConfig()).isNotPresent();
assertThat(result.getStatus()).isEqualTo(0);
assertThat(result.isSuppressStartup()).isTrue();
assertThat(syserr).isEmpty();
assertThat(sysout).isNotEmpty();
assertThat(sysout).contains("Usage: tessera keyupdate [OPTIONS] [COMMAND]", "Description:", "Options:", "Commands:");
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class KeyGenCommandTest method noArgsProvided.
@Test
public void noArgsProvided() throws Exception {
ConfigKeyPair configKeyPair = mock(ConfigKeyPair.class);
when(keyGenerator.generate("", null, null)).thenReturn(configKeyPair);
when(keyGeneratorFactory.create(refEq(null), any(EncryptorConfig.class))).thenReturn(keyGenerator);
int exitCode = commandLine.execute();
assertThat(exitCode).isZero();
CommandLine.ParseResult parseResult = commandLine.getParseResult();
assertThat(parseResult).isNotNull();
assertThat(parseResult.matchedArgs()).isEmpty();
assertThat(parseResult.unmatched()).isEmpty();
CliResult result = commandLine.getExecutionResult();
assertThat(result).isNotNull();
assertThat(result.isSuppressStartup()).isTrue();
assertThat(result.getConfig()).isNotPresent();
assertThat(result.getStatus()).isEqualTo(0);
verify(keyDataMarshaller).marshal(configKeyPair);
verify(keyGeneratorFactory).create(refEq(null), any(EncryptorConfig.class));
verify(keyGenerator).generate("", null, null);
}
use of com.quorum.tessera.cli.CliResult in project tessera by ConsenSys.
the class KeyGenCommandTest method onlyMulipleOutputFilesProvided.
@Test
public void onlyMulipleOutputFilesProvided() throws Exception {
List<String> optionVariations = List.of("--keyout", "-filename");
List<String> valueVariations = List.of("myfile", "myotherfile", "yetanother");
ConfigKeyPair configKeyPair = mock(ConfigKeyPair.class);
valueVariations.forEach(filename -> {
when(keyGenerator.generate(filename, null, null)).thenReturn(configKeyPair);
});
when(keyGeneratorFactory.create(refEq(null), any(EncryptorConfig.class))).thenReturn(keyGenerator);
for (String option : optionVariations) {
String arg = option.concat("=").concat(String.join(",", valueVariations));
int exitCode = commandLine.execute(arg);
assertThat(exitCode).isZero();
CommandLine.ParseResult parseResult = commandLine.getParseResult();
assertThat(parseResult).isNotNull();
assertThat(parseResult.matchedArgs()).hasSize(1);
assertThat(parseResult.hasMatchedOption(option));
assertThat(parseResult.unmatched()).isEmpty();
CliResult result = commandLine.getExecutionResult();
assertThat(result).isNotNull();
assertThat(result.isSuppressStartup()).isTrue();
assertThat(result.getConfig()).isNotPresent();
}
verify(keyDataMarshaller, times(optionVariations.size() * valueVariations.size())).marshal(configKeyPair);
verify(keyGeneratorFactory, times(optionVariations.size())).create(refEq(null), any(EncryptorConfig.class));
valueVariations.forEach(filename -> {
verify(keyGenerator, times(optionVariations.size())).generate(filename, null, null);
});
}
Aggregations