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

Renaming authentication config file cli command #865

Merged
merged 2 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ private Long configureRefreshDelay(final Long refreshDelay) {
private final Boolean permissionsAccountsEnabled = false;

@Option(
names = {"--permissions-config-path"},
names = {"--permissions-config-file"},
description =
"Path to permissions config TOML file (default: a file named \"permissions_config.toml\" in the Pantheon data folder)")
private String permissionsConfigPath = null;
private String permissionsConfigFile = null;

@Option(
names = {"--privacy-enabled"},
Expand Down Expand Up @@ -638,10 +638,10 @@ PantheonController<?> buildController() {
}
}

private String getPermissionsConfigPath() {
private String getPermissionsConfigFile() {

return permissionsConfigPath != null
? permissionsConfigPath
return permissionsConfigFile != null
? permissionsConfigFile
: dataDir().toAbsolutePath()
+ System.getProperty("file.separator")
+ DefaultCommandValues.PERMISSIONING_CONFIG_LOCATION;
Expand Down Expand Up @@ -763,7 +763,7 @@ private Optional<PermissioningConfiguration> permissioningConfiguration() throws

final PermissioningConfiguration permissioningConfiguration =
PermissioningConfigurationBuilder.permissioningConfigurationFromToml(
getPermissionsConfigPath(), permissionsNodesEnabled, permissionsAccountsEnabled);
getPermissionsConfigFile(), permissionsNodesEnabled, permissionsAccountsEnabled);
return Optional.of(permissioningConfiguration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,19 @@ public void overrideDefaultValuesIfKeyIsPresentInConfigFile() throws IOException

@Test
public void permissionsTomlPathWithoutOptionMustDisplayUsage() {
parseCommand("--permissions-config-path");
parseCommand("--permissions-config-file");

verifyZeroInteractions(mockRunnerBuilder);

assertThat(commandErrorOutput.toString())
.startsWith("Missing required parameter for option '--permissions-config-path'");
.startsWith("Missing required parameter for option '--permissions-config-file'");
assertThat(commandOutput.toString()).isEmpty();
}

@Test
public void permissionsEnabledWithNonexistentConfigFileMustError() {
parseCommand(
"--permissions-accounts-enabled", "--permissions-config-path", "file-does-not-exist");
"--permissions-accounts-enabled", "--permissions-config-file", "file-does-not-exist");

verifyZeroInteractions(mockRunnerBuilder);

Expand All @@ -344,7 +344,7 @@ public void permissionsTomlPathMustUseOption() throws IOException {
Files.write(permToml, Resources.toByteArray(configFile));

parseCommand(
"--permissions-accounts-enabled", "--permissions-config-path", permToml.toString());
"--permissions-accounts-enabled", "--permissions-config-file", permToml.toString());
PermissioningConfiguration permissioningConfiguration =
PermissioningConfiguration.createDefault();
permissioningConfiguration.setConfigurationFilePath(permToml.toString());
Expand Down
2 changes: 1 addition & 1 deletion pantheon/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ min-gas-price="1"
# Permissioning
permissions-nodes-enabled=false
permissions-accounts-enabled=false
permissions-config-path="./permissions_config.toml"
permissions-config-file="./permissions_config.toml"

# Privacy
privacy-url="http://127.0.0.1:8888"
Expand Down