Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key-config-path as preferred alias to key-store-path #826

Merged
merged 10 commits into from
Jun 29, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next release
### Features Added
- Hashicorp connection properties can now override http protocol to HTTP/1.1 from the default of HTTP/2. [#817](https://github.com/ConsenSys/web3signer/pull/817)
- Add --key-config-path as preferred alias to --key-store-path [#826](https://github.com/Consensys/web3signer/pull/826)

### Bugs fixed
- Support long name aliases in environment variables and YAML configuration [#825](https://github.com/Consensys/web3signer/pull/825)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<String> createCmdLineParams() {
params.add("--http-host-allowlist");
params.add(String.join(",", signerConfig.getHttpHostAllowList()));
}
params.add("--key-store-path");
params.add("--key-config-path");
params.add(signerConfig.getKeyStorePath().toString());
if (signerConfig.isMetricsEnabled()) {
params.add("--metrics-enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class Web3SignerBaseCommand implements BaseConfig, Runnable {
private Path dataPath;

@Option(
names = {"--key-store-path"},
names = {"--key-config-path", "--key-store-path"},
description = "The path to a directory storing yaml files defining available keys",
paramLabel = DefaultCommandValues.PATH_FORMAT_HELP,
arity = "1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ public class CmdlineHelpers {
public static String validBaseCommandOptions() {
return "--http-listen-port=5001 "
+ "--http-listen-host=localhost "
+ "--key-store-path=./keys "
+ "--key-config-path=./keys "
+ "--idle-connection-timeout-seconds=45 "
+ "--logging=INFO ";
}

public static String validBaseYamlOptions() {
return "http-listen-port: 6001\n"
+ "http-listen-host: \"localhost\"\n"
+ "key-store-path: \"./keys_yaml\"\n"
+ "key-config-path: \"./keys_yaml\"\n"
+ "metrics-categories: \"HTTP\"\n"
+ "logging: \"INFO\"\n";
}

public static String validBaseYamlAliasOptions() {
return "metrics-category: \"HTTP\"\n" + "l: \"INFO\"\n";
return "metrics-category: \"HTTP\"\n"
+ "l: \"INFO\"\n"
+ "key-store-path: \"./keys_yaml_alias\"\n";
}

public static Map<String, String> validBaseEnvironmentVariableOptions() {
Expand All @@ -42,7 +44,7 @@ public static Map<String, String> validBaseEnvironmentVariableOptions() {
"7001",
"WEB3SIGNER_HTTP_LISTEN_HOST",
"localhost",
"WEB3SIGNER_KEY_STORE_PATH",
"WEB3SIGNER_KEY_CONFIG_PATH",
"./keys_env",
"WEB3SIGNER_LOGGING",
"INFO");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void optionsPopulatesWithEnvPrecedence(@TempDir final Path tempDir) throws IOExc
// remove keystorepath from cli.
// The environment option should take precedence over config file.
final String[] args =
removeFieldFrom(configArg + validBaseCommandOptions(), "key-store-path").split(" ");
removeFieldFrom(configArg + validBaseCommandOptions(), "key-config-path").split(" ");

final int result = parser.parseCommandLine(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void valuesFromConfigFileArePopulated(@TempDir final Path tempDir) throws IOExce
commandLine.setDefaultValueProvider(new YamlConfigFileDefaultProvider(commandLine, configFile));

final String cmdArgs =
removeFieldFrom(validBaseCommandOptions(), "http-listen-port", "key-store-path");
removeFieldFrom(validBaseCommandOptions(), "http-listen-port", "key-config-path");
final String[] args = cmdArgs.split(" ");
commandLine.parseArgs(args);

Expand Down Expand Up @@ -103,6 +103,7 @@ void aliasesFromConfigFileArePopulated(@TempDir final Path tempDir) throws IOExc
assertThat(web3SignerBaseCommand.getMetricCategories())
.isEqualTo(Set.of(Web3SignerMetricCategory.HTTP));
assertThat(web3SignerBaseCommand.getLogLevel()).isEqualTo(Level.INFO);
assertThat(web3SignerBaseCommand.getKeyConfigPath()).isEqualTo(Path.of("./keys_yaml_alias"));
assertThat(subCommand.alias).isEqualTo("test alias");
}

Expand Down