aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-22 16:30:55 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-22 16:30:55 +0200
commit99543152e9ddb1aab29d4e69dffb26c97d36040a (patch)
treea15f35206bf35183e986add028e684d59f31c310
parent52c49785fe20844a52f083de4adf9fea6e0c403d (diff)
-clean up test scripts
-rw-r--r--src/testing/Makefile.am5
-rwxr-xr-xsrc/testing/initialize_taler_system.sh6
-rwxr-xr-xsrc/testing/setup.sh20
-rwxr-xr-xsrc/testing/test_merchant_instance_auth.sh14
-rwxr-xr-xsrc/testing/test_merchant_instance_purge.sh40
-rwxr-xr-xsrc/testing/test_merchant_instance_response.sh40
-rwxr-xr-xsrc/testing/test_merchant_kyc.sh36
-rwxr-xr-xsrc/testing/test_merchant_order_autocleanup.sh207
-rwxr-xr-xsrc/testing/test_merchant_order_creation.sh332
-rwxr-xr-xsrc/testing/test_merchant_product_creation.sh171
-rwxr-xr-xsrc/testing/test_merchant_reserve_creation.sh135
-rwxr-xr-xsrc/testing/test_merchant_transfer_tracking.sh200
-rwxr-xr-xsrc/testing/test_merchant_wirewatch.sh18
-rw-r--r--src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv1
-rw-r--r--src/testing/test_template.conf20
15 files changed, 671 insertions, 574 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index ff4e7391..3ca4c086 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -16,7 +16,10 @@ check_SCRIPTS = \
test_merchant_reserve_creation.sh \
test_merchant_product_creation.sh \
test_merchant_order_creation.sh \
- test_merchant_transfer_tracking.sh
+ test_merchant_transfer_tracking.sh \
+ test_merchant_kyc.sh
+# test_merchant_order_autocleanup.sh <= convert!
+# test_merchant_wirewatch.sh <= convert!
lib_LTLIBRARIES = \
diff --git a/src/testing/initialize_taler_system.sh b/src/testing/initialize_taler_system.sh
index 1a234177..709ce3f0 100755
--- a/src/testing/initialize_taler_system.sh
+++ b/src/testing/initialize_taler_system.sh
@@ -257,10 +257,10 @@ fi
echo " OK"
echo -n "Setting up keys ..."
-taler-exchange-offline -c $CONF \
+taler-exchange-offline -c "$CONF" \
download \
sign \
- enable-account `taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI` \
+ enable-account $(taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI) \
enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
wire-fee now iban TESTKUDOS:0.01 TESTKUDOS:0.01 \
global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 1h 1year 5 \
@@ -268,7 +268,7 @@ taler-exchange-offline -c $CONF \
echo -n "."
-for n in `seq 1 3`
+for n in $(seq 1 3)
do
echo -n "."
OK=0
diff --git a/src/testing/setup.sh b/src/testing/setup.sh
index 86d2b06d..37e42cb9 100755
--- a/src/testing/setup.sh
+++ b/src/testing/setup.sh
@@ -44,3 +44,23 @@ function setup()
exec 4>&-
echo "Test system ready" >&2
}
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_fail() {
+ echo "$@" >&2
+ exit 1
+}
+
+function get_payto_uri() {
+ export LIBEUFIN_SANDBOX_USERNAME="$1"
+ export LIBEUFIN_SANDBOX_PASSWORD="$2"
+ export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
+ libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri'
+}
+
+function get_bankaccount_transactions() {
+ export LIBEUFIN_SANDBOX_USERNAME=$1
+ export LIBEUFIN_SANDBOX_PASSWORD=$2
+ export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
+ libeufin-cli sandbox demobank list-transactions --bank-account $1
+}
diff --git a/src/testing/test_merchant_instance_auth.sh b/src/testing/test_merchant_instance_auth.sh
index c85e37e0..1a21c083 100755
--- a/src/testing/test_merchant_instance_auth.sh
+++ b/src/testing/test_merchant_instance_auth.sh
@@ -17,23 +17,17 @@
# <http://www.gnu.org/licenses/>
#
-# Exit, with status code "skip" (no 'real' failure)
-function exit_fail() {
- echo "$@" >&2
- exit 1
-}
-
# Cleanup to run whenever we exit
function my_cleanup()
{
for n in $(jobs -p)
do
- kill $n 2> /dev/null || true
+ kill "$n" 2> /dev/null || true
done
wait
- if [ ! -z ${LAST_RESPONSE+x} ]
+ if [ -n "${LAST_RESPONSE+x}" ]
then
- rm -f ${LAST_RESPONSE}
+ rm -f "${LAST_RESPONSE}"
fi
}
@@ -42,7 +36,7 @@ function my_cleanup()
# Launch only the merchant.
setup -c test_template.conf -m
CONF="test_template.conf.edited"
-LAST_RESPONSE=`mktemp test_response.conf-XXXXXX`
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
echo -n "Configuring 'default' instance ..." >&2
diff --git a/src/testing/test_merchant_instance_purge.sh b/src/testing/test_merchant_instance_purge.sh
index 1c3fab2b..dfebbc84 100755
--- a/src/testing/test_merchant_instance_purge.sh
+++ b/src/testing/test_merchant_instance_purge.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -17,9 +17,12 @@
# <http://www.gnu.org/licenses/>
#
-. initialize_taler_system.sh
+. setup.sh
-echo -n "Configuring default instance ..."
+# Launch only the merchant.
+setup -c test_template.conf -m
+
+echo -n "Configuring default instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
@@ -29,13 +32,12 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
-echo " OK"
+echo " OK" >&2
-echo -n "Configuring merchant instance ..."
+echo -n "Configuring merchant instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
http://localhost:9966/management/instances \
@@ -44,28 +46,22 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
+echo " OK" >&2
-echo " OK"
-
-
-echo -n "Deleting instance ..."
-
+echo -n "Deleting instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
"http://localhost:9966/management/instances/test" \
-w "%{http_code}" -s -o /dev/null)
-
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance deleted. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance deleted. got: $STATUS"
fi
-echo " OK"
-echo -n "Purging instance ..."
+echo " OK" >&2
+echo -n "Purging instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
"http://localhost:9966/management/instances/test?purge=yes" \
@@ -74,10 +70,10 @@ STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance deleted. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance deleted. got: $STATUS"
fi
-echo " OK"
+echo " OK" >&2
+echo "Test PASSED"
exit 0
diff --git a/src/testing/test_merchant_instance_response.sh b/src/testing/test_merchant_instance_response.sh
index 5f175b0b..b94f8dcf 100755
--- a/src/testing/test_merchant_instance_response.sh
+++ b/src/testing/test_merchant_instance_response.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -17,9 +17,11 @@
# <http://www.gnu.org/licenses/>
#
-. initialize_taler_system.sh
+. setup.sh
+
+# Launch only the merchant.
+setup -c test_template.conf -m
-# echo -n "Configuring merchant instance ..."
STATUS=$(curl -H "Content-Type: application/json" -X OPTIONS \
http://localhost:9966/instances/default/private/products \
@@ -27,8 +29,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X OPTIONS \
if [ "$STATUS" != "204" ]
then
- echo 'options should return 204 when default instance doest not exist yet. got:' $STATUS
- exit 1
+ exit_fail "Expected 204 when default instance doest not exist yet. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X GET \
@@ -38,8 +39,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "404" ]
then
- echo 'backend should respond 404 when the default instance is not yet created. got:' $STATUS
- exit 1
+ exit_fail "Expected 404 when the default instance is not yet created. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X POST \
@@ -50,8 +50,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X GET \
@@ -60,8 +59,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "401" ]
then
- echo 'should respond unauthorized without the token for the list of product when the default instance was created. got:' $STATUS
- exit 1
+ exit_fail "Expected 401 without the token for the list of product when the default instance was created. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X GET \
@@ -71,8 +69,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok for the list of product when the default instance was created. got:' $STATUS
- exit 1
+ exit_fail "Expected 200 for the list of product when the default instance was created. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X POST \
@@ -83,8 +80,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance auth token changed. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance auth token changed. got: $STATUS"
fi
@@ -95,8 +91,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
if [ "$STATUS" != "401" ]
then
- echo 'should respond unauthorized without the token, when purging the instance. got:' $STATUS
- exit 1
+ exit_fail "Expected 401 without the token, when purging the instance. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
@@ -106,8 +101,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
if [ "$STATUS" != "401" ]
then
- echo 'should respond unauthorized using old token, when purging the instance. got:' $STATUS
- exit 1
+ exit_fail "Expected 401 using old token, when purging the instance. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
@@ -117,8 +111,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
if [ "$STATUS" != "204" ]
then
- echo 'should respond unauthorized without the token, when purging the instance. got:' $STATUS
- exit 1
+ exit_fail "Expected 204 when purging the instance. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X GET \
@@ -128,10 +121,9 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "404" ]
then
- echo 'should respond not found when trying to list the product and the default instance was deleted. got:' $STATUS
- exit 1
+ exit_fail "Expected 404 when trying to list the product and the default instance was deleted. got: $STATUS"
fi
-echo "OK"
+echo "Test PASSED"
exit 0
diff --git a/src/testing/test_merchant_kyc.sh b/src/testing/test_merchant_kyc.sh
index 996a8895..e7b45ad0 100755
--- a/src/testing/test_merchant_kyc.sh
+++ b/src/testing/test_merchant_kyc.sh
@@ -16,9 +16,13 @@
# License along with TALER; see the file COPYING. If not, see
# <http://www.gnu.org/licenses/>
#
+set -eu
-. initialize_taler_system.sh
+. setup.sh
+# Launch system.
+setup -c "test_template.conf" -m -u "exchange-account-1"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
echo -n "Configuring a merchant instance before configuring the default instance ..."
@@ -30,8 +34,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204 ok, instance created. got: $STATUS"
fi
echo " OK"
@@ -44,8 +47,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, instance exists. got:' $STATUS
- exit 1
+ exit_fail "Expected 200 ok, instance exists. got: $STATUS"
fi
echo " OK"
@@ -58,22 +60,21 @@ RANDOM_IMG='data:image/png;base64,abcdefg'
echo -n "Creating order without TOKEN..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'$RANDOM_IMG'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond 200 OK, order created. got:' $STATUS `cat $LAST_RESPONSE`
+ echo 'should respond 200 OK, order created. got:' $STATUS `cat "$LAST_RESPONSE"`
exit 1
fi
-ORDER_ID=`jq -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -r .token < $LAST_RESPONSE`
+ORDER_ID=`jq -r .order_id < "$LAST_RESPONSE"`
+TOKEN=`jq -r .token < "$LAST_RESPONSE"`
if [ "$TOKEN" != "null" ]
then
- echo 'token should be null, got:' $TOKEN
- exit 1
+ exit_fail "Token should be null, got: $TOKEN"
fi
echo "OK"
@@ -81,14 +82,14 @@ echo "OK"
echo -n "Checking created order without TOKEN..."
STATUS=$(curl http://localhost:9966/orders/$ORDER_ID \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
-PAY_URI=`jq -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URI=`jq -r .taler_pay_uri < "$LAST_RESPONSE"`
if [ "$PAY_URI" == "null" ]
then
- echo 'Expected a taler_pay_uri. Got:' $PAY_URI `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected a taler_pay_uri. Got: $PAY_URI"
fi
echo "OK"
@@ -101,8 +102,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X GET \
if [ "$STATUS" != "204" ]
then
- echo 'should respond 200 OK. got:' $STATUS
- exit 1
+ exit_fail "Expected 204. got: $STATUS"
fi
echo " OK"
diff --git a/src/testing/test_merchant_order_autocleanup.sh b/src/testing/test_merchant_order_autocleanup.sh
index c6266a33..53d11679 100755
--- a/src/testing/test_merchant_order_autocleanup.sh
+++ b/src/testing/test_merchant_order_autocleanup.sh
@@ -1,21 +1,45 @@
#!/bin/bash
# This file is in the public domain.
-. initialize_taler_system.sh
+. setup.sh
+# Launch exchange, merchant and bank.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+CONF="test_template.conf.edited"
+WALLET_DB=$(mktemp test_wallet.json-XXXXXX)
+BANK_URL="http://localhost:18082/demobanks/default/"
+EXCHANGE_URL="http://localhost:8081/"
+
echo -n "First, prepare wallet with coins..."
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'withdrawTestBalance' \
+rm -f "$WALLET_DB"
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ api \
+ --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:99",
bankAccessApiBaseUrl: $BANK_URL,
exchangeBaseUrl: $EXCHANGE_URL
}' \
- --arg BANK_URL "$BANK_URL" \
+ --arg BANK_URL "${BANK_URL}access-api/" \
--arg EXCHANGE_URL "$EXCHANGE_URL"
)" 2>wallet-withdraw-1.err >wallet-withdraw-1.out
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
+echo -n "."
+sleep 10
+echo -n "."
+# NOTE: once libeufin can do long-polling, we should
+# be able to reduce the delay here and run wirewatch
+# always in the background via setup
+taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out
+echo -n "."
+
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
echo " OK"
#
@@ -27,14 +51,13 @@ echo -n "Configuring merchant instance ..."
# create with 2 address
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/management/instances \
+ "http://localhost:9966/management/instances" \
-d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"payto://x-taler-bank/localhost:8082/43"},{"payto_uri":"payto://x-taler-bank/localhost:8082/44"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
# remove one account address
@@ -46,151 +69,159 @@ STATUS=$(curl -H "Content-Type: application/json" -X PATCH \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance updated. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance updated. got: $STATUS"
fi
+echo "OK"
-echo OK
-
-NOW=`date +%s`
-IN_TEN_SECS=`echo $(( $NOW + 5 ))`
+NOW=$(date +%s)
+IN_TEN_SECS=$(( NOW + 10 ))
echo -n "Creating order to be claimed..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme","pay_deadline": {"t_ms":'$NOW'000}}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme","pay_deadline": {"t_s":'"$IN_TEN_SECS"'}}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
echo "Ok (order $ORDER_ID)"
-NOW=`date +%s`
+NOW=$(date +%s)
echo -n "Claim the order but do not pay it ..."
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB advanced pay-prepare "${PAY_URL}" 2> wallet-pay1.err > wallet-pay1.log
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ advanced pay-prepare \
+ "${PAY_URL}" \
+ 2> wallet-claim1.err > wallet-claim1.log
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after pay. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "claimed" ]
then
- echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'paid'. got: $ORDER_STATUS"
fi
-NOW2=`date +%s`
-echo " OK (took $( echo -n $(($NOW2 - $NOW)) ) secs )"
+NOW2=$(date +%s)
+echo " OK (took $(( NOW2 - NOW)) secs)"
-echo 'wait 8 secs '
+echo "Wait 8 secs ..."
sleep 8
echo -n "Trying to get the list of orders..."
STATUS=$(curl "http://localhost:9966/instances/default/private/orders" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok. got: $STATUS"
fi
echo "ok"
echo -n "Creating a new order that will trigger the db cleanup..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
-d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
echo "Ok (order $ORDER_ID)"
echo -n "Trying to get the list of orders (issue #7025)..."
STATUS=$(curl "http://localhost:9966/instances/default/private/orders" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok. got: $STATUS"
fi
-echo ok
+echo "OK"
# set -x
echo -n "Now paying this order..."
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "${PAY_URL}"\
+ -y \
+ 2> wallet-pay1.err > wallet-pay1.log
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after pay. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "paid" ]
then
- echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'paid'. got: $ORDER_STATUS"
fi
-NOW2=`date +%s`
-echo " OK (took $( echo -n $(($NOW2 - $NOW)) ) secs )"
+NOW2=$(date +%s)
+echo " OK (took $(( NOW2 - NOW)) secs )"
echo -n "Trying to get the list of orders..."
STATUS=$(curl "http://localhost:9966/instances/default/private/orders" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok. got: $STATUS"
fi
echo ok
@@ -198,61 +229,69 @@ echo ok
echo -n "Finally, create another order..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
-d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, getting order info before claiming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
echo "Ok (order $ORDER_ID)"
echo -n "Now paying this order..."
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ handle-uri \
+ "${PAY_URL}" \
+ -y \
+ 2> wallet-pay1.err > wallet-pay1.log
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "paid" ]
then
- echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'paid'. got: $ORDER_STATUS"
fi
-NOW2=`date +%s`
+NOW2=$(date +%s)
echo " OK (took $( echo -n $(($NOW2 - $NOW)) ) secs )"
echo -n "Trying to get the list of orders..."
STATUS=$(curl "http://localhost:9966/instances/default/private/orders" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok. got: $STATUS"
fi
-echo ok
+echo "ok"
+
+echo "Test PASSED"
exit 0
diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh
index 1b1aeb23..479caeaa 100755
--- a/src/testing/test_merchant_order_creation.sh
+++ b/src/testing/test_merchant_order_creation.sh
@@ -3,36 +3,48 @@
set -eu
-. initialize_taler_system.sh
-
-# $1: sandbox username
-# $2: sandbox password
-# $3: payto with subject
-# $4: amount
-function wire_funds() {
- libeufin-cli sandbox demobank new-transaction
+function clean_wallet() {
+ rm -f "${WALLET_DB}"
+ exit_cleanup
}
+. setup.sh
+# Launch exchange, merchant and bank.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+CONF="test_template.conf.edited"
+WALLET_DB=$(mktemp test_wallet.json-XXXXXX)
+BANK_URL="http://localhost:18082/demobanks/default/"
+EXCHANGE_URL="http://localhost:8081/"
+
+# Install cleanup handler (except for kill -9)
+trap clean_wallet EXIT
+
echo -n "First prepare wallet with coins ..."
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'withdrawTestBalance' \
+rm -f "$WALLET_DB"
+taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" api --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:99",
bankAccessApiBaseUrl: $BANK_URL,
exchangeBaseUrl: $EXCHANGE_URL
}' \
- --arg BANK_URL "$BANK_URL/access-api/" \
+ --arg BANK_URL "${BANK_URL}access-api/" \
--arg EXCHANGE_URL "$EXCHANGE_URL"
)" 2>wallet-withdraw-1.err >wallet-withdraw-1.out
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
+# FIXME-MS: add logic to have nexus check immediately here.
+sleep 10
+# NOTE: once libeufin can do long-polling, we should
+# be able to reduce the delay here and run wirewatch
+# always in the background via setup
+taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out
+taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
echo " OK"
-CURRENCY_COUNT=$(taler-wallet-cli --wallet-db=$WALLET_DB balance | jq '.balances|length')
+CURRENCY_COUNT=$(taler-wallet-cli --wallet-db="$WALLET_DB" balance | jq '.balances|length')
if [ "$CURRENCY_COUNT" = "0" ]
then
- echo 'should have at least one currency, withdrawal failed. check log.'
- exit 1
+ exit_fail "Expected least one currency, withdrawal failed. check log."
fi
#
@@ -42,17 +54,16 @@ fi
echo -n "Configuring merchant instance ..."
# create with 2 address
-FORTYTHREE=`get_payto_uri fortythree x`
+FORTYTHREE=$(get_payto_uri fortythree x)
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'$FORTYTHREE'"},{"payto_uri":"payto://iban/SANDBOXX/DE270744?receiver-name=Forty+Four"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'"$FORTYTHREE"'"},{"payto_uri":"payto://iban/SANDBOXX/DE270744?receiver-name=Forty+Four"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo "Expected '204 No content' response. Got instead $STATUS"
- exit 1
+ exit_fail "Expected '204 No content' response. Got instead $STATUS"
fi
# remove one account address
@@ -60,13 +71,12 @@ fi
STATUS=$(curl -H "Content-Type: application/json" -X PATCH \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/instances/default/private/ \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'$FORTYTHREE'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'"$FORTYTHREE"'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo "Expected '204 No content' response. Got instead: $STATUS"
- exit 1
+ exit_fail "Expected '204 No content' response. Got instead: $STATUS"
fi
echo "OK"
@@ -78,37 +88,33 @@ RANDOM_IMG='data:image/png;base64,abcdefg'
echo -n "Creating order without TOKEN..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'$RANDOM_IMG'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -r .token < "$LAST_RESPONSE")
if [ "$TOKEN" != "null" ]
then
- echo 'token should be null, got:' $TOKEN
- exit 1
+ exit_fail "token should be null, got: $TOKEN"
fi
echo "OK"
echo -n "Checking created order without TOKEN..."
-
-STATUS=$(curl http://localhost:9966/orders/$ORDER_ID \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
-
-PAY_URI=`jq -r .taler_pay_uri < $LAST_RESPONSE`
-
+STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID" \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+PAY_URI=$(jq -r .taler_pay_uri < "$LAST_RESPONSE")
if [ "$PAY_URI" == "null" ]
then
- echo 'should have a payuri. got:' $PAY_URI `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected non-NULL payuri. got $PAY_URI"
fi
echo "OK"
@@ -118,40 +124,39 @@ echo "OK"
echo -n "Creating order without TOKEN and fullfilment URL..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"create_token":false,"order":{"fulfillment_url":"go_here_please", "amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'$RANDOM_IMG'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"create_token":false,"order":{"fulfillment_url":"go_here_please", "amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -r .token < "$LAST_RESPONSE")
if [ "$TOKEN" != "null" ]
then
- echo 'token should be null, got:' $TOKEN
- exit 1
+ exit_fail "Token should be null, got: $TOKEN"
fi
-STATUS=$(curl http://localhost:9966/orders/$ORDER_ID \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID" \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
-PAY_URI=`jq -r .taler_pay_uri < $LAST_RESPONSE`
-FULLFILMENT_URL=`jq -r .fulfillment_url < $LAST_RESPONSE`
+PAY_URI=$(jq -r .taler_pay_uri < "$LAST_RESPONSE")
+FULLFILMENT_URL=$(jq -r .fulfillment_url < "$LAST_RESPONSE")
if [ "$FULLFILMENT_URL" != "go_here_please" ]
then
- echo 'should have a payuri. got:' $PAY_URI `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected a pay URI. got: $PAY_URI"
fi
if [ "$PAY_URI" == "null" ]
then
- echo 'should have a payuri. got:' $PAY_URI `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected non-NULL pay URI. Got: $PAY_URI"
fi
echo "OK"
@@ -161,40 +166,38 @@ echo "OK"
echo -n "Creating order with non-inventory products..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'$RANDOM_IMG'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -r .token < "$LAST_RESPONSE")
-STATUS=$(curl http://localhost:9966/orders/$ORDER_ID/claim \
- -d '{"nonce":"","token":"'$TOKEN'"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID"/claim \
+ -d '{"nonce":"","token":"'"$TOKEN"'"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order claimed. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order claimed. got: $STATUS"
fi
-QUANTITY=`jq -r .contract_terms.products[0].quantity < $LAST_RESPONSE`
+QUANTITY=$(jq -r .contract_terms.products[0].quantity < "$LAST_RESPONSE")
if [ "$QUANTITY" != "1" ]
then
- echo 'should get quantity 1. got:' $QUANTITY # `jq .contract_terms.products[0] < $LAST_RESPONSE`
- exit 1
+ exit_fail "Expected quantity 1. got: $QUANTITY"
fi
-IMAGE=`jq -r .contract_terms.products[0].image < $LAST_RESPONSE`
+IMAGE=$(jq -r .contract_terms.products[0].image < "$LAST_RESPONSE")
if [ "$IMAGE" != "$RANDOM_IMG" ]
then
- echo 'should get image but got something else. got:' $IMAGE
- exit 1
+ exit_fail "Expected $RANDOM_IMG but got something else: $IMAGE"
fi
echo "OK"
@@ -210,42 +213,40 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, product created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, product created. got: $STATUS"
fi
echo "OK"
echo -n "Creating order with inventory products..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
-d '{"order":{"amount":"TESTKUDOS:7","summary":"3"},"inventory_products":[{"product_id":"2","quantity":1}]}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'Expected 200 OK, order created response. Got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200 OK, order created response. Got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
-STATUS=$(curl http://localhost:9966/orders/$ORDER_ID/claim \
- -d '{"nonce":"","token":"'$TOKEN'"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID"/claim \
+ -d '{"nonce":"","token":"'"$TOKEN"'"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order claimed. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200, order claimed. got: $STATUS"
fi
-QUANTITY=`jq -r .contract_terms.products[0].quantity < $LAST_RESPONSE`
+QUANTITY=$(jq -r .contract_terms.products[0].quantity < "$LAST_RESPONSE")
if [ "$QUANTITY" != "1" ]
then
- echo 'should get quantity 1. got:' $QUANTITY #`jq .contract_terms.products[0] < $LAST_RESPONSE`
- exit 1
+ exit_fail "Expected quantity 1. got: $QUANTITY"
fi
echo "OK"
@@ -261,8 +262,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
if [ "$STATUS" != "400" ]
then
- echo 'should respond bad request, product price is in another currency. got:' $STATUS
- exit 1
+ exit_fail "Expected 400 bad request, product price is in another currency. got: $STATUS"
fi
#
@@ -272,72 +272,76 @@ fi
echo -n "Creating order to be paid..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
-d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"inventory_products":[{"product_id":"2","quantity":1}]}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
echo "OK"
-NOW=`date +%s`
+NOW=$(date +%s)
echo -n "Pay first order ${PAY_URL} ..."
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB run-until-done 2> wallet-finish-pay1.err > wallet-finish-pay1.log
-NOW2=`date +%s`
-echo " OK (took $( echo -n $(($NOW2 - $NOW)) ) secs )"
+taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
+taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" run-until-done 2> wallet-finish-pay1.err > wallet-finish-pay1.log
+NOW2=$(date +%s)
+echo " OK (took $(( NOW2 - NOW )) secs )"
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200, after pay. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "paid" ]
then
- echo "Order status should be 'paid'. got:" $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Order status should be 'paid'. got: $ORDER_STATUS"
fi
#
# WIRE TRANSFER TO MERCHANT AND NOTIFY BACKEND
#
-PAY_DEADLINE=`jq -r .contract_terms.pay_deadline.t_s < $LAST_RESPONSE`
-WIRE_DEADLINE=`jq -r .contract_terms.wire_transfer_deadline.t_s < $LAST_RESPONSE`
+# PAY_DEADLINE=$(jq -r .contract_terms.pay_deadline.t_s < "$LAST_RESPONSE")
+WIRE_DEADLINE=$(jq -r .contract_terms.wire_transfer_deadline.t_s < "$LAST_RESPONSE")
-NOW=`date +%s`
+NOW=$(date +%s)
-TO_SLEEP=`echo $(( $WIRE_DEADLINE - $NOW ))`
+TO_SLEEP=$(( WIRE_DEADLINE - NOW ))
echo "Waiting $TO_SLEEP secs for wire transfer"
echo -n "Perform wire transfers ..."
-taler-exchange-aggregator -y -c $CONF -T ${TO_SLEEP}000000 -t -L INFO &> aggregator.log
-taler-exchange-transfer -c $CONF -t -L INFO &> transfer.log
+taler-exchange-aggregator -y -c "$CONF" -T "${TO_SLEEP}"000000 -t -L INFO &> aggregator.log
+taler-exchange-transfer -c "$CONF" -t -L INFO &> transfer.log
echo " DONE"
echo -n "Give time to Nexus to route the payment to Sandbox..."
+# FIXME-MS: trigger immediate update at nexus
+# NOTE: once libeufin can do long-polling, we should
+# be able to reduce the delay here and run aggregator/transfer
+# always in the background via setup
sleep 3
echo " DONE"
@@ -346,12 +350,12 @@ echo -n "Obtaining wire transfer details from bank..."
# the wire transfer information _via the exchange_ bank
# account. NOTE: grabbing tx == 0, since the latest
# transaction appear first in the bank's history.
-BANKDATA=`get_bankaccount_transactions exchange x | jq '.transactions[0]'`
-SUBJECT=`echo $BANKDATA | jq -r .subject`
-WTID=`echo $SUBJECT | awk '{print $1}'`
-WURL=`echo $SUBJECT | awk '{print $2}'`
-CREDIT_AMOUNT="`echo $BANKDATA | jq -r .currency`:`echo $BANKDATA | jq -r .amount`"
-TARGET=`echo $BANKDATA | jq -r .creditorIban`
+BANKDATA=$(get_bankaccount_transactions exchange x | jq '.transactions[0]')
+SUBJECT=$(echo "$BANKDATA" | jq -r .subject)
+WTID=$(echo "$SUBJECT" | awk '{print $1}')
+WURL=$(echo "$SUBJECT" | awk '{print $2}')
+CREDIT_AMOUNT="$(echo "$BANKDATA" | jq -r .currency):$(echo "$BANKDATA" | jq -r .amount)"
+TARGET=$(echo "$BANKDATA" | jq -r .creditorIban)
# 'TARGET' is now the IBAN.
TARGET_PAYTO="payto://iban/SANDBOXX/$TARGET?receiver-name=Forty+Three"
@@ -373,13 +377,13 @@ export LAST_RESPONSE
echo -n "Notifying merchant of bogus wire transfer ..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -d '{"credit_amount":"'$CREDIT_AMOUNT'1","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \
+ -d '{"credit_amount":"'"$CREDIT_AMOUNT"'1","wtid":"'"$WTID"'","payto_uri":"'"$TARGET_PAYTO"'","exchange_url":"'"$WURL"'"}' \
-m 3 \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected to fail since the amount is not valid. got: $STATUS"
fi
@@ -388,13 +392,13 @@ echo "OK"
echo -n "Notifying merchant of correct wire transfer (conflicting with old data)..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \
+ -d '{"credit_amount":"'"$CREDIT_AMOUNT"'","wtid":"'"$WTID"'","payto_uri":"'"$TARGET_PAYTO"'","exchange_url":"'"$WURL"'"}' \
-m 3 \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "409" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response conflict, after providing conflicting transfer data. got: $STATUS"
fi
@@ -402,23 +406,23 @@ echo " OK"
echo -n "Deleting bogus wire transfer ..."
-TID=`curl -s http://localhost:9966/instances/default/private/transfers | jq -r .transfers[0].transfer_serial_id`
+TID=$(curl -s http://localhost:9966/instances/default/private/transfers | jq -r .transfers[0].transfer_serial_id)
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
"http://localhost:9966/instances/default/private/transfers/$TID" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 204 No Content, after deleting valid TID. got: $STATUS"
fi
STATUS=$(curl -H "Content-Type: application/json" -X DELETE \
"http://localhost:9966/instances/default/private/transfers/$TID" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "404" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 404 Not found, after deleting TID again. got: $STATUS"
fi
@@ -427,13 +431,13 @@ echo " OK"
echo -n "Notifying merchant of correct wire transfer (now working)..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \
+ -d '{"credit_amount":"'"$CREDIT_AMOUNT"'","wtid":"'"$WTID"'","payto_uri":"'"$TARGET_PAYTO"'","exchange_url":"'"$WURL"'"}' \
-m 3 \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 204 No content, after providing transfer data. got: $STATUS"
fi
@@ -446,65 +450,57 @@ set -e
# Test idempotence: do it again!
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"credit_amount":"'"$CREDIT_AMOUNT"'","wtid":"'"$WTID"'","payto_uri":"'"$TARGET_PAYTO"'","exchange_url":"'"$WURL"'"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response No Content, after providing transfer data. got: $STATUS"
fi
echo " OK"
echo -n "Testing taler-merchant-exchange ..."
set -e
-taler-merchant-exchange -L INFO -c $CONF -t &> taler-merchant-exchange.log
+taler-merchant-exchange -L INFO -c "$CONF" -t &> taler-merchant-exchange.log
echo " OK"
echo -n "Fetching wire transfers ..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 200 Ok. got: $STATUS"
fi
-TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < "$LAST_RESPONSE")
if [ "$TRANSFERS_LIST_SIZE" != "1" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected 1 entry in transfer list. Got: $TRANSFERS_LIST_SIZE"
fi
echo "OK"
echo -n "Checking order status ..."
-
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}?transfer=YES" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
-
-
-
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
- exit_fail 'should respond 200 ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200, after order inquiry. got: $STATUS"
fi
-
-DEPOSIT_TOTAL=`jq -r .deposit_total < $LAST_RESPONSE`
-
+DEPOSIT_TOTAL=$(jq -r .deposit_total < "$LAST_RESPONSE")
if [ "$DEPOSIT_TOTAL" == "TESTKUDOS:0" ]
then
- echo 'deposit total is zero, expected greater than zero. got:' $DEPOSIT_TOTAL `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected non-zero deposit total. got: $DEPOSIT_TOTAL"
fi
-
echo " OK"
ACCOUNT_PASSWORD="fortythree:x"
@@ -512,39 +508,29 @@ BANK_HOST="localhost:18082"
# Can be replaced by the libeufin-cli way.
STATUS=$(curl "http://$ACCOUNT_PASSWORD@$BANK_HOST/demobanks/default/access-api/accounts/fortythree" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
-
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
- echo "Expected response 200 Ok, getting account status. Got: $STATUS"
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected response 200 Ok, getting account status. Got: $STATUS"
fi
-
-BALANCE=`jq -r .balance.amount < $LAST_RESPONSE`
-
+BALANCE=$(jq -r .balance.amount < "$LAST_RESPONSE")
if [ "$BALANCE" == "TESTKUDOS:0" ]
then
- jq . < $LAST_RESPONSE
- echo "Wire transfer did not happen. Got: $BALANCE"
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Wire transfer did not happen. Got: $BALANCE"
fi
-
echo " OK"
echo -n "Getting information about kyc ..."
-
STATUS=$(curl -H "Content-Type: application/json" -X GET \
http://localhost:9966/instances/default/private/kyc \
-w "%{http_code}" -s -o /dev/null)
-
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204. Got: $STATUS"
fi
-
echo " OK"
exit 0
diff --git a/src/testing/test_merchant_product_creation.sh b/src/testing/test_merchant_product_creation.sh
index 738b7d5e..651ee060 100755
--- a/src/testing/test_merchant_product_creation.sh
+++ b/src/testing/test_merchant_product_creation.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -17,26 +17,35 @@
# <http://www.gnu.org/licenses/>
#
-. initialize_taler_system.sh
+set -eu
+
+. setup.sh
+
+# Launch system.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+WALLET_DB=$(mktemp test_wallet.json-XXXXXX)
+CONF="test_template.conf.edited"
+BANK_URL="http://localhost:18082/demobanks/default/"
+FORTYTHREE=$(get_payto_uri fortythree x)
+EXCHANGE_URL="http://localhost:8081/"
-FORTYTHREE=`get_payto_uri fortythree x`
echo -n "Configuring merchant instance ..."
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
- http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'$FORTYTHREE'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+ "http://localhost:9966/management/instances" \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'"$FORTYTHREE"'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo "Should have responded 204 No content, instance created. Got $STATUS instead"
- exit 1
+ exit_fail "Expected 204 No content, instance created. Got $STATUS instead"
fi
-echo OK
-RANDOM_IMG='data:image/png;base64,abcdefg'
+echo "OK"
-INFINITE_PRODUCT_TEMPLATE='{"product_id":"2","description":"product with id 2 and price :15","price":"TESTKUDOS:15","total_stock":-1,"unit":"","image":"'$RANDOM_IMG'","taxes":[]}'
-MANAGED_PRODUCT_TEMPLATE='{"product_id":"3","description":"product with id 3 and price :10","price":"TESTKUDOS:150","total_stock":2,"unit":"","image":"'$RANDOM_IMG'","taxes":[]}'
+RANDOM_IMG='data:image/png;base64,abcdefg'
+INFINITE_PRODUCT_TEMPLATE='{"product_id":"2","description":"product with id 2 and price :15","price":"TESTKUDOS:15","total_stock":-1,"unit":"","image":"'"$RANDOM_IMG"'","taxes":[]}'
+MANAGED_PRODUCT_TEMPLATE='{"product_id":"3","description":"product with id 3 and price :10","price":"TESTKUDOS:150","total_stock":2,"unit":"","image":"'"$RANDOM_IMG"'","taxes":[]}'
echo -n "Creating products..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
@@ -45,8 +54,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, product created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, product created. got: $STATUS"
fi
STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
@@ -55,125 +63,120 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/products' \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, product created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, product created. got: $STATUS"
fi
-echo OK
+echo "OK"
-PRODUCT_DATA=$(echo $INFINITE_PRODUCT_TEMPLATE | jq 'del(.product_id) | . + {description: "other description"}')
+PRODUCT_DATA=$(echo "$INFINITE_PRODUCT_TEMPLATE" | jq 'del(.product_id) | . + {description: "other description"}')
echo -n "Updating infinite stock product..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/products/2' -X PATCH \
-d "$PRODUCT_DATA" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, updating product. got:' $STATUS
- cat $LAST_RESPONSE
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 204, updating product. got: $STATUS"
fi
STATUS=$(curl 'http://localhost:9966/instances/default/private/products/2' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
-DESCRIPTION=`jq -r .description < $LAST_RESPONSE`
+DESCRIPTION=$(jq -r .description < "$LAST_RESPONSE")
if [ "$DESCRIPTION" != "other description" ]
then
- echo 'should change description. got:' $DESCRIPTION
- cat $LAST_RESPONSE
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'other description'. Got: $DESCRIPTION"
fi
-echo OK
+echo "OK"
-MANAGED_PRODUCT_ID=$(echo $MANAGED_PRODUCT_TEMPLATE | jq -r '.product_id')
+MANAGED_PRODUCT_ID=$(echo "$MANAGED_PRODUCT_TEMPLATE" | jq -r '.product_id')
echo -n "Locking inventory ..."
STATUS=$(curl "http://localhost:9966/instances/default/private/products/${MANAGED_PRODUCT_ID}/lock" \
-d '{"lock_uuid":"luck","duration":{"d_us": 100000000},"quantity":10}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "410" ]
then
- echo 'should respond gone, lock failed. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 410, lock failed. got: $STATUS"
fi
echo -n "."
STATUS=$(curl "http://localhost:9966/instances/default/private/products/${MANAGED_PRODUCT_ID}/lock" \
-d '{"lock_uuid":"luck","duration":{"d_us": 100000000},"quantity":1}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, lock created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 204, lock created. got: $STATUS"
fi
-
echo " OK"
-
echo -n "Creating order to be paid..."
-
-
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"inventory_products":[{"product_id":"'${MANAGED_PRODUCT_ID}'","quantity":1}]}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"inventory_products":[{"product_id":"'"${MANAGED_PRODUCT_ID}"'","quantity":1}]}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+#TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
echo -n "."
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"inventory_products":[{"product_id":"'${MANAGED_PRODUCT_ID}'","quantity":1}]}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"inventory_products":[{"product_id":"'"${MANAGED_PRODUCT_ID}"'","quantity":1}]}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "410" ]
then
- echo 'should respond out of stock (what remains is locked). got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 410 out of stock (what remains is locked). got: $STATUS"
fi
echo -n "."
# Using the 'luck' inventory lock, order creation should work.
STATUS=$(curl 'http://localhost:9966/instances/default/private/orders' \
- -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"lock_uuids":["luck"],"inventory_products":[{"product_id":"'$MANAGED_PRODUCT_ID'","quantity":1}]}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"},"lock_uuids":["luck"],"inventory_products":[{"product_id":"'"$MANAGED_PRODUCT_ID"'","quantity":1}]}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'Should respond 200 OK, lock should apply. Got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 OK, lock should apply. Got: $STATUS"
fi
-
-
echo " OK"
echo -n "First withdraw wallet ..."
-rm -f $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'withdrawTestBalance' \
+rm -f "$WALLET_DB"
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ api \
+ --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:5",
@@ -184,49 +187,63 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'with
--arg EXCHANGE_URL "$EXCHANGE_URL"
)" 2>wallet-withdraw-1.err >wallet-withdraw-1.out
echo -n "."
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
+sleep 10
+# NOTE: once libeufin can do long-polling, we should
+# be able to reduce the delay here and run wirewatch
+# always in the background via setup
+echo -n "."
+taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out
+echo -n "."
+
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
echo " OK"
echo -n "Pay first order ..."
-NOW=`date +%s`
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
-NOW2=`date +%s`
-echo " OK (took $( echo -n $(($NOW2 - $NOW)) ) secs )"
+NOW=$(date +%s)
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "${PAY_URL}" \
+ -y \
+ 2> wallet-pay1.err > wallet-pay1.log
+NOW2=$(date +%s)
+echo " OK (took $(( NOW2 - NOW)) secs )"
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after pay. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "paid" ]
then
- echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'paid'. got: $ORDER_STATUS"
fi
echo -n "Updating product..."
-PRODUCT_DATA=$(echo $MANAGED_PRODUCT_TEMPLATE | jq 'del(.product_id) | . + {"total_stock": (.total_stock + 2) }')
+PRODUCT_DATA=$(echo "$MANAGED_PRODUCT_TEMPLATE" | jq 'del(.product_id) | . + {"total_stock": (.total_stock + 2) }')
STATUS=$(curl 'http://localhost:9966/instances/default/private/products/3' -X PATCH \
-d "$PRODUCT_DATA" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, updating product. got:' $STATUS
- cat $LAST_RESPONSE
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 204, updating product. got: $STATUS"
fi
-
echo " OK"
exit 0
diff --git a/src/testing/test_merchant_reserve_creation.sh b/src/testing/test_merchant_reserve_creation.sh
index f68c4834..6a45e387 100755
--- a/src/testing/test_merchant_reserve_creation.sh
+++ b/src/testing/test_merchant_reserve_creation.sh
@@ -19,18 +19,18 @@
set -eu
-. initialize_taler_system.sh
+. setup.sh
+# Launch exchange, merchant and bank.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+CONF="test_template.conf.edited"
echo -n "Configuring merchant instance ..."
-# create instance
-FORTYTHREE=`get_payto_uri fortythree x`
-echo -n "."
-
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"payto://x-taler-bank/localhost:1'$NEXUS_PORT'/43"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"payto://x-taler-bank/localhost:18082/43"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
@@ -40,142 +40,153 @@ fi
echo "OK"
echo -n "Creating reserve ..."
+#bash
+
STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves' \
- -d '{"initial_balance":"TESTKUDOS:2","exchange_url":"'$EXCHANGE_URL'","wire_method":"iban"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"initial_balance":"TESTKUDOS:2","exchange_url":"http://localhost:8081/","wire_method":"iban"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
+ cat "$LAST_RESPONSE"
exit_fail "Expected 200, reserve created. Got instead: $STATUS"
fi
echo "OK"
-RESERVE_PUB=`jq -r .reserve_pub < $LAST_RESPONSE`
+RESERVE_PUB=$(jq -r .reserve_pub < "$LAST_RESPONSE")
-STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERVE_PUB \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'"$RESERVE_PUB" \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
-FUNDED=`jq -r '.merchant_initial_amount == .exchange_initial_amount' < $LAST_RESPONSE`
+FUNDED=$(jq -r '.merchant_initial_amount == .exchange_initial_amount' < "$LAST_RESPONSE")
if [ "$FUNDED" != "false" ]
then
- cat $LAST_RESPONSE
- exit_fail "Should not yet be funded if we just created. Got: $STATUS is founded: $FUNDED"
+ cat "$LAST_RESPONSE"
+ exit_fail "Should not yet be funded if we just created. Got: $STATUS is founded: $FUNDED"
fi
echo -n "Wire transferring... "
# Exchange wants TESTKUDOS:2 from account 43, under RESERVE_PUB.
-EXCHANGE_PAYTO=`get_payto_uri exchange x`
+EXCHANGE_PAYTO=$(get_payto_uri exchange x)
export LIBEUFIN_SANDBOX_USERNAME=fortythree
export LIBEUFIN_SANDBOX_PASSWORD=x
export LIBEUFIN_SANDBOX_URL="http://localhost:18082/"
libeufin-cli sandbox demobank new-transaction \
- --bank-account fortythree \
+ --bank-account "fortythree" \
--payto-with-subject "$EXCHANGE_PAYTO&message=$RESERVE_PUB" \
- --amount TESTKUDOS:2
+ --amount "TESTKUDOS:2"
unset LIBEUFIN_SANDBOX_USERNAME
unset LIBEUFIN_SANDBOX_PASSWORD
unset LIBEUFIN_SANDBOX_URL
echo "OK"
-echo -n "Give Nexus time to detect the payment... "
+echo -n "Give Nexus time to detect the payment (FIXME)... "
sleep 10 # FIXME-MS: replace with call to Nexus to right now poll the sandbox ...
+# This seems to not work (exchange user unknown). Not sure why.
+#export LIBEUFIN_NEXUS_USERNAME=exchange
+#export LIBEUFIN_NEXUS_PASSWORD=x
+#export LIBEUFIN_NEXUS_URL="http://localhost:8082/"
+#libeufin-cli \
+# accounts \
+# fetch-transactions \
+# exchange \
+# &> libeufin-transfer-fetch.out
+#unset LIBEUFIN_NEXUS_USERNAME
+#unset LIBEUFIN_NEXUS_PASSWORD
+#unset LIBEUFIN_NEXUS_URL
echo "OK"
-# Stop existing background service, we need to run it here, now, and only once
-kill -TERM $WIREWATCH_PID
-wait $WIREWATCH_PID
-
-taler-exchange-wirewatch -c $CONF -t -L INFO &> taler-exchange-wirewatch.log
+echo "Fetch transaction for exchange"
+# Run wirewatch here, now, and only once
+taler-exchange-wirewatch \
+ -c "$CONF" \
+ -t \
+ -L "INFO" \
+ &> taler-exchange-wirewatch.log
-STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERVE_PUB \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
-
-export LAST_RESPONSE
-
-FUNDED=`jq -r '.merchant_initial_amount == .exchange_initial_amount' < $LAST_RESPONSE`
+STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'"$RESERVE_PUB" \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+FUNDED=$(jq -r '.merchant_initial_amount == .exchange_initial_amount' < "$LAST_RESPONSE")
if [ "$FUNDED" != "true" ]
then
- cat $LAST_RESPONSE
- exit_fail "should be funded. got: $STATUS is founded: $FUNDED"
+ cat "$LAST_RESPONSE"
+ exit_fail "should be funded. got: $STATUS is founded: $FUNDED"
fi
-ACCOUNTS=`jq -r '.accounts|length' < $LAST_RESPONSE`
-
+ACCOUNTS=$(jq -r '.accounts|length' < "$LAST_RESPONSE")
if [ "x$ACCOUNTS" != "x1" ]
then
- cat $LAST_RESPONSE
+ cat "$LAST_RESPONSE"
exit_fail "Expected 1 account in response. got: $ACCOUNTS"
fi
echo -n "authorizing tip ..."
-STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERVE_PUB'/authorize-tip' \
+STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'"$RESERVE_PUB"'/authorize-tip' \
-d '{"amount":"TESTKUDOS:1","justification":"off course","next_url":"https://taler.net/"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
exit_fail "should respond failed, we did not fund yet. got: $STATUS"
fi
+echo "OK"
-echo OK
-
-echo -n Checking tip ....
-STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERVE_PUB'?tips=yes' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+echo -n "Checking tip ..."
+STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'"$RESERVE_PUB"'?tips=yes' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
-TIPS_SIZE=`jq -r ".tips | length" < $LAST_RESPONSE`
+TIPS_SIZE=$(jq -r ".tips | length" < "$LAST_RESPONSE")
if [ "$TIPS_SIZE" != "1" ]
then
- cat $LAST_RESPONSE
- exit_fail "should respond 1, just 1 tip. got: $TIPS_SIZE"
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 1 tip. got: $TIPS_SIZE"
fi
-TIP_ID=`jq -r .tips[0].tip_id < $LAST_RESPONSE`
+TIP_ID=$(jq -r .tips[0].tip_id < "$LAST_RESPONSE")
-echo found
+echo "Found"
-echo -n Checking tip status ....
+echo -n "Checking tip status ..."
-STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'$TIP_ID \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'"$TIP_ID" \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- cat $LAST_RESPONSE
- exit_fail "should respond ok, tip found. got: $STATUS"
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200, tip found. got: $STATUS"
fi
echo -n " ... "
-STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'$TIP_ID'?pickups=yes' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+STATUS=$(curl 'http://localhost:9966/instances/default/private/tips/'"$TIP_ID"'?pickups=yes' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- cat $LAST_RESPONSE
- exit_fail "should respond ok, tip found. got: $STATUS"
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200, tip found. got: $STATUS"
fi
-
-echo OK
+echo "OK"
echo -n "trying to create invalid reserve ..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves' \
- -d '{"initial_balance":"INVALID:2","exchange_url":"'$EXCHANGE_URL'","wire_method":"iban"}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -d '{"initial_balance":"INVALID:2","exchange_url":"http://localhost:8081/","wire_method":"iban"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "400" ]
then
- exit_fail "Should respond invalid, bad currency. got: $STATUS"
+ exit_fail "Expected 400, bad currency. got: $STATUS"
fi
+echo "FAILED (which is expected)"
-echo "FAILED (which is ok)"
-
+echo "Test PASSED"
exit 0
diff --git a/src/testing/test_merchant_transfer_tracking.sh b/src/testing/test_merchant_transfer_tracking.sh
index 0bd64b3e..c10fce33 100755
--- a/src/testing/test_merchant_transfer_tracking.sh
+++ b/src/testing/test_merchant_transfer_tracking.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
@@ -18,21 +18,48 @@
#
# Testcase for #6912 (failed to reproduce so far)
-. initialize_taler_system.sh
+set -eu
+
+. setup.sh
+
+# Launch system.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+WALLET_DB=$(mktemp test_wallet.json-XXXXXX)
+CONF="test_template.conf.edited"
+#FORTYTHREE=$(get_payto_uri merchant x)
+BANK_URL="http://localhost:18082/demobanks/default/"
+EXCHANGE_URL="http://localhost:8081/"
echo -n "First prepare wallet with coins..."
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 'withdrawTestBalance' \
+rm -f "$WALLET_DB"
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ api \
+ --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:99",
bankAccessApiBaseUrl: $BANK_URL,
exchangeBaseUrl: $EXCHANGE_URL
}' \
- --arg BANK_URL "$BANK_URL/access-api/" \
+ --arg BANK_URL "${BANK_URL}access-api/" \
--arg EXCHANGE_URL "$EXCHANGE_URL"
)" 2>wallet-withdraw-1.err >wallet-withdraw-1.out
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
+echo -n "."
+sleep 10
+echo -n "."
+# NOTE: once libeufin can do long-polling, we should
+# be able to reduce the delay here and run wirewatch
+# always in the background via setup
+taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out
+echo -n "."
+
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
echo " OK"
#
@@ -40,104 +67,103 @@ echo " OK"
#
echo -n "Configuring merchant default instance ..."
-TOR_PAYTO=`get_payto_uri tor x`
-GNUNET_PAYTO=`get_payto_uri gnunet x`
+TOR_PAYTO=$(get_payto_uri tor x)
+GNUNET_PAYTO=$(get_payto_uri gnunet x)
# create with 2 address
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'$TOR_PAYTO'"},{"payto_uri":"'$GNUNET_PAYTO'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'"$TOR_PAYTO"'"},{"payto_uri":"'"$GNUNET_PAYTO"'"}],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
-
-echo OK
-
+echo "OK"
echo -n "Configuring merchant test instance ..."
-SURVEY_PAYTO=`get_payto_uri survey x`
-TUTORIAL_PAYTO=`get_payto_uri tutorial x`
+SURVEY_PAYTO=$(get_payto_uri survey x)
+TUTORIAL_PAYTO=$(get_payto_uri tutorial x)
# create with 2 address
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
- -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'$SURVEY_PAYTO'"},{"payto_uri":"'$TUTORIAL_PAYTO'"}],"id":"test","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+ -d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"'"$SURVEY_PAYTO"'"},{"payto_uri":"'"$TUTORIAL_PAYTO"'"}],"id":"test","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
-w "%{http_code}" -s -o /dev/null)
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
-echo OK
-
-RANDOM_IMG='data:image/png;base64,abcdefg'
+echo "OK"
# CREATE ORDER AND SELL IT
echo -n "Creating order to be paid..."
STATUS=$(curl 'http://localhost:9966/instances/test/private/orders' \
-d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+#TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
-echo OK
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
+echo "OK"
-NOW=`date +%s`
+NOW=$(date +%s)
echo -n "Pay first order ..."
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" -y 2> wallet-pay1.err > wallet-pay1.log
-NOW2=`date +%s`
-echo " OK (took $( echo -n $(($NOW2 - $NOW))) secs)"
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "${PAY_URL}" \
+ -y \
+ 2> wallet-pay1.err > wallet-pay1.log
+NOW2=$(date +%s)
+echo " OK (took $(( NOW2 - NOW )) secs)"
STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should respond ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after pay. got: $STATUS"
fi
-ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+ORDER_STATUS=$(jq -r .order_status < "$LAST_RESPONSE")
if [ "$ORDER_STATUS" != "paid" ]
then
- echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE"
+ exit_fail "Expected 'paid'. got: $ORDER_STATUS"
fi
#
# WIRE TRANSFER TO MERCHANT AND NOTIFY BACKEND
#
-PAY_DEADLINE=`jq -r .contract_terms.pay_deadline.t_s < $LAST_RESPONSE`
-WIRE_DEADLINE=`jq -r .contract_terms.wire_transfer_deadline.t_s < $LAST_RESPONSE`
+#PAY_DEADLINE=$(jq -r .contract_terms.pay_deadline.t_s < "$LAST_RESPONSE")
+WIRE_DEADLINE=$(jq -r .contract_terms.wire_transfer_deadline.t_s < "$LAST_RESPONSE")
-NOW=`date +%s`
+NOW=$(date +%s)
-TO_SLEEP=`echo $(( $WIRE_DEADLINE - $NOW ))`
+TO_SLEEP=$(( WIRE_DEADLINE - NOW ))
echo "waiting $TO_SLEEP secs for wire transfer"
echo -n "Perform wire transfers ..."
@@ -154,20 +180,20 @@ echo -n "Obtaining wire transfer details from bank..."
# the wire transfer information _via the exchange_ bank
# account. NOTE: grabbing tx == 0, since the latest
# transaction appear first in the bank's history.
-export BANKDATA=`get_bankaccount_transactions exchange x | jq '.transactions[0]'`
-export SUBJECT=`echo $BANKDATA | jq -r .subject`
-export WTID=`echo $SUBJECT | awk '{print $1}'`
-export WURL=`echo $SUBJECT | awk '{print $2}'`
-export CREDIT_AMOUNT="`echo $BANKDATA | jq -r .currency`:`echo $BANKDATA | jq -r .amount`"
-export TARGET=`echo $BANKDATA | jq -r .creditorIban`
+BANKDATA=$(get_bankaccount_transactions exchange x | jq '.transactions[0]')
+SUBJECT=$(echo "$BANKDATA" | jq -r .subject)
+WTID=$(echo "$SUBJECT" | awk '{print $1}')
+WURL=$(echo "$SUBJECT" | awk '{print $2}')
+CREDIT_AMOUNT=$(echo "$BANKDATA" | jq -r .currency):$(echo "$BANKDATA" | jq -r .amount)
+TARGET=$(echo "$BANKDATA" | jq -r .creditorIban)
# Figure out which account got paid, in order to
# resort the right (and complete: including the receiver-name)
# TARGET_PAYTO
-if `echo $SURVEY_PAYTO | grep -q $TARGET`; then
- export TARGET_PAYTO=$SURVEY_PAYTO;
+if echo "$SURVEY_PAYTO" | grep -q "$TARGET" > /dev/null; then
+ TARGET_PAYTO="$SURVEY_PAYTO";
fi
-if `echo $TUTORIAL_PAYTO | grep -q $TARGET`; then
- export TARGET_PAYTO=$TUTORIAL_PAYTO;
+if echo "$TUTORIAL_PAYTO" | grep -q "$TARGET" > /dev/null; then
+ TARGET_PAYTO="$TUTORIAL_PAYTO";
fi
echo " DONE"
if [ "$EXCHANGE_URL" != "$WURL" ]
@@ -192,11 +218,11 @@ echo -n "Notifying merchant of correct wire transfer, but on wrong instance..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
-d "{\"credit_amount\":\"$CREDIT_AMOUNT\",\"wtid\":\"$WTID\",\"payto_uri\":\"$TOR_PAYTO\",\"exchange_url\":\"$WURL\"}" \
-m 3 \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 204 no content, after providing transfer data. Got: $STATUS"
fi
echo " OK"
@@ -205,19 +231,19 @@ echo " OK"
echo -n "Fetching wire transfers of DEFAULT instance ..."
STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 200 Ok. got: $STATUS"
fi
-TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < "$LAST_RESPONSE")
if [ "$TRANSFERS_LIST_SIZE" != "1" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected one transfer. got: $TRANSFERS_LIST_SIZE"
fi
@@ -230,19 +256,19 @@ echo "OK"
echo -n "Fetching wire transfers of 'test' instance ..."
STATUS=$(curl 'http://localhost:9966/instances/test/private/transfers' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 200 Ok. got: $STATUS"
fi
-TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < "$LAST_RESPONSE")
if [ "$TRANSFERS_LIST_SIZE" != "0" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected non-empty transfer list size. got: $TRANSFERS_LIST_SIZE"
fi
@@ -250,22 +276,20 @@ echo "OK"
echo -n "Checking order status ..."
STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}?transfer=YES" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
- exit_fail 'should response ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after order inquiry. got: $STATUS"
fi
-WAS_WIRED=`jq -r .wired < $LAST_RESPONSE`
+WAS_WIRED=$(jq -r .wired < "$LAST_RESPONSE")
if [ "$WAS_WIRED" == "true" ]
then
- jq . < $LAST_RESPONSE
- echo '.wired true, expected false'
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail ".wired is true, expected false"
fi
echo " OK"
@@ -274,13 +298,13 @@ echo -n "Notifying merchant of correct wire transfer in the correct instance..."
#this time in the correct instance so the order will be marked as wired...
STATUS=$(curl 'http://localhost:9966/instances/test/private/transfers' \
- -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \
+ -d '{"credit_amount":"'"$CREDIT_AMOUNT"'","wtid":"'"$WTID"'","payto_uri":"'"$TARGET_PAYTO"'","exchange_url":"'"$WURL"'"}' \
-m 3 \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "204" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 204 no content, after providing transfer data. got: $STATUS"
fi
echo " OK"
@@ -292,19 +316,19 @@ echo "OK"
echo -n "Fetching wire transfers of TEST instance ..."
STATUS=$(curl 'http://localhost:9966/instances/test/private/transfers' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected response 200 Ok. got: $STATUS"
fi
-TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+TRANSFERS_LIST_SIZE=$(jq -r '.transfers | length' < "$LAST_RESPONSE")
if [ "$TRANSFERS_LIST_SIZE" != "1" ]
then
- jq . < $LAST_RESPONSE
+ jq . < "$LAST_RESPONSE"
exit_fail "Expected one transfer. got: $TRANSFERS_LIST_SIZE"
fi
@@ -312,22 +336,20 @@ echo "OK"
echo -n "Checking order status ..."
STATUS=$(curl "http://localhost:9966/instances/test/private/orders/${ORDER_ID}?transfer=YES" \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- jq . < $LAST_RESPONSE
- exit_fail 'should response ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail "Expected 200 ok, after order inquiry. got: $STATUS"
fi
-WAS_WIRED=`jq -r .wired < $LAST_RESPONSE`
+WAS_WIRED=$(jq -r .wired < "$LAST_RESPONSE")
if [ "$WAS_WIRED" != "true" ]
then
- jq . < $LAST_RESPONSE
- echo '.wired false, expected true'
- exit 1
+ jq . < "$LAST_RESPONSE"
+ exit_fail ".wired false, expected true"
fi
echo " OK"
diff --git a/src/testing/test_merchant_wirewatch.sh b/src/testing/test_merchant_wirewatch.sh
index 1c078291..73a91831 100755
--- a/src/testing/test_merchant_wirewatch.sh
+++ b/src/testing/test_merchant_wirewatch.sh
@@ -17,11 +17,18 @@
# <http://www.gnu.org/licenses/>
#
# Testcase for #6363 (WiP)
+set -eu
+
+. setup.sh
+# Launch exchange, merchant and bank.
+setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban"
+LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX)
+CONF="test_template.conf.edited"
+WALLET_DB=$(mktemp test_wallet.json-XXXXXX)
+BANK_URL="http://localhost:18082/demobanks/default/"
+EXCHANGE_URL="http://localhost:8081/"
-. initialize_taler_system.sh
-# NEXUS_PORT is from the initialize_taler_systems.sh script
-export NEXUS_PORT
# 'talerebics' is used in taler-bank-manage-testing
export EBICS_HOST="talerebics"
@@ -151,10 +158,7 @@ echo " OK"
#
echo -n "Configuring merchant default instance ..."
-TOR_PAYTO=$(get_payto_uri tor x)
GNUNET_PAYTO=$(get_payto_uri gnunet x)
-# create with 2 address
-
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer secret-token:super_secret' \
http://localhost:9966/management/instances \
@@ -242,7 +246,7 @@ taler-exchange-transfer\
echo " DONE"
echo -n "Waiting for Nexus and Sandbox to settle the payment ..."
-sleep 3
+sleep 3 # FIXME-MS: replace with call to Nexus to right now poll the sandbox ...
libeufin-cli \
accounts \
fetch-transactions \
diff --git a/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv b/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv
new file mode 100644
index 00000000..ff57701a
--- /dev/null
+++ b/src/testing/test_reducer_home/.local/share/taler/exchange-offline/master.priv
@@ -0,0 +1 @@
+ N0ߌs= =kGM-g#r \ No newline at end of file
diff --git a/src/testing/test_template.conf b/src/testing/test_template.conf
index 2d57a91d..cbd794c6 100644
--- a/src/testing/test_template.conf
+++ b/src/testing/test_template.conf
@@ -13,7 +13,8 @@ CURRENCY_ROUND_UNIT = TESTKUDOS:0.01
AML_THRESHOLD = TESTKUDOS:1000000
MAX_KEYS_CACHING = forever
DB = postgres
-MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange-offline/master.priv
+MASTER_PUBLIC_KEY = VH2C95R9J44JK7JC87GXBFFAEPGYBSRESH6Y6WG51HRB2ZV7KQW0
SERVE = tcp
UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
UNIXPATH_MODE = 660
@@ -56,6 +57,17 @@ WIRE_GATEWAY_AUTH_METHOD = BASIC
USERNAME = merchant-wirewatch
PASSWORD = merchant-wirewatch-password
+[bank]
+HTTP_PORT = 8082
+
+[libeufin-nexus]
+#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
+DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
+
+[libeufin-sandbox]
+#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
+DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
+
[auditor]
DB = postgres
@@ -75,8 +87,8 @@ LEGAL_RESERVE_EXPIRATION_TIME = 7 years
[exchange-account-1]
# PAYTO_URI comes by patching.
-enable_debit = yes
-enable_credit = yes
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/facades/test-facade/taler-wire-gateway/"
@@ -87,7 +99,7 @@ PASSWORD = x
[merchant-exchange-default]
EXCHANGE_BASE_URL = http://localhost:8081/
CURRENCY = TESTKUDOS
-MASTER_KEY = CZFZJJAHRX7A6SDD8FTHAC0ZGS3ZCV00F06CX0C3ABRCV17REF40
+MASTER_KEY = VH2C95R9J44JK7JC87GXBFFAEPGYBSRESH6Y6WG51HRB2ZV7KQW0
[payments-generator]
currency = TESTKUDOS