summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_product_creation.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_merchant_product_creation.sh')
-rwxr-xr-xsrc/testing/test_merchant_product_creation.sh68
1 files changed, 60 insertions, 8 deletions
diff --git a/src/testing/test_merchant_product_creation.sh b/src/testing/test_merchant_product_creation.sh
index 938a13d3..78b95d4e 100755
--- a/src/testing/test_merchant_product_creation.sh
+++ b/src/testing/test_merchant_product_creation.sh
@@ -85,20 +85,47 @@ then
cat $LAST_RESPONSE
exit 1
fi
-
echo OK
+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_ms": 100000},"quantity":10}' \
+ -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "410" ]
+then
+ echo 'should respond gone, lock failed. got:' $STATUS `cat $LAST_RESPONSE`
+ exit 1
+fi
+
+echo -n "."
+
+STATUS=$(curl "http://localhost:9966/instances/default/private/products/${MANAGED_PRODUCT_ID}/lock" \
+ -d '{"lock_uuid":"luck","duration":{"d_ms": 100000},"quantity":1}' \
+ -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "204" ]
+then
+ echo 'should respond ok, lock created. got:' $STATUS `cat $LAST_RESPONSE`
+ exit 1
+fi
+
+echo " OK"
+
+
echo -n "Creating order to be paid..."
-MANAGED_PRODUCT_ID=$(echo $MANAGED_PRODUCT_TEMPLATE | jq -r '.product_id')
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}]}' \
+ -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 response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
+ echo 'should respond ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
exit 1
fi
@@ -110,13 +137,38 @@ STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
+ echo 'should respond ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
exit 1
fi
-
PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
-echo OK
+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)
+
+if [ "$STATUS" != "410" ]
+then
+ echo 'should respond out of stock (what remains is locked). got:' $STATUS `cat $LAST_RESPONSE`
+ exit 1
+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)
+
+if [ "$STATUS" != "200" ]
+then
+ echo 'should respond ok, lock should apply. got:' $STATUS `cat $LAST_RESPONSE`
+ exit 1
+fi
+
+
+echo " OK"
echo -n "First withdraw wallet"
rm $WALLET_DB
@@ -146,7 +198,7 @@ STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
+ echo 'should respond ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
exit 1
fi