diff options
author | priscilla <priscilla.huang@efrei.net> | 2022-12-06 09:27:45 -0500 |
---|---|---|
committer | priscilla <priscilla.huang@efrei.net> | 2022-12-06 09:27:45 -0500 |
commit | e90fc21a82c6d58a3fc8154b4a708cb323245ef0 (patch) | |
tree | e8f02e6f8de32c69cd5364f6e025799b3f988d34 /src/testing/test_merchant_template_creation.sh | |
parent | b0a95a941b3d374e19e2f27c57155183315ed4df (diff) | |
download | merchant-e90fc21a82c6d58a3fc8154b4a708cb323245ef0.tar.gz merchant-e90fc21a82c6d58a3fc8154b4a708cb323245ef0.tar.bz2 merchant-e90fc21a82c6d58a3fc8154b4a708cb323245ef0.zip |
update
Diffstat (limited to 'src/testing/test_merchant_template_creation.sh')
-rw-r--r-- | src/testing/test_merchant_template_creation.sh | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/testing/test_merchant_template_creation.sh b/src/testing/test_merchant_template_creation.sh index e69de29b..2fb6ab26 100644 --- a/src/testing/test_merchant_template_creation.sh +++ b/src/testing/test_merchant_template_creation.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# This file is part of TALER +# Copyright (C) 2014-2021 Taler Systems SA +# +# TALER is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3, or +# (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with TALER; see the file COPYING. If not, see +# <http://www.gnu.org/licenses/> +# + +. initialize_taler_system.sh + +echo -n "Configuring merchant instance ..." +FORTYTHREE=`get_payto_uri fortythree x` +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:super_secret' \ + http://localhost:9966/management/instances \ + -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS +:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -w "%{http_code}" -s -o /dev/null) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, instance created. got:' $STATUS + exit 1 +fi +echo OK +RANDOM_IMG='data:image/png;base64,abcdefg' + +INFINITE_TEMPLATE='{"template_id":"2","description":"template with id 2","image":"'$RANDOM_IMG'"}' +MANAGED_TEMPLATE='{"template_id":"3","description":"template with id 3","image":"'$RANDOM_IMG'"}' + +echo -n "Creating templates..." +STATUS=$(curl 'http://localhost:9966/instances/default/private/templates' \ + -d "$INFINITE_TEMPLATE" \ + -w "%{http_code}" -s -o /dev/null) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, template created. got:' $STATUS + exit 1 +fi + +STATUS=$(curl 'http://localhost:9966/instances/default/private/templates' \ + -d "$MANAGED_TEMPLATE" \ + -w "%{http_code}" -s -o /dev/null) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, template created. got:' $STATUS + exit 1 +fi +echo OK + + +TEMPLATE_DATA=$(echo $INFINITE_TEMPLATE | jq 'del(.template_id) | . + {description: "other description"}') + +echo -n "Updating infinite stock template..." +STATUS=$(curl 'http://localhost:9966/instances/default/private/templates/2' -X PATCH \ + -d "$TEMPLATE_DATA" \ + -w "%{http_code}" -s -o $LAST_RESPONSE) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, updating template. got:' $STATUS + cat $LAST_RESPONSE + exit 1 +fi + +STATUS=$(curl 'http://localhost:9966/instances/default/private/templates/2' \ + -w "%{http_code}" -s -o $LAST_RESPONSE) + +DESCRIPTION=`jq -r .description < $LAST_RESPONSE` + +if [ "$DESCRIPTION" != "other description" ] +then + echo 'should change description. got:' $DESCRIPTION + cat $LAST_RESPONSE + exit 1 +fi +echo OK + +echo " OK" + + +echo -n "Updating template..." + +TEMPLATE_DATA=$(echo $MANAGED_TEMPLATE | jq 'del(.template_id)') + +STATUS=$(curl 'http://localhost:9966/instances/default/private/templates/3' -X PATCH \ + -d "$TEMPLATE_DATA" \ + -w "%{http_code}" -s -o $LAST_RESPONSE) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, updating template. got:' $STATUS + cat $LAST_RESPONSE + exit 1 +fi + +echo " OK" + +exit 0 |