fix 1.23.4: normalize taler:// :443/:80 + mon scan all landings
Shared lib.sh normalize_taler_uri for ladder/e2e/pay. urls phase checks public bank/exchange/merchant intros and bank mint JSON for residual default ports (ERROR on GOA/local). Unit test included.
This commit is contained in:
parent
a103eeab9d
commit
d420043863
10 changed files with 225 additions and 12 deletions
73
tests/test_normalize_taler_uri.sh
Executable file
73
tests/test_normalize_taler_uri.sh
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env bash
|
||||
# Unit tests for normalize_taler_uri / taler_uri_has_default_port (lib.sh).
|
||||
# Run: ./tests/test_normalize_taler_uri.sh
|
||||
set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
# shellcheck source=../lib.sh
|
||||
source "$ROOT/lib.sh"
|
||||
|
||||
pass=0
|
||||
fail=0
|
||||
assert_eq() {
|
||||
local name="$1" got="$2" want="$3"
|
||||
if [ "$got" = "$want" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
echo "FAIL $name" >&2
|
||||
echo " got: $got" >&2
|
||||
echo " want: $want" >&2
|
||||
fail=$((fail + 1))
|
||||
fi
|
||||
}
|
||||
assert_true() {
|
||||
local name="$1"
|
||||
if "$@"; then
|
||||
# shift name
|
||||
:
|
||||
fi
|
||||
}
|
||||
|
||||
# --- strip :443 / :80 ---
|
||||
assert_eq "withdraw :443/" \
|
||||
"$(normalize_taler_uri 'taler://withdraw/bank.hacktivism.ch:443/taler-integration/abc-123')" \
|
||||
"taler://withdraw/bank.hacktivism.ch/taler-integration/abc-123"
|
||||
|
||||
assert_eq "withdraw :443 end" \
|
||||
"$(normalize_taler_uri 'taler://withdraw/bank.example:443')" \
|
||||
"taler://withdraw/bank.example"
|
||||
|
||||
assert_eq "pay :443" \
|
||||
"$(normalize_taler_uri 'taler://pay/taler.hacktivism.ch:443/instances/x/orders/y?c=z')" \
|
||||
"taler://pay/taler.hacktivism.ch/instances/x/orders/y?c=z"
|
||||
|
||||
assert_eq "pay-template :80" \
|
||||
"$(normalize_taler_uri 'taler://pay-template/shop.example:80/instances/i/t')" \
|
||||
"taler://pay-template/shop.example/instances/i/t"
|
||||
|
||||
assert_eq "already clean" \
|
||||
"$(normalize_taler_uri 'taler://withdraw/bank.hacktivism.ch/taler-integration/uuid')" \
|
||||
"taler://withdraw/bank.hacktivism.ch/taler-integration/uuid"
|
||||
|
||||
assert_eq "empty" "$(normalize_taler_uri '')" ""
|
||||
|
||||
# non-default port kept
|
||||
assert_eq "keep :8443" \
|
||||
"$(normalize_taler_uri 'taler://withdraw/bank.example:8443/taler-integration/x')" \
|
||||
"taler://withdraw/bank.example:8443/taler-integration/x"
|
||||
|
||||
# has_default_port detector
|
||||
if taler_uri_has_default_port 'taler://withdraw/h:443/p'; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
echo "FAIL detector should match :443" >&2
|
||||
fail=$((fail + 1))
|
||||
fi
|
||||
if taler_uri_has_default_port 'taler://withdraw/h/p'; then
|
||||
echo "FAIL detector should not match clean URI" >&2
|
||||
fail=$((fail + 1))
|
||||
else
|
||||
pass=$((pass + 1))
|
||||
fi
|
||||
|
||||
echo "normalize_taler_uri tests: pass=$pass fail=$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue