summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_order_creation.sh
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-04-15 19:46:19 +0200
committerChristian Blättler <blatc2@bfh.ch>2024-04-15 19:46:19 +0200
commitb243c4d358fc415d2dd5ace9fd25750f65316d2c (patch)
tree3ede73ad7a099e64c3f27dbd6b899e97b903291a /src/testing/test_merchant_order_creation.sh
parenteae958bf31060e3231b8a964301920f7b75b496c (diff)
downloadmerchant-b243c4d358fc415d2dd5ace9fd25750f65316d2c.tar.gz
merchant-b243c4d358fc415d2dd5ace9fd25750f65316d2c.tar.bz2
merchant-b243c4d358fc415d2dd5ace9fd25750f65316d2c.zip
add test for order creation with v1 contract
Diffstat (limited to 'src/testing/test_merchant_order_creation.sh')
-rwxr-xr-xsrc/testing/test_merchant_order_creation.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh
index 175667b9..bf1c5d02 100755
--- 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
#