commit b243c4d358fc415d2dd5ace9fd25750f65316d2c
parent eae958bf31060e3231b8a964301920f7b75b496c
Author: Christian Blättler <blatc2@bfh.ch>
Date: Mon, 15 Apr 2024 19:46:19 +0200
add test for order creation with v1 contract
Diffstat:
1 file changed, 40 insertions(+), 0 deletions(-)
diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh
@@ -244,6 +244,46 @@ fi
echo "OK"
#
+# CREATE TOKEN FAMILY AND V1 ORDER WITH CHOICES
+#
+echo -n "Creating token family..."
+NOW=$(date +%s)
+IN_A_YEAR=$((NOW + 31536000))
+STATUS=$(curl 'http://localhost:9966/private/tokenfamilies' \
+ -d '{"slug":"test-sub","kind":"subscription","description":"Test token family","name":"Test Subscription","valid_after":{"t_s":'$NOW'},"valid_before":{"t_s":'$IN_A_YEAR'},"duration": {"d_us": 2592000000}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+
+if [ "$STATUS" != "204" ]
+then
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 204, token family created. got: $STATUS"
+fi
+
+echo -n "Creating v1 order with token family..."
+STATUS=$(curl 'http://localhost:9966/private/orders' \
+ -d '{"order":{"version":"1","amount":"TESTKUDOS:7","summary":"with_subscription","fulfillment_message":"Payed successfully","choices":[{"inputs":[{"kind":"token","count":1,"token_family_slug":"test-sub","valid_after":{"t_s":'$NOW'}}],"outputs":[{"kind":"token","count":1,"token_family_slug":"test-sub","valid_after":{"t_s":'$NOW'}}]}]}}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+
+if [ "$STATUS" != "200" ]
+then
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order created. got: $STATUS"
+fi
+
+ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -r .token < "$LAST_RESPONSE")
+
+STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID"/claim \
+ -d '{"nonce":"","token":"'"$TOKEN"'"}' \
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
+
+if [ "$STATUS" != "200" ]
+then
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order claimed. got: $STATUS"
+fi
+
+#
# CREATE ORDER WITH NON-INVENTORY AND CHECK
#