Skip to content

Commit

Permalink
Check param count only, not param order correctness
Browse files Browse the repository at this point in the history
This change simplifies client 'getoffers' method parameter
validation.  It no longer assumes parameter ordering is correct, nor
validates the direction parameter value.  The client only verifies
the correct number of string parameters are present.
  • Loading branch information
ghubstan authored and eigentsmis committed Jun 26, 2020
1 parent cff7317 commit 8bdbf79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
10 changes: 2 additions & 8 deletions cli/src/main/java/bisq/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,10 @@ public static void run(String[] args) {
return;
}
case getoffers: {
if (nonOptionArgs.size() < 2)
throw new IllegalArgumentException("no buy/sell direction specified");

var direction = nonOptionArgs.get(1);
if (!direction.equalsIgnoreCase("BUY") && !direction.equalsIgnoreCase("SELL"))
throw new IllegalArgumentException("no buy/sell direction specified");

if (nonOptionArgs.size() < 3)
throw new IllegalArgumentException("no fiat currency specified");
throw new IllegalArgumentException("incorrect parameter count, expecting direction (buy|sell), currency code");

var direction = nonOptionArgs.get(1);
var fiatCurrency = nonOptionArgs.get(2);

var request = GetOffersRequest.newBuilder()
Expand Down
9 changes: 1 addition & 8 deletions cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,7 @@
run ./bisq-cli --password=xyz getoffers
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: no buy/sell direction specified" ]
}

@test "test getoffers missing ccy argument" {
run ./bisq-cli --password=xyz getoffers buy
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: no fiat currency specified" ]
[ "$output" = "Error: incorrect parameter count, expecting direction (buy|sell), currency code" ]
}

@test "test getoffers buy eur check return status" {
Expand Down

0 comments on commit 8bdbf79

Please sign in to comment.