From 976860bfecf27cd16a77ad508879c225989cb26e Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 7 Jul 2021 01:44:53 -0300 Subject: issue #6915 --- src/testing/test_merchant_order_creation.sh | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh index f596666d..6e772b81 100755 --- a/src/testing/test_merchant_order_creation.sh +++ b/src/testing/test_merchant_order_creation.sh @@ -55,6 +55,82 @@ fi echo OK RANDOM_IMG='data:image/png;base64,abcdefg' +# +# CREATE AN ORDER WITHOUT TOKEN +# + +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) + +if [ "$STATUS" != "200" ] +then + echo 'should response 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` + +if [ "$TOKEN" != "null" ] +then + echo 'token should be null, got:' $TOKEN +fi + +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 +fi +echo OK + +# +# CREATE AN ORDER WITHOUT TOKEN WITH FULLFILMENT URL +# + +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) + +if [ "$STATUS" != "200" ] +then + echo 'should response 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` + +if [ "$TOKEN" != "null" ] +then + echo 'token should be null, got:' $TOKEN +fi + +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` + +if [ "$FULLFILMENT_URL" != "go_here_please" ] +then + echo 'should have a payuri. got:' $PAY_URI `cat $LAST_RESPONSE` + exit 1 +fi + +if [ "$PAY_URI" == "null" ] +then + echo 'should have a payuri. got:' $PAY_URI `cat $LAST_RESPONSE` + exit 1 +fi +echo OK # # CREATE ORDER WITH NON-INVENTORY AND CHECK -- cgit v1.2.3