test.sh (2321B)
1 #!/bin/bash 2 # Minimal script for testing, creates a first template 3 # that would work in combination with 'test.conf'. 4 # Run after starting taler-merchant-httpd and 5 # *before* starting paivana-httpd. 6 7 # Exit, with status code "skip" (no 'real' failure) 8 function exit_fail() { 9 echo "$@" >&2 10 exit 1 11 } 12 13 LAST_RESPONSE=$(mktemp /tmp/last-response-XXXXXX.json) 14 15 echo -n "Configuring merchant instance ..." 16 17 STATUS=$(curl -H "Content-Type: application/json" -X POST \ 18 -H 'Authorization: Bearer secret-token:sandbox' \ 19 http://localhost:9966/management/instances \ 20 -d '{"auth":{"method":"external"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \ 21 -w "%{http_code}" \ 22 -s \ 23 -o "$LAST_RESPONSE") 24 25 if [ "$STATUS" != "204" ] 26 then 27 jq < "$LAST_RESPONSE" 28 exit_fail "Expected '204 No content' response. Got instead $STATUS" 29 fi 30 echo "OK" 31 32 echo -n "Configuring merchant bank account ..." 33 34 PAYTO="payto://x-taler-bank/bank.demo.taler.net/fortythree?receiver-name=43" 35 # add bank account address 36 STATUS=$(curl -H "Content-Type: application/json" \ 37 -X POST \ 38 -H 'Authorization: Bearer secret-token:sandbox' \ 39 http://localhost:9966/private/accounts \ 40 -d '{"payto_uri":"'"$PAYTO"'"}' \ 41 -w "%{http_code}" \ 42 -s \ 43 -o "$LAST_RESPONSE") 44 45 if [ "$STATUS" != "200" ] 46 then 47 jq < "$LAST_RESPONSE" 48 exit_fail "Expected '200 OK' response. Got instead $STATUS" 49 fi 50 echo "Ok" 51 52 echo -n "Creating Paivana template..." 53 TID="paivana" 54 STATUS=$(curl -H "Content-Type: application/json" \ 55 -X POST \ 56 'http://localhost:9966/private/templates' \ 57 -H 'Authorization: Bearer secret-token:sandbox' \ 58 -d '{"template_id":"paivana","template_description":"A Paivana template","template_contract":{"template_type":"paivana","summary":"The summary","website_regex":".*","choices":[{"amount":"KUDOS:1"}]}}' \ 59 -w "%{http_code}" \ 60 -s \ 61 -o "$LAST_RESPONSE") 62 63 if [ "$STATUS" != "204" ] 64 then 65 jq < "$LAST_RESPONSE" 66 exit_fail "Expected 204, template created. got: $STATUS" 67 fi 68 69 echo "OK"