[MINOR] permission config file location and option under docker (#925)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Chris Mckay 6 years ago committed by GitHub
parent 7fc448a9ac
commit 3b35d2d47a
  1. 1
      pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java
  2. 28
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  3. 6
      pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java
  4. 13
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -48,6 +48,7 @@ interface DefaultCommandValues {
String DOCKER_RPC_WS_AUTHENTICATION_CREDENTIALS_FILE_LOCATION = String DOCKER_RPC_WS_AUTHENTICATION_CREDENTIALS_FILE_LOCATION =
"/etc/pantheon/rpc_ws_auth_config.toml"; "/etc/pantheon/rpc_ws_auth_config.toml";
String DOCKER_PRIVACY_PUBLIC_KEY_FILE = "/etc/pantheon/privacy_public_key"; String DOCKER_PRIVACY_PUBLIC_KEY_FILE = "/etc/pantheon/privacy_public_key";
String DOCKER_PERMISSIONS_CONFIG_FILE_LOCATION = "/etc/pantheon/permissions_config.toml";
String PERMISSIONING_CONFIG_LOCATION = "permissions_config.toml"; String PERMISSIONING_CONFIG_LOCATION = "permissions_config.toml";
String MANDATORY_HOST_FORMAT_HELP = "<HOST>"; String MANDATORY_HOST_FORMAT_HELP = "<HOST>";
String MANDATORY_PORT_FORMAT_HELP = "<PORT>"; String MANDATORY_PORT_FORMAT_HELP = "<PORT>";

@ -440,12 +440,6 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
description = "Enable account level permissions (default: ${DEFAULT-VALUE})") description = "Enable account level permissions (default: ${DEFAULT-VALUE})")
private final Boolean permissionsAccountsEnabled = false; private final Boolean permissionsAccountsEnabled = false;
@Option(
names = {"--permissions-config-file"},
description =
"Permissions config TOML file (default: a file named \"permissions_config.toml\" in the Pantheon data folder)")
private String permissionsConfigFile = null;
@Option( @Option(
names = {"--privacy-enabled"}, names = {"--privacy-enabled"},
description = "Enable private transactions (default: ${DEFAULT-VALUE})") description = "Enable private transactions (default: ${DEFAULT-VALUE})")
@ -550,10 +544,10 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)"); + "or specify the beneficiary of mining (via --miner-coinbase <Address>)");
} }
if (permissionsConfigFile != null) { if (permissionsConfigFile() != null) {
if (!permissionsAccountsEnabled && !permissionsNodesEnabled) { if (!permissionsAccountsEnabled && !permissionsNodesEnabled) {
logger.warn( logger.warn(
"Permissions config file set {} but no permissions enabled", permissionsConfigFile); "Permissions config file set {} but no permissions enabled", permissionsConfigFile());
} }
} }
@ -622,8 +616,8 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
private String getPermissionsConfigFile() { private String getPermissionsConfigFile() {
return permissionsConfigFile != null return permissionsConfigFile() != null
? permissionsConfigFile ? permissionsConfigFile()
: dataDir().toAbsolutePath() : dataDir().toAbsolutePath()
+ System.getProperty("file.separator") + System.getProperty("file.separator")
+ DefaultCommandValues.PERMISSIONING_CONFIG_LOCATION; + DefaultCommandValues.PERMISSIONING_CONFIG_LOCATION;
@ -1008,6 +1002,20 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
return filename; return filename;
} }
private String permissionsConfigFile() {
String filename = null;
if (isFullInstantiation()) {
filename = standaloneCommands.permissionsConfigFile;
} else if (isDocker) {
final File file = new File(DOCKER_PERMISSIONS_CONFIG_FILE_LOCATION);
if (file.exists()) {
filename = file.getAbsolutePath();
}
}
return filename;
}
private boolean isFullInstantiation() { private boolean isFullInstantiation() {
return !isDocker; return !isDocker;
} }

@ -72,4 +72,10 @@ class StandaloneCommand implements DefaultCommandValues {
names = {"--privacy-public-key-file"}, names = {"--privacy-public-key-file"},
description = "The enclave's public key file") description = "The enclave's public key file")
final File privacyPublicKeyFile = null; final File privacyPublicKeyFile = null;
@CommandLine.Option(
names = {"--permissions-config-file"},
description =
"Permissions config TOML file (default: a file named \"permissions_config.toml\" in the Pantheon data folder)")
String permissionsConfigFile = null;
} }

@ -1989,4 +1989,17 @@ public class PantheonCommandTest extends CommandTestAbstract {
.startsWith("Unknown options: --rpc-ws-authentication-credentials-file, ."); .startsWith("Unknown options: --rpc-ws-authentication-credentials-file, .");
assertThat(commandOutput.toString()).isEmpty(); assertThat(commandOutput.toString()).isEmpty();
} }
@Test
public void permissionsConfigFileOptionDisabledUnderDocker() {
System.setProperty("pantheon.docker", "true");
assumeFalse(isFullInstantiation());
final Path path = Paths.get(".");
parseCommand("--permissions-config-file", path.toString());
assertThat(commandErrorOutput.toString())
.startsWith("Unknown options: --permissions-config-file, .");
assertThat(commandOutput.toString()).isEmpty();
}
} }

Loading…
Cancel
Save