diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-05-06 18:40:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-05-06 18:40:38 +0200 |
commit | 22ca9c89152aff6272418fa9726072787aa963cc (patch) | |
tree | 92ed00dff1987388345ff6cdf467b754b369fe89 /src/testing/test_merchant_order_creation.sh | |
parent | cbe046b30ab34ec07934bbdcbcb9b0438f24a821 (diff) | |
download | merchant-22ca9c89152aff6272418fa9726072787aa963cc.tar.gz merchant-22ca9c89152aff6272418fa9726072787aa963cc.tar.bz2 merchant-22ca9c89152aff6272418fa9726072787aa963cc.zip |
-fix order creation test
Diffstat (limited to 'src/testing/test_merchant_order_creation.sh')
-rwxr-xr-x | src/testing/test_merchant_order_creation.sh | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh index 754cdc25..1b1aeb23 100755 --- 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 |