test_merchant_instance_purge.sh (2818B)
1 #!/usr/bin/env bash 2 # This file is part of TALER 3 # Copyright (C) 2014-2023 Taler Systems SA 4 # 5 # TALER is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 3, or 8 # (at your option) any later version. 9 # 10 # TALER is distributed in the hope that it will be useful, but 11 # WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public 16 # License along with TALER; see the file COPYING. If not, see 17 # <http://www.gnu.org/licenses/> 18 # 19 20 . setup.sh 21 22 # Launch only the merchant. 23 setup -c test_template.conf -m 24 LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) 25 26 echo -n "Configuring admin instance ..." >&2 27 28 STATUS=$(curl -H "Content-Type: application/json" -X POST \ 29 http://localhost:9966/management/instances \ 30 -d '{"auth":{"method":"token","password":"super_secret"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ 31 -w "%{http_code}" -s -o /dev/null) 32 33 if [ "$STATUS" != "204" ] 34 then 35 exit_fail "Expected 204, instance created. got: $STATUS" 36 fi 37 ADMIN_TOKEN=$(merchant_login admin super_secret) 38 39 echo " OK" >&2 40 41 echo -n "Configuring merchant instance ..." >&2 42 43 STATUS=$(curl -H "Content-Type: application/json" -X POST \ 44 -H "Authorization: Bearer $ADMIN_TOKEN" \ 45 http://localhost:9966/management/instances \ 46 -d '{"auth":{"method":"token","password":"secret-token:other_secret"},"id":"test","name":"test","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ 47 -w "%{http_code}" -s -o /dev/null) 48 49 if [ "$STATUS" != "204" ] 50 then 51 exit_fail "Expected 204, instance created. got: $STATUS" 52 fi 53 echo " OK" >&2 54 55 echo -n "Deleting instance ..." >&2 56 STATUS=$(curl -H "Content-Type: application/json" -X DELETE \ 57 -H "Authorization: Bearer $ADMIN_TOKEN" \ 58 "http://localhost:9966/management/instances/test" \ 59 -w "%{http_code}" -s -o /dev/null) 60 61 if [ "$STATUS" != "204" ] 62 then 63 exit_fail "Expected 204, instance deleted. got: $STATUS" 64 fi 65 66 echo " OK" >&2 67 echo -n "Purging instance ..." >&2 68 69 STATUS=$(curl -H "Content-Type: application/json" -X DELETE \ 70 -H "Authorization: Bearer $ADMIN_TOKEN" \ 71 "http://localhost:9966/management/instances/test?purge=yes" \ 72 -w "%{http_code}" -s -o /dev/null) 73 74 75 if [ "$STATUS" != "204" ] 76 then 77 exit_fail "Expected 204, instance deleted. got: $STATUS" 78 fi 79 80 echo " OK" >&2 81 echo "Test PASSED" 82 83 exit 0