Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2316] check permissions CLI dependencies #909

Merged
merged 10 commits into from
Feb 19, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void run() {
Configurator.setAllLevels("", logLevel);
}

// Check that p2p options are able top work or send an error
// Check that p2p options are able to work or send an error
CommandLineUtils.checkOptionDependencies(
logger,
commandLine,
Expand All @@ -536,7 +536,7 @@ public void run() {
"--banned-node-id",
"--banned-node-ids"));

// Check that mining options are able top work or send an error
// Check that mining options are able to work or send an error
CommandLineUtils.checkOptionDependencies(
logger,
commandLine,
Expand All @@ -552,6 +552,13 @@ public void run() {
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)");
}

if (permissionsConfigFile != null) {
if (!permissionsAccountsEnabled && !permissionsNodesEnabled) {
logger.warn(
"Permissions config file set {} but no permissions enabled", permissionsConfigFile);
}
}

final EthNetworkConfig ethNetworkConfig = updateNetworkConfig(getNetwork());
try {
final JsonRpcConfiguration jsonRpcConfiguration = jsonRpcConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,31 @@ public void permissionsEnabledWithNonexistentConfigFileMustError() {
assertThat(commandOutput.toString()).isEmpty();
}

@Test
public void permissionsTomlFileWithNoPermissionsEnabledMustError() throws IOException {

final URL configFile = Resources.getResource(PERMISSIONING_CONFIG_TOML);
final Path permToml = Files.createTempFile("toml", "");
Files.write(permToml, Resources.toByteArray(configFile));
parseCommand("--permissions-config-file", permToml.toString());
permToml.toFile().deleteOnExit();

verify(mockRunnerBuilder).build();

assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
}

@Test
public void defaultPermissionsTomlFileWithNoPermissionsEnabledMustError() throws IOException {
parseCommand("--p2p-enabled", "false");

verify(mockRunnerBuilder).build();

assertThat(commandErrorOutput.toString()).doesNotContain("no permissions enabled");
assertThat(commandOutput.toString()).isEmpty();
}

@Test
public void permissionsTomlPathMustUseOption() throws IOException {

Expand Down