summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-22 00:02:24 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-22 00:02:24 +0200
commit52c49785fe20844a52f083de4adf9fea6e0c403d (patch)
tree7ff2ff14772c2438913d359e9162d3246408eeb8
parent1ab96cd4aa2a913af036d74756e18785702f1a35 (diff)
downloadmerchant-52c49785fe20844a52f083de4adf9fea6e0c403d.tar.gz
merchant-52c49785fe20844a52f083de4adf9fea6e0c403d.tar.bz2
merchant-52c49785fe20844a52f083de4adf9fea6e0c403d.zip
start to use taler-unified-setup in merchant shell script tests
-rw-r--r--src/testing/Makefile.am2
-rwxr-xr-xsrc/testing/initialize_taler_system.sh4
-rwxr-xr-xsrc/testing/setup.sh46
-rw-r--r--src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_1/16867657041
-rw-r--r--src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_5/16867657041
-rw-r--r--src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_1/16867657041
-rw-r--r--src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_10/16867657042
-rwxr-xr-xsrc/testing/test_merchant_instance_auth.sh93
-rwxr-xr-xsrc/testing/test_merchant_instance_creation.sh18
-rw-r--r--src/testing/test_template.conf11
10 files changed, 121 insertions, 58 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 8ad5cb9c..ff4e7391 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -10,6 +10,7 @@ endif
check_SCRIPTS = \
test-merchant-walletharness.sh \
test_merchant_instance_auth.sh \
+ test_merchant_instance_creation.sh \
test_merchant_instance_response.sh \
test_merchant_instance_purge.sh \
test_merchant_reserve_creation.sh \
@@ -220,6 +221,7 @@ test_kyc_api_LDADD = \
$(XLIB)
EXTRA_DIST = \
+ setup.sh \
initialize_taler_system.sh \
test_key_rotation.sh \
test_key_rotation.conf \
diff --git a/src/testing/initialize_taler_system.sh b/src/testing/initialize_taler_system.sh
index 153121d2..1a234177 100755
--- a/src/testing/initialize_taler_system.sh
+++ b/src/testing/initialize_taler_system.sh
@@ -124,8 +124,8 @@ gnunet-ecc -g1 $MASTER_PRIV_FILE > /dev/null 2> /dev/null
MASTER_PUB=`gnunet-ecc -p ${MASTER_PRIV_FILE}`
EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
-MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
-AUDITOR_URL=http://localhost:8083/
+MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
+AUDITOR_URL="http://localhost:8083/"
AUDITOR_PRIV_FILE=`taler-config -f -c $CONF -s AUDITOR -o AUDITOR_PRIV_FILE`
AUDITOR_PRIV_DIR=`dirname $AUDITOR_PRIV_FILE`
mkdir -p $AUDITOR_PRIV_DIR
diff --git a/src/testing/setup.sh b/src/testing/setup.sh
new file mode 100755
index 00000000..86d2b06d
--- /dev/null
+++ b/src/testing/setup.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+# This file is in the public domain
+
+# Script to be inlined into the main test scripts. Defines function 'setup()'
+# which wraps around 'taler-unified-setup.sh' to launch GNU Taler services.
+# Call setup() with the arguments to pass to 'taler-unified-setup'. setup()
+# will then launch GNU Taler, wait for the process to be complete before
+# returning. The script will also install an exit handler to ensure the GNU
+# Taler processes are stopped when the shell exits.
+
+set -eu
+
+# Cleanup to run whenever we exit
+function exit_cleanup()
+{
+ if [ ! -z ${SETUP_PID+x} ]
+ then
+ echo "Killing taler-unified-setup ($SETUP_PID)" >&2
+ kill -TERM "$SETUP_PID"
+ wait
+ fi
+}
+
+# Install cleanup handler (except for kill -9)
+trap exit_cleanup EXIT
+
+function setup()
+{
+ echo "Starting test system ..." >&2
+ # Create a named pipe in a temp directory we own.
+ FIFO_DIR=$(mktemp -d fifo-XXXXXX)
+ FIFO_OUT=$(echo "$FIFO_DIR/out")
+ mkfifo "$FIFO_OUT"
+ # Open pipe as FD 3 (RW) and FD 4 (RO)
+ exec 3<> "$FIFO_OUT" 4< "$FIFO_OUT"
+ rm -rf "$FIFO_DIR"
+ # We require '-W' for our termination logic to work.
+ taler-unified-setup.sh -W "$@" >&3 &
+ SETUP_PID=$!
+ # Close FD3
+ exec 3>&-
+ sed -u '/<<READY>>/ q' <&4
+ # Close FD4
+ exec 4>&-
+ echo "Test system ready" >&2
+}
diff --git a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_1/1686765704 b/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_1/1686765704
deleted file mode 100644
index cc813619..00000000
--- a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_1/1686765704
+++ /dev/null
@@ -1 +0,0 @@
-:R߹>}S\;&7NcS& \ No newline at end of file
diff --git a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_5/1686765704 b/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_5/1686765704
deleted file mode 100644
index d7b275d7..00000000
--- a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_5/1686765704
+++ /dev/null
@@ -1 +0,0 @@
-{ogoMgXI3Yu \ No newline at end of file
diff --git a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_1/1686765704 b/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_1/1686765704
deleted file mode 100644
index a1523aa3..00000000
--- a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_1/1686765704
+++ /dev/null
@@ -1 +0,0 @@
-=/@RM]LeeSZjoq \ No newline at end of file
diff --git a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_10/1686765704 b/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_10/1686765704
deleted file mode 100644
index b75d3c55..00000000
--- a/src/testing/test_merchant_api_home/taler/exchange-secmod-cs/keys/coin_eur_ct_10/1686765704
+++ /dev/null
@@ -1,2 +0,0 @@
--]\+8_
-' ee \ No newline at end of file
diff --git a/src/testing/test_merchant_instance_auth.sh b/src/testing/test_merchant_instance_auth.sh
index 16ab1f09..c85e37e0 100755
--- a/src/testing/test_merchant_instance_auth.sh
+++ b/src/testing/test_merchant_instance_auth.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 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
@@ -18,15 +18,33 @@
#
# Exit, with status code "skip" (no 'real' failure)
-function exit_skip() {
- echo $1
- exit 77
+function exit_fail() {
+ echo "$@" >&2
+ exit 1
+}
+
+# Cleanup to run whenever we exit
+function my_cleanup()
+{
+ for n in $(jobs -p)
+ do
+ kill $n 2> /dev/null || true
+ done
+ wait
+ if [ ! -z ${LAST_RESPONSE+x} ]
+ then
+ rm -f ${LAST_RESPONSE}
+ fi
}
-. initialize_taler_system.sh
+. setup.sh
+# Launch only the merchant.
+setup -c test_template.conf -m
+CONF="test_template.conf.edited"
+LAST_RESPONSE=`mktemp test_response.conf-XXXXXX`
-echo -n "Configuring 'default' instance ..."
+echo -n "Configuring 'default' instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
http://localhost:9966/management/instances \
@@ -35,27 +53,26 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS" >&2
fi
+echo " OK" >&2
-echo " OK"
-
-
-kill $MERCHANT_HTTPD_PID
-wait $MERCHANT_HTTPD_PID
+# Kill merchant
+kill -TERM "$SETUP_PID"
+wait
+unset SETUP_PID
NEW_SECRET=secret-token:different_value
taler-merchant-httpd -a "${NEW_SECRET}" -c "${CONF}" -L DEBUG 2> taler-merchant-httpd.log &
-MERCHANT_HTTPD_PID=$!
-#taler-merchant-httpd -c $CONF -L DEBUG 2> taler-merchant-httpd.log &
+# Install cleanup handler (except for kill -9)
+trap my_cleanup EXIT
-echo -n "Waiting for the merchant..."
+echo -n "Waiting for the merchant..." >&2
# Wait for merchant to be available (usually the slowest)
-for n in `seq 1 50`
+for n in $(seq 1 50)
do
- echo -n "."
+ echo -n "." >&2
sleep 0.1
OK=0
# merchant
@@ -66,40 +83,40 @@ done
if [ "x$OK" != "x1" ]
then
- exit_skip "Failed to start merchant backend"
+ exit_fail "Failed to (re)start merchant backend"
fi
-echo -n "Creating order to test auth is ok..."
+echo -n "Creating order to test auth is ok..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
'http://localhost:9966/instances/default/private/orders' \
-H 'Authorization: Bearer '$NEW_SECRET \
-d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"}}' \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, order created. got: $STATUS"
fi
-ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
-TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+ORDER_ID=$(jq -e -r .order_id < "$LAST_RESPONSE")
+TOKEN=$(jq -e -r .token < "$LAST_RESPONSE")
STATUS=$(curl "http://localhost:9966/instances/default/private/orders/${ORDER_ID}" \
-H 'Authorization: Bearer '$NEW_SECRET \
- -w "%{http_code}" -s -o $LAST_RESPONSE)
+ -w "%{http_code}" -s -o "$LAST_RESPONSE")
if [ "$STATUS" != "200" ]
then
- echo 'should response ok, getting order info before claming it. got:' $STATUS `cat $LAST_RESPONSE`
- exit 1
+ cat "$LAST_RESPONSE" >&2
+ exit_fail "Expected 200, getting order info before claming it. got: $STATUS"
fi
-PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+PAY_URL=$(jq -e -r .taler_pay_uri < "$LAST_RESPONSE")
-echo OK order $ORDER_ID with $TOKEN
+echo "OK order ${ORDER_ID} with ${TOKEN} and ${PAY_URL}" >&2
-echo -n "Configuring 'second' instance ..."
+echo -n "Configuring 'second' instance ..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer '$NEW_SECRET \
@@ -109,13 +126,12 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance created. got: $STATUS"
fi
-echo "OK"
+echo "OK" >&2
-echo -n "Updating 'second' instance token using the 'default' auth token..."
+echo -n "Updating 'second' instance token using the 'default' auth token..." >&2
STATUS=$(curl -H "Content-Type: application/json" -X POST \
-H 'Authorization: Bearer '$NEW_SECRET \
@@ -125,11 +141,10 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance auth token changed. got:' $STATUS
- exit 1
+ exit_fail "Expected 204, instance auth token changed. got: $STATUS"
fi
-echo " OK"
-
+echo " OK" >&2
+echo "Test PASSED"
exit 0
diff --git a/src/testing/test_merchant_instance_creation.sh b/src/testing/test_merchant_instance_creation.sh
index 1fc65ff5..ed868b96 100755
--- a/src/testing/test_merchant_instance_creation.sh
+++ b/src/testing/test_merchant_instance_creation.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of TALER
-# Copyright (C) 2014-2021 Taler Systems SA
+# Copyright (C) 2014-2023 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
@@ -17,7 +17,10 @@
# <http://www.gnu.org/licenses/>
#
-. initialize_taler_system.sh
+. setup.sh
+
+# Launch only the merchant.
+setup -c test_template.conf -m
echo -n "Configuring a merchant instance before configuring the default instance ..."
@@ -29,7 +32,7 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
if [ "$STATUS" != "204" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
+ echo "Expected 204, instance created. got: $STATUS"
exit 1
fi
@@ -43,9 +46,9 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
-d '{"auth":{"method":"external"},"accounts":[{"payto_uri":"payto://x-taler-bank/localhost/43"}],"id":"default","name":"default","user_type":"business","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" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \
-w "%{http_code}" -s -o /dev/null)
-if [ "$STATUS" != "204" ]
+if [ "$STATUS" != "401" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
+ echo "Expected 401, permission denied. got: $STATUS"
exit 1
fi
@@ -58,13 +61,12 @@ STATUS=$(curl -H "Content-Type: application/json" -X POST \
-d '{"auth":{"method":"token","token":"secret-token:other_secret"},"accounts":[{"payto_uri":"payto://x-taler-bank/localhost/43"}],"id":"second","name":"test","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" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \
-w "%{http_code}" -s -o /dev/null)
-if [ "$STATUS" != "204" ]
+if [ "$STATUS" != "401" ]
then
- echo 'should respond ok, instance created. got:' $STATUS
+ echo "Expected 401, permission denied. got: $STATUS"
exit 1
fi
echo " OK"
-
exit 0
diff --git a/src/testing/test_template.conf b/src/testing/test_template.conf
index 0c57af72..2d57a91d 100644
--- a/src/testing/test_template.conf
+++ b/src/testing/test_template.conf
@@ -27,6 +27,9 @@ REVOCATION_DIR = ${TALER_DATA_HOME}/exchange/revocations/
TERMS_ETAG = 0
PRIVACY_ETAG = 0
+[exchangedb-postgres]
+CONFIG = postgres:///talercheck
+
[merchant]
SERVE = tcp
PORT = 9966
@@ -35,17 +38,16 @@ UNIXPATH_MODE = 660
DEFAULT_WIRE_FEE_AMORTIZATION = 1
DB = postgres
WIREFORMAT = default
-# Set very low, so we can be sure that the database generated
-# will contain wire transfers "ready" for the aggregator.
WIRE_TRANSFER_DELAY = 1 minute
DEFAULT_PAY_DEADLINE = 1 day
DEFAULT_MAX_DEPOSIT_FEE = TESTKUDOS:0.1
KEYFILE = ${TALER_DATA_HOME}/merchant/merchant.priv
DEFAULT_MAX_WIRE_FEE = TESTKUDOS:0.10
-
-# Ensure that merchant reports EVERY deposit confirmation to auditor
FORCE_AUDIT = YES
+[merchantdb-postgres]
+CONFIG = postgres:///talercheck
+
[taler-merchant-wirewatch]
INSTANCE = "default"
# This one will be set by test_merchant_wirewatch.sh
@@ -85,6 +87,7 @@ PASSWORD = x
[merchant-exchange-default]
EXCHANGE_BASE_URL = http://localhost:8081/
CURRENCY = TESTKUDOS
+MASTER_KEY = CZFZJJAHRX7A6SDD8FTHAC0ZGS3ZCV00F06CX0C3ABRCV17REF40
[payments-generator]
currency = TESTKUDOS