commit 91ab8c2c73767d51494976081dac79d5a7c010de
parent 5edd2bb88adfbee9ddf6dc448f1ac92441e36660
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 30 Jul 2026 17:57:30 +0200
switch test setup to taler-unified-setup and libeufin-bank
Diffstat:
4 files changed, 305 insertions(+), 400 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -43,3 +43,7 @@ doc/doxygen/*.tag
src/testing/taler-bank.err
src/testing/test_reducer_home/
.version
+
+# artifacts left in src/testing by taler-unified-setup.sh
+libeufin-bank.pid
+tmp-last-response.*
diff --git a/src/testing/test_anastasis_reducer_4_free.conf b/src/testing/test_anastasis_reducer_4_free.conf
@@ -228,4 +228,4 @@ TALER_HOME = ${PWD}/test_reducer_home/
TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
-TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/
+TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime-${USER}/
diff --git a/src/testing/test_prepare.sh b/src/testing/test_prepare.sh
@@ -20,98 +20,91 @@ function exit_fail() {
# Cleanup to run whenever we exit
function cleanup()
{
+ if test -n "${SETUP_PID:-}"
+ then
+ kill -TERM "$SETUP_PID" 2> /dev/null || true
+ wait "$SETUP_PID" 2> /dev/null || true
+ fi
for n in `jobs -p`
do
kill -SIGCONT $n # in case one provider was suspended
kill $n 2> /dev/null || true
done
- rm -rf $CONF $CONF_4 $WALLET_DB $R1FILE $R2FILE $B1FILE $B2FILE $TMP_DIR
+ rm -rf $CONF $CONF.edited $CONF_4 $CONF_IBAN $WALLET_DB $R1FILE $R2FILE $B1FILE $B2FILE $TMP_DIR
wait
}
-# $1=ebics username, $2=ebics partner name, $3=person name, $4=sandbox bank account name, $5=iban
-function prepare_sandbox_account() {
- echo -n "Activating ebics subscriber $1 at the sandbox ..."
- libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
- ebicssubscriber create \
- --host-id=$EBICS_HOST \
- --partner-id=$2 \
- --user-id=$1
- echo " OK"
- echo -n "Giving a bank account ($4) to $1 ..."
- libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
- ebicsbankaccount create \
- --iban=$5 \
- --bic="BCMAESM1XXX"\
- --person-name="$3" \
- --account-name=$4 \
- --ebics-user-id=$1 \
- --ebics-host-id=$EBICS_HOST \
- --ebics-partner-id=$2
- echo " OK"
+# Launch the GNU Taler services (bank, exchange, merchant) via
+# taler-unified-setup.sh and return once they are up. Mirrors the setup()
+# helper of exchange/src/testing/setup.sh; we cannot source that file as it is
+# not installed. Arguments are passed on to taler-unified-setup.sh.
+function taler_setup()
+{
+ local FIFO_DIR
+ local FIFO_OUT
+
+ # Create a named pipe in a temp directory we own.
+ FIFO_DIR=`mktemp -d fifo-XXXXXX`
+ FIFO_OUT="$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"
+ # '-W' is required for our termination logic to work.
+ taler-unified-setup.sh -W "$@" >&3 2> taler-unified-setup.log &
+ SETUP_PID=$!
+ exec 3>&-
+ # taler-unified-setup.sh prints "READY:$TESTROOT" once everything is up.
+ # Read until EOF instead of 'sed -u /READY:/ q' so that we can tell "the
+ # system came up" apart from "taler-unified-setup.sh died first".
+ READY=0
+ while IFS= read -r LINE <&4
+ do
+ case "$LINE" in
+ READY:*)
+ READY=1
+ break
+ ;;
+ esac
+ done
+ exec 4>&-
+ if test 1 != $READY
+ then
+ exit_skip "Failed to launch Taler services, see taler-unified-setup.log"
+ fi
}
-# Transfer only from debit to credit/anastasis account.
-# This function moves funds directly at the Sandbox. No need
-# to pass through the Nexus+Ebics layer to issue the payment
-# $1 = amount ($CURRENCY:X.Y), $2 = subject.
-function wire_transfer_to_anastasis() {
- libeufin-sandbox make-transaction \
- --debit-account=sandbox-account-debit \
- --credit-account=sandbox-account-credit "$1" "$2"
- # Sync nexus with sandbox
- export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
- export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
- libeufin-cli accounts fetch-transactions nexus-bankaccount-credit > /dev/null
- anastasis-helper-authorization-iban -c $CONF_4 -t -L INFO
-}
-
-# $1 = facade base URL. Merely a debug utility.
-function see_anastasis_transactions_via_facade() {
- curl -s --user "$CREDIT_USERNAME:$CREDIT_PASSWORD" "${1}history/incoming?delta=5" | jq
+# Create a bank account at libeufin-bank. Prints its payto URI.
+# $1 = username, $2 = password, $3 = legal name, $4 = payto URI (optional)
+function make_bank_account() {
+ if test -z "${4:-}"
+ then
+ libeufin-bank create-account \
+ -c $CONF_IBAN \
+ -u "$1" -p "$2" --name "$3" 2>> iban-setup.log
+ else
+ libeufin-bank create-account \
+ -c $CONF_IBAN \
+ -u "$1" -p "$2" --name "$3" --payto_uri "$4" 2>> iban-setup.log
+ fi
}
-# $1 = ebics user id, $2 = ebics partner, $3 = bank connection name
-# $4 = bank account name local to Nexus, $5 = bank account name as known
-# by Sandbox
-function prepare_nexus_account() {
- echo -n "Making bank connection $3 ..."
- libeufin-cli connections new-ebics-connection \
- --ebics-url="${SANDBOX_URL}ebicsweb" \
- --host-id=$EBICS_HOST \
- --partner-id=$2 \
- --ebics-user-id=$1 \
- $3 > /dev/null
- echo " OK"
- echo -n "Connecting $3 ..."
- libeufin-cli connections connect $3 > /dev/null
- echo " OK"
- echo -n "Importing Sandbox bank account ($5) to Nexus ($4) ..."
- libeufin-cli connections download-bank-accounts $3 > /dev/null
- libeufin-cli connections import-bank-account \
- --offered-account-id=$5 --nexus-bank-account-id=$4 $3 > /dev/null
- echo " OK"
-}
-# $1 = facade name, $2 = bank connection to use, $3 = bank account name
-# local to Nexus
-function prepare_anastasis_facade() {
- echo -n "Creating facade ..."
- libeufin-cli facades new-anastasis-facade \
- --currency=EUR \
- --facade-name=$1 \
- $2 $3
- echo " OK"
- # No need to setup facade permissions, as the anastasis client
- # is superuser at Nexus.
+# Transfer funds from the debit account to the Anastasis account and have
+# the Anastasis IBAN helper pick the transfer up.
+# $1 = amount ($CURRENCY:X.Y), $2 = subject.
+function wire_transfer_to_anastasis() {
+ curl -s -X POST \
+ --user "${DEBIT_USERNAME}:${DEBIT_PASSWORD}" \
+ -H "Content-Type: application/json" \
+ -d "{\"payto_uri\":\"${PAYTO_CREDIT}&message=$(echo "$2" | jq -sRr @uri)&amount=$1\"}" \
+ "${IBAN_BANK_URL}accounts/${DEBIT_USERNAME}/transactions" > /dev/null
+ anastasis-helper-authorization-iban -c $CONF_4 -t -L INFO
}
-
if test "${1:-}" != "free" -a "${1:-}" != "fees"
then
echo "Launch script with either 'free' or 'fees' argument to launch providers with/without fees."
@@ -128,20 +121,24 @@ else
CONF4="test_anastasis_reducer_4.conf"
fi
-# Exchange configuration file will be edited, so we create one
+# Taler configuration file will be edited, so we create one
# from the template.
export CONF=`mktemp test_reducerXXXXXX.conf`
export CONF_4=`mktemp test_reducer_4XXXXXX.conf`
+export CONF_IBAN=`mktemp test_reducer_ibanXXXXXX.conf`
cp test_reducer.conf $CONF
cp $CONF4 $CONF_4
TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
-WALLET_DB=`mktemp test_reducer_walletXXXXXX.json`
+# wallet-core needs an sqlite3 database; a '.json' name selects the
+# no-longer-supported in-memory backend.
+WALLET_DB=`mktemp test_reducer_walletXXXXXX.sqlite3`
B1FILE=`mktemp test_reducer_stateB1XXXXXX`
B2FILE=`mktemp test_reducer_stateB2XXXXXX`
R1FILE=`mktemp test_reducer_stateR1XXXXXX`
R2FILE=`mktemp test_reducer_stateR2XXXXXX`
IBAN_ACTIVE='false'
+SETUP_PID=''
# Install cleanup handler (except for kill -9)
trap cleanup EXIT
@@ -152,150 +149,23 @@ then
echo -n "Testing for taler"
taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange required"
taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant required"
+ # note: 'taler-unified-setup.sh -h' exits non-zero (its exit trap wins)
+ command -v taler-unified-setup.sh > /dev/null || exit_skip " taler-unified-setup.sh required"
echo " FOUND"
- echo -n "Testing for taler-bank-manage"
- taler-bank-manage --help >/dev/null </dev/null || exit_skip " MISSING"
+ echo -n "Testing for libeufin-bank"
+ libeufin-bank --help >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
echo -n "Testing for taler-wallet-cli"
taler-wallet-cli -v >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
-fi
-echo -n "Testing for libeufin-cli"
-if test $1 = 'fees' && libeufin-cli --version > /dev/null 2>/dev/null
-then
+ echo -n "Testing for jq"
+ jq --version >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
- IBAN_CREDIT=`anastasis-config -c $CONF_4 -s authorization-iban -o CREDIT_IBAN`
- CREDIT_BUSINESS_NAME=`anastasis-config -c $CONF_4 -s authorization-iban -o BUSINESS_NAME`
- echo -n "Setting up Nexus ..."
- export LIBEUFIN_NEXUS_DB_CONNECTION="postgres:///anastasischeck"
- export LIBEUFIN_SANDBOX_DB_CONNECTION="postgres:///anastasischeck"
- export NEXUS_URL="http://localhost:5001/"
- export SANDBOX_URL="http://localhost:5000/"
- libeufin-nexus serve &> nexus.log &
- nexus_pid=$!
- if ! curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null; then
- exit_skip "Could not launch Nexus"
- fi
- echo -n "."
- libeufin-sandbox serve --no-auth &> sandbox.log &
- sandbox_pid=$!
- if ! curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null; then
- exit_skip "Could not launch Sandbox"
- fi
- export EBICS_HOST="ebicstesthost"
- export IBAN_DEBIT="FR1420041010050500013M02606"
- echo "OK"
-
- echo -n "Preparing Sandbox ..."
- libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
- ebicshost create \
- --host-id=$EBICS_HOST
- echo " OK"
-
- export PERSON_CREDIT_NAME="Person Credit"
- echo -n "Preparing accounts ..."
- # note: Ebisc schema doesn't allow dashed names.
- prepare_sandbox_account \
- ebicsuserCredit \
- ebicspartnerCredit \
- "${PERSON_CREDIT_NAME}" \
- sandbox-account-credit \
- $IBAN_CREDIT
- prepare_sandbox_account \
- ebicsuserDebit \
- ebicspartnerDebit \
- "Person Debit" \
- sandbox-account-debit \
- $IBAN_DEBIT
- echo "Sandbox preparation done"
-
- echo -n "Preparing Nexus ..."
- export LIBEUFIN_NEXUS_URL=$NEXUS_URL
- # Make debit user, will buy Anastasis services.
- export DEBIT_USERNAME=anastasis-debit-user
- export DEBIT_PASSWORD=anastasis-debit-password
- libeufin-nexus superuser $DEBIT_USERNAME --password=$DEBIT_PASSWORD
- echo " OK"
- export LIBEUFIN_NEXUS_USERNAME=$DEBIT_USERNAME
- export LIBEUFIN_NEXUS_PASSWORD=$DEBIT_PASSWORD
-
- prepare_nexus_account \
- ebicsuserDebit \
- ebicspartnerDebit \
- bankconnection-debit \
- nexus-bankaccount-debit \
- sandbox-account-debit
-
- # Make credit user, will be Anastasis client.
- export CREDIT_USERNAME=anastasis-credit-user
- export CREDIT_PASSWORD=anastasis-credit-password
- echo -n "Create credit user (for anastasis) at Nexus ..."
- libeufin-nexus superuser $CREDIT_USERNAME --password=$CREDIT_PASSWORD
- echo " OK"
- export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
- export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
-
- prepare_nexus_account \
- ebicsuserCredit \
- ebicspartnerCredit \
- bankconnection-credit \
- nexus-bankaccount-credit \
- sandbox-account-credit
-
- echo -n "Create facade ..."
- libeufin-cli facades new-anastasis-facade \
- --currency="EUR" \
- --facade-name=facade-credit \
- bankconnection-credit nexus-bankaccount-credit
- echo " OK"
- export FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \")
-
- ## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD
-
- echo -n "Configuring Anastasis IBAN account ..."
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o CREDIT_IBAN \
- -V "${IBAN_CREDIT}"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o BUSINESS_NAME \
- -V "${PERSON_CREDIT_NAME}"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o WIRE_GATEWAY_URL \
- -V "${FACADE_URL}"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o WIRE_GATEWAY_AUTH_METHOD \
- -V "basic"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o USERNAME \
- -V "${LIBEUFIN_NEXUS_USERNAME}"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o PASSWORD \
- -V "${LIBEUFIN_NEXUS_PASSWORD}"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o ENABLED \
- -V YES
- echo " OK"
- IBAN_ACTIVE='true'
-else
- echo " NOT FOUND (IBAN authentication not supported)"
- anastasis-config -c $CONF_4 \
- -s authorization-iban \
- -o ENABLED \
- -V NO
fi
-
echo -n "Testing for anastasis-httpd"
anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
@@ -327,67 +197,191 @@ echo " OK"
if test $1 = 'fees'
then
- echo -n "Generating Taler auditor, exchange and merchant configurations ..."
-
- DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
- rm -rf $DATA_DIR
-
- # obtain key configuration data
- MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE-OFFLINE -o MASTER_PRIV_FILE`
- MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
- mkdir -p $MASTER_PRIV_DIR
- 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}/
- BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
- BANK_URL=http://localhost:${BANK_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
- gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
- AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
-
- # patch configuration
+ echo -n "Setting up Taler databases ..."
TALER_DB=talercheck
- taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
- taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
- taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
- taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
- taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
- taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
- taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
- taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
-
- echo " OK"
-
- echo -n "Setting up exchange ..."
-
- # reset database
+ # bank, exchange and merchant share one database here
+ taler-exchange-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
+ taler-exchange-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
+ taler-exchange-config -c $CONF -s libeufin-bankdb-postgres -o CONFIG -V postgres:///$TALER_DB
+ taler-exchange-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
+ taler-exchange-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
+ DATA_DIR=`taler-exchange-config -f -c $CONF -s PATHS -o TALER_HOME`
+ rm -rf $DATA_DIR
dropdb $TALER_DB >/dev/null 2>/dev/null || true
createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
- taler-exchange-dbinit -c $CONF
- taler-merchant-dbinit -c $CONF
- taler-auditor-dbinit -c $CONF
- taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
-
echo " OK"
- # Launch services
- echo -n "Launching taler services ..."
- taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 2> taler-bank.err &
- taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log &
- taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log &
- taler-exchange-secmod-cs -c $CONF 2> taler-exchange-secmod-cs.log &
- taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
- taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
- taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
- taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
+ # taler-unified-setup.sh launches the bank (libeufin-bank), the exchange
+ # (including the secmods and the offline key ceremony) and the merchant
+ # (including taler-merchant-exchangekeyupdate, without which the merchant
+ # never learns the exchange's keys and refuses to create orders). It
+ # writes the configuration it actually uses to "$CONF.edited".
+ echo "Launching Taler services ..."
+ taler_setup -c $CONF -L INFO -b -e -m -w -r merchant-exchange-default
+ echo "Taler services up"
+
+ BANK_PORT=`taler-exchange-config -c $CONF.edited -s libeufin-bank -o PORT`
+ BANK_URL="http://localhost:${BANK_PORT}/"
+ EXCHANGE_URL=`taler-exchange-config -c $CONF.edited -s exchange -o BASE_URL`
+ MERCHANT_PORT=`taler-merchant-config -c $CONF.edited -s merchant -o PORT`
+ MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
+ echo -n "Configuring merchant instance ..."
+ # POST to the merchant and fail loudly if it does not like the request.
+ # $1 = path, $2 = JSON body
+ function merchant_post() {
+ local RESP
+ local CODE
+
+ RESP=`curl -s -w '\n%{http_code}' -H "Content-Type: application/json" \
+ -X POST -d "$2" "${MERCHANT_URL}$1"`
+ CODE=`echo "$RESP" | tail -n1`
+ case "$CODE" in
+ 20*)
+ ;;
+ *)
+ echo " FAILED ($CODE)"
+ echo "$RESP" | head -n-1
+ exit_fail "merchant rejected POST /$1"
+ ;;
+ esac
+ }
+ # The default instance is called "admin" and is served at the root of the
+ # merchant; the historic /instances/default/ prefix is gone. 'use_stefan'
+ # is required by the current merchant protocol.
+ merchant_post management/instances \
+ '{"auth":{"method":"external"},"id":"admin","name":"default","address":{},"jurisdiction":{},"use_stefan":true,"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}}'
+ # 'fortythree' is one of the accounts taler-unified-setup.sh registers
+ merchant_post private/accounts \
+ '{"payto_uri":"payto://x-taler-bank/localhost/fortythree?receiver-name=Forty+Three"}'
echo " OK"
+ echo -n "Preparing wallet"
+ rm -f $WALLET_DB
+ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api \
+ --expect-success 'withdrawTestBalance' \
+ "$(jq -n '
+ {
+ amount: "TESTKUDOS:100",
+ corebankApiBaseUrl: $BANK_URL,
+ exchangeBaseUrl: $EXCHANGE_URL
+ }' \
+ --arg BANK_URL "$BANK_URL" \
+ --arg EXCHANGE_URL "$EXCHANGE_URL"
+ )" 2> wallet-withdraw.log >/dev/null
+ echo -n "."
+ # the wallet's withdrawal only completes once the exchange has seen the
+ # incoming wire transfer
+ taler-exchange-wirewatch -c $CONF.edited -t 2> wirewatch-once.log
+ echo -n "."
+ taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2> wallet-run.log >/dev/null
+ echo " OK"
+
+ echo -n "Setting up IBAN authentication ..."
+ # The IBAN challenge needs a bank that speaks IBAN and whose incoming
+ # transfers Anastasis can see through the taler-revenue API. That cannot
+ # be the bank the exchange uses: libeufin-bank serves a single WIRE_TYPE,
+ # and the exchange side of this test is x-taler-bank. So we run a second,
+ # IBAN-typed libeufin-bank for this one authorization method -- it also
+ # matches the fact that the IBAN challenge is priced in EUR.
+ IBAN_DB=anastasisibancheck
+ IBAN_BANK_PORT=8092
+ IBAN_BANK_URL="http://localhost:${IBAN_BANK_PORT}/"
+ REASON=""
+ # both IBANs must pass the checksum: libeufin-bank rejects malformed ones
+ IBAN_CREDIT="DE44500105175407324931"
+ IBAN_DEBIT="FR1420041010050500013M02606"
+ PERSON_CREDIT_NAME="Person Credit"
+ CREDIT_USERNAME=anastasis-credit-user
+ CREDIT_PASSWORD=anastasis-credit-password
+ DEBIT_USERNAME=anastasis-debit-user
+ DEBIT_PASSWORD=anastasis-debit-password
+ PAYTO_CREDIT="payto://iban/${IBAN_CREDIT}?receiver-name=Person+Credit"
+ PAYTO_DEBIT="payto://iban/${IBAN_DEBIT}?receiver-name=Person+Debit"
+ IBAN_REVENUE_URL="${IBAN_BANK_URL}accounts/${CREDIT_USERNAME}/taler-revenue/"
+ # the challenge is priced in this currency, e.g. "EUR:1"
+ IBAN_CURRENCY=`anastasis-config -c $CONF_4 -s authorization-iban -o COST | cut -d: -f1`
+ cat > $CONF_IBAN <<EOF
+# Generated by test_prepare.sh: the "customer's bank" for IBAN challenges.
+[PATHS]
+TALER_HOME = \${PWD}/test_reducer_home/
+TALER_DATA_HOME = \$TALER_HOME/.local/share/taler/
+TALER_CONFIG_HOME = \$TALER_HOME/.config/taler/
+TALER_CACHE_HOME = \$TALER_HOME/.cache/taler/
+TALER_RUNTIME_DIR = \${TMPDIR:-\${TMP:-/tmp}}/taler-system-runtime-\${USER}/
+
+[libeufin-bank]
+CURRENCY = ${IBAN_CURRENCY}
+BASE_URL = ${IBAN_BANK_URL}
+SERVE = tcp
+PORT = ${IBAN_BANK_PORT}
+WIRE_TYPE = iban
+IBAN_PAYTO_BIC = SANDBOXX
+DEFAULT_CUSTOMER_DEBT_LIMIT = ${IBAN_CURRENCY}:200
+DEFAULT_ADMIN_DEBT_LIMIT = ${IBAN_CURRENCY}:2000
+ALLOW_REGISTRATION = YES
+PWD_HASH_CONFIG = { "cost": 4 }
+PWD_AUTH_COMPAT = yes
+
+[libeufin-bankdb-postgres]
+CONFIG = postgres:///${IBAN_DB}
+EOF
+ IBAN_ACTIVE='true'
+ dropdb $IBAN_DB >/dev/null 2>/dev/null || true
+ if ! createdb $IBAN_DB 2>> iban-setup.log
+ then
+ IBAN_ACTIVE='false'
+ else
+ libeufin-bank dbinit -c $CONF_IBAN >> iban-setup.log 2>&1
+ libeufin-bank serve -c $CONF_IBAN >> iban-setup.log 2>&1 &
+ IBAN_BANK_PID=$!
+ for n in `seq 1 50`
+ do
+ sleep 0.2
+ wget --tries=1 --timeout=1 "${IBAN_BANK_URL}config" \
+ -o /dev/null -O /dev/null >/dev/null && break
+ done
+ make_bank_account "$CREDIT_USERNAME" "$CREDIT_PASSWORD" \
+ "$PERSON_CREDIT_NAME" "$PAYTO_CREDIT" > /dev/null &&
+ make_bank_account "$DEBIT_USERNAME" "$DEBIT_PASSWORD" \
+ "Person Debit" "$PAYTO_DEBIT" > /dev/null &&
+ libeufin-bank edit-account -c $CONF_IBAN \
+ --debit_threshold="${IBAN_CURRENCY}:1000" \
+ "$DEBIT_USERNAME" >> iban-setup.log 2>&1 ||
+ IBAN_ACTIVE='false'
+ # Make sure the bank speaks the revenue API that
+ # anastasis-helper-authorization-iban expects (an empty history is
+ # answered with 204), so that a version mismatch disables IBAN
+ # authentication instead of failing challenges at run time.
+ CODE=`curl -s -o /dev/null -w "%{http_code}" \
+ --user "${CREDIT_USERNAME}:${CREDIT_PASSWORD}" \
+ "${IBAN_REVENUE_URL}history?limit=1"`
+ if test $IBAN_ACTIVE = 'true' &&
+ test 200 != "$CODE" && test 204 != "$CODE"
+ then
+ REASON="revenue API at ${IBAN_REVENUE_URL} answered $CODE"
+ IBAN_ACTIVE='false'
+ kill $IBAN_BANK_PID 2> /dev/null || true
+ fi
+ fi
+ if test $IBAN_ACTIVE = 'false'
+ then
+ echo " DISABLED (${REASON:-see iban-setup.log})"
+ anastasis-config -c $CONF_4 -s authorization-iban -o ENABLED -V NO
+ else
+ anastasis-config -c $CONF_4 -s authorization-iban -o CURRENCY -V "${IBAN_CURRENCY}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o CREDIT_IBAN -V "${IBAN_CREDIT}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o BUSINESS_NAME -V "${PERSON_CREDIT_NAME}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o WIRE_GATEWAY_URL \
+ -V "${IBAN_REVENUE_URL}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o WIRE_GATEWAY_AUTH_METHOD -V "basic"
+ anastasis-config -c $CONF_4 -s authorization-iban -o USERNAME -V "${CREDIT_USERNAME}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o PASSWORD -V "${CREDIT_PASSWORD}"
+ anastasis-config -c $CONF_4 -s authorization-iban -o ENABLED -V YES
+ echo " OK"
+ fi
+else
+ anastasis-config -c $CONF_4 -s authorization-iban -o ENABLED -V NO
fi
@@ -406,84 +400,6 @@ export PPID_1
export PPID_2
export PPID_3
export PPID_4
-
-if test $1 = 'fees'
-then
-
- # Wait for bank to be available (usually the slowest)
- for n in `seq 1 50`
- do
- echo -n "."
- sleep 0.2
- OK=0
- # bank
- wget --tries=1 --timeout=1 http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
- done
-
- if [ 1 != $OK ]
- then
- exit_skip "Failed to launch services (bank)"
- fi
-
- # Wait for all other taler services to be available
- for n in `seq 1 50`
- do
- echo -n "."
- sleep 0.1
- OK=0
- # exchange
- wget --tries=1 --timeout=1 http://localhost:8081/seed -o /dev/null -O /dev/null >/dev/null || continue
- # merchant
- wget --tries=1 --timeout=1 http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
- # auditor
- wget --tries=1 --timeout=1 http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
- done
-
- if [ 1 != $OK ]
- then
- exit_skip "Failed to launch taler services"
- fi
-
- echo "OK"
-
- echo -n "Setting up keys ..."
- taler-exchange-offline -c $CONF \
- download \
- sign \
- enable-account payto://x-taler-bank/localhost/Exchange \
- enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
- wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 \
- global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 1h 1h 1year 5 \
- upload &> taler-exchange-offline.log
-
- echo -n "."
-
- for n in `seq 1 3`
- do
- echo -n "."
- OK=0
- wget --tries=1 --timeout=1 http://localhost:8081/keys -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
- done
-
- if [ 1 != $OK ]
- then
- exit_skip "Failed to setup keys"
- fi
-
- echo " OK"
-
- echo -n "Setting up auditor signatures ..."
- taler-auditor-offline -c $CONF \
- download sign upload &> taler-auditor-offline.log
- echo " OK"
-
-fi
echo " OK"
echo -n "Waiting for anastasis services ..."
@@ -512,35 +428,6 @@ then
fi
echo "OK"
-if test $1 = 'fees'
-then
-
- echo -n "Configuring merchant instance ..."
- # Setup merchant
-
- curl -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"id":"admin","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_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/management/instances
-
- curl -H "Content-Type: application/json" -X POST -d '{"payto_uri":"payto://x-taler-bank/localhost/43"}' http://localhost:9966/private/accounts
-
- echo " OK"
-
- echo -n "Preparing wallet"
- rm $WALLET_DB
- taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' \
- "$(jq -n '
- {
- amount: "TESTKUDOS:100",
- bankBaseUrl: $BANK_URL,
- exchangeBaseUrl: $EXCHANGE_URL
- }' \
- --arg BANK_URL "$BANK_URL" \
- --arg EXCHANGE_URL "$EXCHANGE_URL"
- )" 2> /dev/null >/dev/null
- taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>/dev/null >/dev/null
- echo " OK"
-
-fi
-
export -f wire_transfer_to_anastasis
echo "You can now run anastasis-gtk in TESTLAND."
@@ -551,6 +438,11 @@ if test $IBAN_ACTIVE = 'true'
then
echo '- for IBAN authentication use: wire_transfer_to_anastasis "$AMOUNT" "$SUBJECT"'
echo "- for your customer IBAN, use: ${IBAN_DEBIT}"
+ export IBAN_BANK_URL
+ export PAYTO_CREDIT
+ export DEBIT_USERNAME
+ export DEBIT_PASSWORD
+ export CONF_4
fi
if test $1 = 'fees'
then
diff --git a/src/testing/test_reducer.conf b/src/testing/test_reducer.conf
@@ -3,7 +3,9 @@ TALER_HOME = ${PWD}/test_reducer_home/
TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
-TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/
+# per-user: a fixed /tmp path breaks as soon as another user on the machine
+# created it first (the secmod sockets live in here)
+TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime-${USER}/
[anastasis]
CURRENCY = TESTKUDOS
@@ -31,6 +33,10 @@ ENABLED = yes
[exchange]
CURRENCY = TESTKUDOS
CURRENCY_ROUND_UNIT = TESTKUDOS:0.01
+TINY_AMOUNT = TESTKUDOS:0.01
+DEFAULT_P2P_EXPIRATION = 4 weeks
+# placeholder; taler-unified-setup.sh patches this to the key it generates
+MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
MAX_KEYS_CACHING = forever
DB = postgres
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
@@ -50,6 +56,9 @@ TERMS_ETAG = 0
PRIVACY_ETAG = 0
STEFAN_ABS = "TESTKUDOS:5"
+[exchange-offline]
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+
[merchant]
SERVE = tcp
PORT = 9966
@@ -66,49 +75,49 @@ 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
-
-[auditor]
-DB = postgres
-AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
+[libeufin-bank]
+CURRENCY = TESTKUDOS
SERVE = tcp
-UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
-UNIXPATH_MODE = 660
-PORT = 8083
-AUDITOR_URL = http://localhost:8083/
-TINY_AMOUNT = TESTKUDOS:0.01
-AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
-BASE_URL = "http://localhost:8083/"
-
-[bank]
-DATABASE = postgres:///taler-auditor-basedb
-MAX_DEBT = TESTKUDOS:50.0
-MAX_DEBT_BANK = TESTKUDOS:100000.0
-HTTP_PORT = 8082
-SUGGESTED_EXCHANGE = http://localhost:8081/
-SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost/2?receiver-name=Exchange
-ALLOW_REGISTRATIONS = YES
-SERVE = http
+PORT = 8082
+BASE_URL = http://localhost:8082/
+DEFAULT_CUSTOMER_DEBT_LIMIT = TESTKUDOS:200
+DEFAULT_ADMIN_DEBT_LIMIT = TESTKUDOS:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = TESTKUDOS:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+WIRE_TYPE = x-taler-bank
+X_TALER_BANK_PAYTO_HOSTNAME = localhost
+ALLOW_REGISTRATION = YES
+IBAN_PAYTO_BIC = SANDBOXX
+# keep the tests fast
+PWD_HASH_CONFIG = { "cost": 4 }
+PWD_AUTH_COMPAT = yes
+
+[libeufin-bankdb-postgres]
+CONFIG = postgres:///talercheck
[exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
LEGAL_RESERVE_EXPIRATION_TIME = 7 years
[exchange-account-1]
-PAYTO_URI = payto://x-taler-bank/localhost/Exchange?receiver-name=Exchange
-enable_debit = yes
-enable_credit = yes
+# 'exchange' is the account taler-unified-setup.sh registers at libeufin-bank
+PAYTO_URI = payto://x-taler-bank/localhost/exchange?receiver-name=Exchange+Company
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
-WIRE_GATEWAY_URL = "http://localhost:8082/accounts/Exchange/taler-wire-gateway/"
+WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/"
WIRE_GATEWAY_AUTH_METHOD = basic
-USERNAME = Exchange
-PASSWORD = x
+USERNAME = exchange
+PASSWORD = password
[merchant-exchange-default]
EXCHANGE_BASE_URL = http://localhost:8081/
CURRENCY = TESTKUDOS
+# placeholder; taler-unified-setup.sh -r patches this to the exchange's key,
+# without which the merchant does not trust the exchange and refuses orders
+MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
[coin_kudos_ct_1]
value = TESTKUDOS:0.01