mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Set --password as a required option in JOpt parser
This commit is contained in:
parent
822e6813f8
commit
5fa7939ec4
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
23
cli/test.sh
23
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
|
||||
|
Loading…
Reference in New Issue
Block a user