summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_order_creation.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_merchant_order_creation.sh')
-rwxr-xr-xsrc/testing/test_merchant_order_creation.sh76
1 files changed, 76 insertions, 0 deletions
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