diff --git a/cli/src/main/java/bisq/cli/CliMain.java b/cli/src/main/java/bisq/cli/CliMain.java index 342423948b..2554ac4a31 100644 --- a/cli/src/main/java/bisq/cli/CliMain.java +++ b/cli/src/main/java/bisq/cli/CliMain.java @@ -75,7 +75,8 @@ public class CliMain { .defaultsTo(9998); var passwordOpt = parser.accepts("password", "rpc server password") - .withRequiredArg(); + .withRequiredArg() + .required(); OptionSet options = null; try { @@ -110,10 +111,8 @@ public class CliMain { var host = options.valueOf(hostOpt); var port = options.valueOf(portOpt); var password = options.valueOf(passwordOpt); - if (password == null) { - err.println("Error: rpc server password not specified"); - exit(EXIT_FAILURE); - } + + var credentials = new PasswordCallCredentials(password); var channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { @@ -126,8 +125,6 @@ public class CliMain { })); try { - var credentials = new PasswordCallCredentials(password); - switch (method) { case getversion: { var stub = GetVersionGrpc.newBlockingStub(channel).withCallCredentials(credentials); diff --git a/cli/src/main/java/bisq/cli/PasswordCallCredentials.java b/cli/src/main/java/bisq/cli/PasswordCallCredentials.java index 3a03a8a068..14b451d28f 100644 --- a/cli/src/main/java/bisq/cli/PasswordCallCredentials.java +++ b/cli/src/main/java/bisq/cli/PasswordCallCredentials.java @@ -21,7 +21,7 @@ class PasswordCallCredentials extends CallCredentials { public PasswordCallCredentials(String passwordValue) { if (passwordValue == null) - throw new IllegalArgumentException(format("'%s' header value must not be null", PASSWORD_KEY)); + throw new IllegalArgumentException(format("'%s' value must not be null", PASSWORD_KEY)); this.passwordValue = passwordValue; } diff --git a/cli/test.sh b/cli/test.sh index d1bac098fa..33d0439d89 100755 --- a/cli/test.sh +++ b/cli/test.sh @@ -51,9 +51,9 @@ echo "========================================================================" OUTPUT=$(expect -c ' # exp_internal 1 - puts "TEST getversion (no pwd error)" - set expected "Error: rpc server password not specified" - spawn ./bisq-cli getversion + puts "TEST missing required password option error" + set expected "Error: Missing required option(s) \\\[password\\\]" + spawn ./bisq-cli anymethod expect { $expected { puts "PASS" } default { @@ -118,23 +118,6 @@ OUTPUT=$(expect -c ' echo "$OUTPUT" echo "========================================================================" -OUTPUT=$(expect -c ' - puts "TEST getbalance (no pwd error)" - # exp_internal 1 - set expected "Error: rpc server password not specified" - spawn ./bisq-cli getbalance - expect { - $expected { puts "PASS" } - default { - set results $expect_out(buffer) - puts "FAIL expected = $expected" - puts " actual = $results" - } - } -') -echo "$OUTPUT" -echo "========================================================================" - OUTPUT=$(expect -c ' puts "TEST getbalance" # exp_internal 1