merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 22ca9c89152aff6272418fa9726072787aa963cc
parent cbe046b30ab34ec07934bbdcbcb9b0438f24a821
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  6 May 2023 18:40:38 +0200

-fix order creation test

Diffstat:
Msrc/testing/test_merchant_order_creation.sh | 64++++++++++++++--------------------------------------------------
1 file changed, 14 insertions(+), 50 deletions(-)

diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh @@ -377,27 +377,14 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ -m 3 \ -w "%{http_code}" -s -o $LAST_RESPONSE) -if [ "$STATUS" != "409" ] +if [ "$STATUS" != "204" ] then jq . < $LAST_RESPONSE exit_fail "Expected to fail since the amount is not valid. got: $STATUS" fi echo "OK" -echo -n "Notifying merchant of bogus wire transfer AGAIN ..." - -STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ - -d '{"credit_amount":"'$CREDIT_AMOUNT'1","wtid":"'$WTID'","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \ - -m 3 \ - -w "%{http_code}" -s -o $LAST_RESPONSE) - -if [ "$STATUS" != "409" ] -then - jq . < $LAST_RESPONSE - exit_fail "Expected to fail since the amount is not valid. got: $STATUS" -fi -echo " OK" echo -n "Notifying merchant of correct wire transfer (conflicting with old data)..." STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ @@ -444,45 +431,37 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ -m 3 \ -w "%{http_code}" -s -o $LAST_RESPONSE) -if [ "$STATUS" != "200" ] +if [ "$STATUS" != "204" ] then jq . < $LAST_RESPONSE - exit_fail "Expected response ok, after providing transfer data. got: $STATUS" + exit_fail "Expected response 204 No content, after providing transfer data. got: $STATUS" fi echo " OK" + echo -n "Testing idempotence ..." 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) -if [ "$STATUS" != "200" ] +if [ "$STATUS" != "204" ] then jq . < $LAST_RESPONSE - exit_fail "Expected response ok, after providing transfer data. got: $STATUS" + exit_fail "Expected response No Content, after providing transfer data. got: $STATUS" fi echo " OK" -echo -n "Sending bogus WTID ..." -# -# CHECK TRANSFER API -# - -STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ - -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \ - -w "%{http_code}" -s -o $LAST_RESPONSE) +echo -n "Testing taler-merchant-exchange ..." +set -e +taler-merchant-exchange -L INFO -c $CONF -t &> taler-merchant-exchange.log +echo " OK" -if [ "$STATUS" != "502" ] -then - jq . < $LAST_RESPONSE - exit_fail "Expected response invalid since the WTID is fake. got: $STATUS" -fi -echo "OK" echo -n "Fetching wire transfers ..." STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ @@ -496,28 +475,13 @@ fi TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE` -if [ "$TRANSFERS_LIST_SIZE" != "2" ] +if [ "$TRANSFERS_LIST_SIZE" != "1" ] then jq . < $LAST_RESPONSE - exit_fail "Expected response ok. got: $STATUS" + exit_fail "Expected 1 entry in transfer list. Got: $TRANSFERS_LIST_SIZE" fi echo "OK" -echo -n "Fetching wire transfer details of bogus WTID ..." - -# Test for #6854: use a bogus WTID, causing the exchange to fail to -# find the WTID. -STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \ - -d '{"credit_amount":"'$CREDIT_AMOUNT'","wtid":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","payto_uri":"'$TARGET_PAYTO'","exchange_url":"'$WURL'"}' \ - -w "%{http_code}" -s -o $LAST_RESPONSE) - -if [ "$STATUS" != "502" ] -then - jq . < $LAST_RESPONSE - exit_fail "Expected response invalid since the WTID is fake. got: $STATUS" -fi - -echo " OK" echo -n "Checking order status ..." @@ -529,7 +493,7 @@ STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID if [ "$STATUS" != "200" ] then jq . < $LAST_RESPONSE - exit_fail 'should response ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE` + exit_fail 'should respond 200 ok, after order inquiry. got:' $STATUS `cat $LAST_RESPONSE` exit 1 fi