summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------contrib/gana0
-rwxr-xr-xsrc/auditor/generate-auditor-basedb.sh2
-rwxr-xr-xsrc/auditor/generate-revoke-basedb.sh2
-rw-r--r--src/bank-lib/fakebank_twg.c2
-rwxr-xr-xsrc/testing/taler-unified-setup.sh351
-rw-r--r--src/testing/test-taler-exchange-wirewatch-postgres.conf10
-rw-r--r--src/testing/test_bank_api.c2
-rw-r--r--src/testing/test_bank_api.conf12
-rw-r--r--src/testing/test_bank_api_twisted.c2
-rw-r--r--src/testing/test_exchange_api.conf14
-rw-r--r--src/testing/testing_api_helpers_bank.c687
11 files changed, 144 insertions, 940 deletions
diff --git a/contrib/gana b/contrib/gana
-Subproject 64244e85f34d3090ab60ab07c33d8c0de29ab16
+Subproject e9015f67dd6674680a0137b6ef8a04e08a8613e
diff --git a/src/auditor/generate-auditor-basedb.sh b/src/auditor/generate-auditor-basedb.sh
index 46e0813a0..5ac8a93cc 100755
--- a/src/auditor/generate-auditor-basedb.sh
+++ b/src/auditor/generate-auditor-basedb.sh
@@ -56,7 +56,7 @@ echo " DONE"
# Launch exchange, merchant and bank.
setup -c "$CONF" \
- -aenmsw \
+ -abemw \
-d "iban"
# obtain key configuration data
diff --git a/src/auditor/generate-revoke-basedb.sh b/src/auditor/generate-revoke-basedb.sh
index 4acfac280..9313468a4 100755
--- a/src/auditor/generate-revoke-basedb.sh
+++ b/src/auditor/generate-revoke-basedb.sh
@@ -24,7 +24,7 @@ echo " DONE"
# Launch exchange, merchant and bank.
setup -c "$CONF" \
- -aenmsw \
+ -abemw \
-d "iban"
# obtain key configuration data
diff --git a/src/bank-lib/fakebank_twg.c b/src/bank-lib/fakebank_twg.c
index f362dd4a8..353821bd2 100644
--- a/src/bank-lib/fakebank_twg.c
+++ b/src/bank-lib/fakebank_twg.c
@@ -46,7 +46,7 @@ TALER_FAKEBANK_twg_main_ (
void **con_cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Fakebank, serving URL `%s' for account `%s'\n",
+ "Fakebank TWG, serving URL `%s' for account `%s'\n",
url,
account);
if (0 == strcasecmp (method,
diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh
index eba903910..a5bba70db 100755
--- a/src/testing/taler-unified-setup.sh
+++ b/src/testing/taler-unified-setup.sh
@@ -70,7 +70,7 @@ START_FAKEBANK=0
START_AGGREGATOR=0
START_MERCHANT=0
START_NEXUS=0
-START_SANDBOX=0
+START_BANK=0
START_TRANSFER=0
START_WIREWATCH=0
USE_ACCOUNT="exchange-account-1"
@@ -87,7 +87,7 @@ while getopts ':abc:d:efghL:mnr:stu:vwW' OPTION; do
START_AUDITOR="1"
;;
b)
- START_BACKUP="1"
+ START_BANK="1"
;;
c)
CONF_ORIG="$OPTARG"
@@ -104,7 +104,7 @@ while getopts ':abc:d:efghL:mnr:stu:vwW' OPTION; do
h)
echo 'Supported options:'
echo ' -a -- start auditor'
- echo ' -b -- start backup/sync'
+ echo ' -b -- start bank'
# shellcheck disable=SC2016
echo ' -c $CONF -- set configuration'
# shellcheck disable=SC2016
@@ -119,7 +119,7 @@ while getopts ':abc:d:efghL:mnr:stu:vwW' OPTION; do
echo ' -n -- start nexus'
# shellcheck disable=SC2016
echo ' -r $MEX -- which exchange to use at the merchant (optional)'
- echo ' -s -- start sandbox'
+ echo ' -s -- start backup/sync'
echo ' -t -- start transfer'
# shellcheck disable=SC2016
echo ' -u $SECTION -- exchange account to use'
@@ -143,7 +143,7 @@ while getopts ':abc:d:efghL:mnr:stu:vwW' OPTION; do
USE_MERCHANT_EXCHANGE="$OPTARG"
;;
s)
- START_SANDBOX="1"
+ START_BACKUP="1"
;;
t)
START_TRANSFER="1"
@@ -208,28 +208,37 @@ CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
echo "Setting up for $CURRENCY at $EXCHANGE_URL"
-register_sandbox_account() {
- export LIBEUFIN_SANDBOX_USERNAME="$1"
- export LIBEUFIN_SANDBOX_PASSWORD="$2"
- # FIXME-MS: delete should be removed after we make 'register' idempotent!
- libeufin-cli sandbox \
- demobank \
- delete \
- --bank-account "$1" &> /dev/null || true
-
+register_bank_account() {
+ wget \
+ --http-user="$AUSER" \
+ --http-password="$APASS" \
+ --method=DELETE \
+ -o /dev/null \
+ -O /dev/null \
+ "http://localhost:${BANK_PORT}/accounts/$1" \
+ || true # deletion may fail, that's OK!
+ if [ "$3" = "exchange" || "$3" = "Exchange" ]
+ then
+ IS_EXCHANGE="true"
+ else
+ IS_EXCHANGE="false"
+ fi
MAYBE_IBAN="${4:-}"
- if test -n "$MAYBE_IBAN"; then
- libeufin-cli sandbox \
- demobank \
- register --name "$3" --iban "$MAYBE_IBAN"
+ if test -n "$MAYBE_IBAN";
+ then
+ # Note: this assumes that $3 has no spaces. Should probably escape in the future..
+ PAYTO="payto://SANDBOXX/${MAYBE_IBAN}?receiver-name=$3"
+ BODY='{username="'"$1"'",password="'"$2"'",is_taler_exchange='"$IS_EXCHANGE"',name="'"$3"'",internal_payto_uri="'"$PAYTO"'"}'
else
- libeufin-cli sandbox \
- demobank \
- register --name "$3"
+ BODY='{username="'"$1"'",password="'"$2"'",is_taler_exchange='"$IS_EXCHANGE"',name="'"$3"'"}'
fi
-
- unset LIBEUFIN_SANDBOX_USERNAME
- unset LIBEUFIN_SANDBOX_PASSWORD
+ wget \
+ --http-user="$AUSER" \
+ --http-password="$APASS" \
+ --method=POST \
+ --body-data="${BODY}" \
+ -a wget.log \
+ "http://localhost:${BANK_PORT}/accounts/$1"
}
register_fakebank_account() {
@@ -249,59 +258,28 @@ register_fakebank_account() {
}
-if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]
+if [[ "1" = "$START_BANK" || "1" = "$START_FAKEBANK" ]]
then
BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT")
- if [ "1" = "$START_NEXUS" ]
- then
- NEXUS_PORT="$BANK_PORT"
- SANDBOX_PORT="1$BANK_PORT"
- else
- NEXUS_PORT="0"
- SANDBOX_PORT="1$BANK_PORT"
- fi
-else
- if [ "1" = "$START_SANDBOX" ]
- then
- BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT")
- SANDBOX_PORT="$BANK_PORT"
- fi
+ BANK_URL="http://localhost:${BANK_PORT}/"
fi
-if [ "1" = "$START_SANDBOX" ]
+if [ "1" = "$START_BANK" ]
then
- #
- LIBEUFIN_SANDBOX_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-sandbox" -o "DB_CONNECTION")
- if [ -n "${PGHOST:+}" ]
- then
- EHOST=$(echo "$PGHOST" | sed -e "s/\//\\\\\//g")
- LIBEUFIN_SANDBOX_DB_CONNECTION=$(echo "$LIBEUFIN_SANDBOX_DB_CONNECTION" | sed -e "s/\/var\/run\/postgresql/$EHOST/")
- taler-config -c "$CONF" -s "libeufin-sandbox" -o "DB_CONNECTION" -V "$LIBEUFIN_SANDBOX_DB_CONNECTION"
- fi
- export LIBEUFIN_SANDBOX_DB_CONNECTION
- # Create the default demobank.
- echo -n "Configuring sandbox at ${LIBEUFIN_SANDBOX_DB_CONNECTION} "
-
- libeufin-sandbox reset-tables \
- &> libeufin-sandbox-reset.log
- libeufin-sandbox config \
- --currency "$CURRENCY" \
- --users-debt-limit 99999999 \
- --bank-debt-limit 99999999 \
- default &> libeufin-sandbox-config.log
+ echo -n "Setting up bank database ... "
+ libeufin-bank-dbinit \
+ -r \
+ -c "$CONF" \
+ &> libeufin-bank-reset.log
echo "DONE"
- echo "sandbox uses DB at $LIBEUFIN_SANDBOX_DB_CONNECTION"
- echo -n "Launching sandbox ... "
- export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret"
- libeufin-sandbox serve \
- --port "$SANDBOX_PORT" \
- > libeufin-sandbox-stdout.log \
- 2> libeufin-sandbox-stderr.log &
- echo $! > libeufin-sandbox.pid
+ echo -n "Launching bank ... "
+ libeufin-bank serve \
+ --port "$BANK_PORT" \
+ > libeufin-bank-stdout.log \
+ 2> libeufin-bank-stderr.log &
+ echo $! > libeufin-bank.pid
echo "DONE"
- export LIBEUFIN_SANDBOX_URL="http://localhost:$SANDBOX_PORT/"
- OK="0"
- echo -n "Waiting for Sandbox ..."
+ echo -n "Waiting for Bank ..."
for n in $(seq 1 100); do
echo -n "."
sleep "$DEFAULT_SLEEP"
@@ -310,101 +288,56 @@ then
--waitretry=0 \
-o /dev/null \
-O /dev/null \
- "$LIBEUFIN_SANDBOX_URL" || continue
+ "$BANK_URL/config" || continue
OK="1"
break
done
if [ "1" != "$OK" ]
then
- exit_skip "Failed to launch services (sandbox)"
+ exit_skip "Failed to launch services (bank)"
fi
echo "OK"
- echo -n "Register Sandbox users ..."
- # The specified IBAN and name must match the ones hard-coded into
- # the C helper for the add-incoming call. Without this value,
- # Sandbox won't find the target account to debit along a /add-incoming
- # call.
- register_sandbox_account fortytwo x "User42" FR7630006000011234567890189
- register_sandbox_account fortythree x "Forty Three"
- register_sandbox_account exchange x "Exchange Company"
- register_sandbox_account tor x "Tor Project"
- register_sandbox_account gnunet x "GNUnet"
- register_sandbox_account tutorial x "Tutorial"
- register_sandbox_account survey x "Survey"
- echo " DONE"
-
- echo -n "Fixing up exchange's PAYTO_URI in the config ..."
- export LIBEUFIN_SANDBOX_USERNAME="exchange"
- export LIBEUFIN_SANDBOX_PASSWORD="x"
- EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri')
- taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
- echo " OK"
-
- echo -n "Setting this exchange as the bank's default ..."
- libeufin-sandbox default-exchange "$EXCHANGE_URL" "$EXCHANGE_PAYTO"
+ echo -n "Set admin password..."
+ AUSER="admin"
+ APASS="secret"
+ libeufin-bank passwd "$AUSER" "$APASS"
echo " OK"
-
- # Prepare EBICS: create Ebics host and Exchange subscriber.
- # Shortly becoming admin to setup Ebics.
- export LIBEUFIN_SANDBOX_USERNAME="admin"
- export LIBEUFIN_SANDBOX_PASSWORD="secret"
- echo -n "Create EBICS host at Sandbox.."
- # FIXME-MS: || true should be removed after we make 'create' idempotent!
- libeufin-cli sandbox \
- --sandbox-url "$LIBEUFIN_SANDBOX_URL" \
- ebicshost create --host-id talerebics &> libeufin-sandbox-ebicshost-create.log || true
- echo "OK"
- echo -n "Create exchange EBICS subscriber at Sandbox.."
- # FIXME-MS: || true should be removed after we make 'new-ebicssubscriber' idempotent!
- libeufin-cli sandbox \
- demobank new-ebicssubscriber --host-id talerebics \
- --user-id exchangeebics --partner-id talerpartner \
- --bank-account exchange &> libeufin-sandbox-ebicsscubscriber.log || true
- # that's a username _and_ a bank account name
- echo "OK"
- unset LIBEUFIN_SANDBOX_USERNAME
- unset LIBEUFIN_SANDBOX_PASSWORD
fi
if [ "1" = "$START_NEXUS" ]
then
- echo "Setting up Nexus ..."
+ echo "Nexus currently not supported ..."
+fi
- # Prepare Nexus, which is the side actually talking
- # to the exchange.
- LIBEUFIN_NEXUS_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-nexus" -o "DB_CONNECTION")
+if [ "1" = "$START_FAKEBANK" ]
+then
+ echo -n "Setting up fakebank ..."
+ $USE_VALGRIND taler-fakebank-run \
+ -c "$CONF" \
+ -L "$LOGLEVEL" \
+ -n 4 \
+ 2> taler-fakebank-run.log &
+ echo " OK"
+fi
- if [ -n "${PGHOST:+}" ]
- then
- EHOST=$(echo "$PGHOST" | sed -e "s/\//\\\\\//g")
- LIBEUFIN_NEXUS_DB_CONNECTION=$(echo "$LIBEUFIN_NEXUS_DB_CONNECTION" | sed -e "s/\/var\/run\/postgresql/$EHOST/")
- taler-config -c "$CONF" -s "libeufin-nexus" -o "DB_CONNECTION" -V "$LIBEUFIN_NEXUS_DB_CONNECTION"
- fi
- export LIBEUFIN_NEXUS_DB_CONNECTION
- libeufin-nexus reset-tables \
- &> libeufin-nexus-reset.log
-
- # For convenience, username and password are
- # identical to those used at the Sandbox.
- echo -n "Create exchange Nexus user ..."
- libeufin-nexus superuser exchange --password x
- echo "OK"
- libeufin-nexus serve --port "$NEXUS_PORT" \
- 2> libeufin-nexus-stderr.log \
- > libeufin-nexus-stdout.log &
- echo $! > libeufin-nexus.pid
- export LIBEUFIN_NEXUS_URL="http://localhost:$NEXUS_PORT"
- echo -n "Waiting for Nexus ..."
+if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]
+then
+ echo -n "Waiting for the bank"
+ # Wait for bank to be available (usually the slowest)
OK="0"
- for n in $(seq 1 100); do
+ for n in $(seq 1 300)
+ do
echo -n "."
sleep "$DEFAULT_SLEEP"
- wget --timeout=1 \
- --tries=3 \
+ # bank
+ wget --tries=1 \
--waitretry=0 \
+ --timeout=1 \
+ --user admin \
+ --password secret \
+ "http://localhost:${BANK_PORT}/" \
-o /dev/null \
- -O /dev/null \
- "$LIBEUFIN_NEXUS_URL" || continue
+ -O /dev/null >/dev/null || continue
OK="1"
break
done
@@ -413,69 +346,36 @@ then
exit_skip "Failed to launch services (bank)"
fi
echo " OK"
-
- export LIBEUFIN_NEXUS_USERNAME=exchange
- export LIBEUFIN_NEXUS_PASSWORD=x
- echo -n "Creating a EBICS connection at Nexus ..."
- # FIXME-MS: '||true' should be removed after we make 'new-ebics-connection' idempotent!
- libeufin-cli connections new-ebics-connection \
- --ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
- --host-id talerebics \
- --partner-id talerpartner \
- --ebics-user-id exchangeebics \
- talerconn
- echo "OK"
-
- echo -n "Setup EBICS keying ..."
- libeufin-cli connections connect talerconn
- echo "OK"
- echo -n "Download bank account name from Sandbox ..."
- libeufin-cli connections download-bank-accounts talerconn
- echo "OK"
- echo -n "Importing bank account info into Nexus ..."
- libeufin-cli connections import-bank-account \
- --offered-account-id exchange \
- --nexus-bank-account-id exchange-nexus \
- talerconn
- echo "OK"
- echo -n "Setup payments submission task..."
- # Tries every second.
- libeufin-cli accounts task-schedule \
- --task-type submit \
- --task-name exchange-payments \
- --task-cronspec "* * *" \
- exchange-nexus
- echo "OK"
- # Tries every second. Ask C52
- echo -n "Setup history fetch task..."
- libeufin-cli accounts task-schedule \
- --task-type fetch \
- --task-name exchange-history \
- --task-cronspec "* * *" \
- --task-param-level report \
- --task-param-range-type latest \
- exchange-nexus
- echo "OK"
- # create Taler facade.
- echo -n "Create the Taler facade at Nexus..."
- libeufin-cli facades \
- new-taler-wire-gateway-facade \
- --currency TESTKUDOS --facade-name test-facade \
- talerconn exchange-nexus
- echo "OK"
- # Facade schema: http://localhost:$NEXUS_PORT/facades/test-facade/taler-wire-gateway/
- # FIXME: set the above URL automatically in the configuration?
fi
if [ "1" = "$START_FAKEBANK" ]
then
- echo -n "Setting up fakebank ..."
- $USE_VALGRIND taler-fakebank-run\
- -c "$CONF" \
- -L "$LOGLEVEL" \
- -n 4 \
- 2> taler-fakebank-run.log &
- echo " OK"
+ echo -n "Register Fakebank users ..."
+ register_fakebank_account fortytwo x
+ register_fakebank_account fortythree x
+ register_fakebank_account exchange x
+ register_fakebank_account tor x
+ register_fakebank_account gnunet x
+ register_fakebank_account tutorial x
+ register_fakebank_account survey x
+ echo " DONE"
+fi
+
+if [ "1" = "$START_BANK" ]
+then
+ echo -n "Register bank users ..."
+ # The specified IBAN and name must match the ones hard-coded into
+ # the C helper for the add-incoming call. Without this value,
+ # libeufin-bank won't find the target account to debit along a /add-incoming
+ # call.
+ register_bank_account fortytwo x "User42" FR7630006000011234567890189
+ register_bank_account fortythree x "Forty Three"
+ register_bank_account exchange x "Exchange Company" DE989651
+ register_bank_account tor x "Tor Project"
+ register_bank_account gnunet x "GNUnet"
+ register_bank_account tutorial x "Tutorial"
+ register_bank_account survey x "Survey"
+ echo " DONE"
fi
if [ "1" = "$START_EXCHANGE" ]
@@ -595,47 +495,6 @@ then
echo " DONE"
fi
-if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]
-then
- echo -n "Waiting for the bank"
- # Wait for bank to be available (usually the slowest)
- OK="0"
- for n in $(seq 1 300)
- do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- # bank
- wget --tries=1 \
- --waitretry=0 \
- --timeout=1 \
- --user admin \
- --password secret \
- "http://localhost:${BANK_PORT}/" \
- -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
- echo " OK"
-fi
-
-if [ "1" = "$START_FAKEBANK" ]
-then
- echo -n "Register Fakebank users ..."
- register_fakebank_account fortytwo x
- register_fakebank_account fortythree x
- register_fakebank_account exchange x
- register_fakebank_account tor x
- register_fakebank_account gnunet x
- register_fakebank_account tutorial x
- register_fakebank_account survey x
- echo " DONE"
-fi
-
echo -n "Waiting for Taler services ..."
# Wait for all other taler services to be available
diff --git a/src/testing/test-taler-exchange-wirewatch-postgres.conf b/src/testing/test-taler-exchange-wirewatch-postgres.conf
index 79d0825fd..81c96e240 100644
--- a/src/testing/test-taler-exchange-wirewatch-postgres.conf
+++ b/src/testing/test-taler-exchange-wirewatch-postgres.conf
@@ -51,6 +51,16 @@ PASSWORD = x
[bank]
HTTP_PORT = 8082
+[libeufin-bank]
+CURRENCY = EUR
+DEFAULT_CUSTOMER_DEBT_LIMIT = EUR:200
+DEFAULT_ADMIN_DEBT_LIMIT = EUR:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = EUR:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+SERVE = tcp
+PORT = 8082
+
# Need at least one coin, otherwise Exchange
# refuses to start.
[coin_eur_ct_1]
diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c
index 8f1fe2960..19a14d910 100644
--- a/src/testing/test_bank_api.c
+++ b/src/testing/test_bank_api.c
@@ -76,7 +76,7 @@ run (void *cls,
ssoptions = "-f";
break;
case TALER_TESTING_BS_IBAN:
- ssoptions = "-ns";
+ ssoptions = "-b";
break;
default:
ssoptions = NULL;
diff --git a/src/testing/test_bank_api.conf b/src/testing/test_bank_api.conf
index 0f5a8abeb..3618770bc 100644
--- a/src/testing/test_bank_api.conf
+++ b/src/testing/test_bank_api.conf
@@ -7,7 +7,15 @@ TALER_TEST_HOME = test_exchange_api_home/
currency = EUR
[bank]
-# not (!) used by the nexus, only by the helper
-# check to make sure the port is free for Nexus.
SERVE = http
HTTP_PORT = 8082
+
+[libeufin-bank]
+CURRENCY = EUR
+DEFAULT_CUSTOMER_DEBT_LIMIT = EUR:200
+DEFAULT_ADMIN_DEBT_LIMIT = EUR:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = EUR:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+SERVE = tcp
+PORT = 8082
diff --git a/src/testing/test_bank_api_twisted.c b/src/testing/test_bank_api_twisted.c
index 21ae56421..038ec8a1f 100644
--- a/src/testing/test_bank_api_twisted.c
+++ b/src/testing/test_bank_api_twisted.c
@@ -100,7 +100,7 @@ run (void *cls,
case TALER_TESTING_BS_IBAN:
exchange_auth_twisted.wire_gateway_url
= "http://localhost:8888/accounts/Exchange/taler-wire-gateway/";
- systype = "-ns";
+ systype = "-b";
break;
}
GNUNET_assert (NULL != systype);
diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf
index ebd3d67a0..66ceb7f4c 100644
--- a/src/testing/test_exchange_api.conf
+++ b/src/testing/test_exchange_api.conf
@@ -4,6 +4,20 @@
[PATHS]
TALER_TEST_HOME = test_exchange_api_home/
+[libeufin-bank]
+CURRENCY = EUR
+DEFAULT_CUSTOMER_DEBT_LIMIT = EUR:200
+DEFAULT_ADMIN_DEBT_LIMIT = EUR:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = EUR:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+SERVE = tcp
+PORT = 8082
+
+[libeufin-bankdb-postgres]
+CONFIG = postgresql:///talercheck
+
+
[taler]
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c
deleted file mode 100644
index cfee6f24a..000000000
--- a/src/testing/testing_api_helpers_bank.c
+++ /dev/null
@@ -1,687 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2018-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
- 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/>
-*/
-/**
- * @file testing/testing_api_helpers_bank.c
- * @brief convenience functions for bank tests.
- * @author Marcello Stanisci
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <gnunet/gnunet_util_lib.h>
-#include "taler_testing_lib.h"
-#include "taler_fakebank_lib.h"
-
-#define BANK_FAIL() \
- do {GNUNET_break (0); return NULL; } while (0)
-
-#define JDBC_TALERCHECK \
- "jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix." \
- "AFUNIXSocketFactory$FactoryArg&socketFactoryArg" \
- "=/var/run/postgresql/.s.PGSQL.5432"
-
-struct TALER_FAKEBANK_Handle *
-TALER_TESTING_run_fakebank (const char *bank_url,
- const char *currency)
-{
- const char *port;
- long pnum;
- struct TALER_FAKEBANK_Handle *fakebankd;
-
- port = strrchr (bank_url,
- (unsigned char) ':');
- if (NULL == port)
- pnum = 80;
- else
- pnum = strtol (port + 1, NULL, 10);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Starting Fakebank on port %u (%s)\n",
- (unsigned int) pnum,
- bank_url);
- fakebankd = TALER_FAKEBANK_start ((uint16_t) pnum,
- currency);
- if (NULL == fakebankd)
- {
- GNUNET_break (0);
- return NULL;
- }
- return fakebankd;
-}
-
-
-struct TALER_TESTING_LibeufinServices
-TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
-{
- struct GNUNET_OS_Process *nexus_proc;
- struct GNUNET_OS_Process *sandbox_proc;
- struct TALER_TESTING_LibeufinServices ret = { 0 };
- unsigned int iter;
- char *curl_check_cmd;
-
- setenv (
- "LIBEUFIN_NEXUS_DB_CONNECTION",
- JDBC_TALERCHECK,
- 1); // not overwriting any potentially existing DB.
-
- nexus_proc = GNUNET_OS_start_process (
- GNUNET_OS_INHERIT_STD_ERR,
- NULL, NULL, NULL,
- "libeufin-nexus",
- "libeufin-nexus",
- "serve",
- NULL);
- if (NULL == nexus_proc)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "exec",
- "libeufin-nexus");
- return ret;
- }
- GNUNET_asprintf (&curl_check_cmd,
- "curl -s %s",
- bc->exchange_auth.wire_gateway_url);
- /* give child time to start and bind against the socket */
- fprintf (stderr,
- "Waiting for `nexus' to be ready (via %s)\n", curl_check_cmd);
- iter = 0;
- do
- {
- if (10 == iter)
- {
- fprintf (
- stderr,
- "Failed to launch `nexus'\n");
- GNUNET_OS_process_kill (nexus_proc,
- SIGTERM);
- GNUNET_OS_process_wait (nexus_proc);
- GNUNET_OS_process_destroy (nexus_proc);
- GNUNET_free (curl_check_cmd);
- GNUNET_break (0);
- return ret;
- }
- fprintf (stderr, ".");
- sleep (1);
- iter++;
- }
- while (0 != system (curl_check_cmd));
-
- // start sandbox.
- GNUNET_free (curl_check_cmd);
- fprintf (stderr, "\n");
- setenv (
- "LIBEUFIN_SANDBOX_DB_CONNECTION",
- JDBC_TALERCHECK,
- 1); // not overwriting any potentially existing DB.
- setenv (
- "LIBEUFIN_SANDBOX_ADMIN_PASSWORD",
- "secret",
- 1);
- if (0 != system ("libeufin-sandbox config --currency=KUDOS default"))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not create the default demobank.\n");
- return ret;
- }
- sandbox_proc = GNUNET_OS_start_process (
- GNUNET_OS_INHERIT_STD_ERR,
- NULL, NULL, NULL,
- "libeufin-sandbox",
- "libeufin-sandbox",
- "serve",
- NULL);
- if (NULL == sandbox_proc)
- {
- GNUNET_break (0);
- return ret;
- }
-
- /* give child time to start and bind against the socket */
- fprintf (stderr,
- "Waiting for `sandbox' to be ready.\n");
- iter = 0;
- do
- {
- if (10 == iter)
- {
- fprintf (
- stderr,
- "Failed to launch `sandbox'\n");
- GNUNET_OS_process_kill (sandbox_proc,
- SIGTERM);
- GNUNET_OS_process_wait (sandbox_proc);
- GNUNET_OS_process_destroy (sandbox_proc);
- GNUNET_break (0);
- return ret;
- }
- fprintf (stderr, ".");
- sleep (1);
- iter++;
- }
- while (0 != system ("curl -s http://localhost:5000/"));
- fprintf (stderr, "\n");
-
- // Creates nexus user + bank loopback connection + Taler facade.
- if (0 != system ("taler-nexus-prepare"))
- {
- GNUNET_OS_process_kill (nexus_proc, SIGTERM);
- GNUNET_OS_process_wait (nexus_proc);
- GNUNET_OS_process_destroy (nexus_proc);
- GNUNET_OS_process_kill (sandbox_proc, SIGTERM);
- GNUNET_OS_process_wait (sandbox_proc);
- GNUNET_OS_process_destroy (sandbox_proc);
- TALER_LOG_ERROR ("Could not prepare nexus\n");
- GNUNET_break (0);
- return ret;
- }
- ret.nexus = nexus_proc;
- ret.sandbox = sandbox_proc;
- return ret;
-}
-
-
-struct GNUNET_OS_Process *
-TALER_TESTING_run_bank (const char *config_filename,
- const char *bank_url)
-{
- struct GNUNET_OS_Process *bank_proc;
- unsigned int iter;
- char *wget_cmd;
- char *database;
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (cfg,
- config_filename))
- {
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- exit (77);
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "bank",
- "database",
- &database))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- "bank",
- "database");
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- exit (77);
- }
- GNUNET_CONFIGURATION_destroy (cfg);
- bank_proc = GNUNET_OS_start_process (
- GNUNET_OS_INHERIT_STD_ERR,
- NULL, NULL, NULL,
- "taler-bank-manage-testing",
- "taler-bank-manage-testing",
- config_filename,
- database,
- "serve", NULL);
- GNUNET_free (database);
- if (NULL == bank_proc)
- {
- BANK_FAIL ();
- }
-
- GNUNET_asprintf (&wget_cmd,
- "wget -q -t 2 -T 1 %s -o /dev/null -O /dev/null",
- bank_url);
-
- /* give child time to start and bind against the socket */
- fprintf (stderr,
- "Waiting for `taler-bank-manage' to be ready (via %s)\n", wget_cmd);
- iter = 0;
- do
- {
- if (10 == iter)
- {
- fprintf (
- stderr,
- "Failed to launch `taler-bank-manage' (or `wget')\n");
- GNUNET_OS_process_kill (bank_proc,
- SIGTERM);
- GNUNET_OS_process_wait (bank_proc);
- GNUNET_OS_process_destroy (bank_proc);
- GNUNET_free (wget_cmd);
- BANK_FAIL ();
- }
- fprintf (stderr, ".");
- sleep (1);
- iter++;
- }
- while (0 != system (wget_cmd));
- GNUNET_free (wget_cmd);
- fprintf (stderr, "\n");
-
- return bank_proc;
-
-}
-
-
-enum GNUNET_GenericReturnValue
-TALER_TESTING_prepare_libeufin (const char *config_filename,
- bool reset_db,
- const char *config_section,
- struct TALER_TESTING_BankConfiguration *bc)
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- unsigned long long port;
- char *database = NULL; // silence compiler
- char *exchange_payto_uri;
-
- GNUNET_assert (0 ==
- strncasecmp (config_section,
- "exchange-account-",
- strlen ("exchange-account-")));
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (cfg,
- config_filename))
- {
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- config_section,
- "PAYTO_URI",
- &exchange_payto_uri))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- config_section,
- "PAYTO_URI");
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "bank",
- "HTTP_PORT",
- &port))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "bank",
- "HTTP_PORT");
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (database);
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
- (uint16_t) port))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Required port %llu not available, skipping.\n",
- port);
- GNUNET_break (0);
- GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- /* DB preparation */
- if (reset_db)
- {
- setenv (
- "LIBEUFIN_NEXUS_DB_CONNECTION",
- JDBC_TALERCHECK,
- 1); // not overwriting any potentially existing DB.
-
- if (0 != system ("libeufin-nexus reset-tables"))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to invoke db-removal command on nexusdb.\n");
- GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- setenv (
- "LIBEUFIN_SANDBOX_DB_CONNECTION",
- JDBC_TALERCHECK,
- 1); // not overwriting any potentially existing DB.
-
- if (0 != system ("libeufin-sandbox reset-tables"))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to invoke db-removal command on sandboxdb.\n");
- GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- }
-
- {
- char *csn;
-
- GNUNET_asprintf (&csn,
- "exchange-accountcredentials-%s",
- &config_section[strlen ("exchange-account-")]);
-
-
- if (GNUNET_OK !=
- TALER_BANK_auth_parse_cfg (cfg,
- csn,
- &bc->exchange_auth))
- {
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (csn);
- return GNUNET_SYSERR;
- }
- GNUNET_free (csn);
- }
- GNUNET_CONFIGURATION_destroy (cfg);
- bc->exchange_payto = exchange_payto_uri;
- bc->user42_payto =
- "payto://iban/SANDBOXX/FR7630006000011234567890189?receiver-name=User42";
- bc->user43_payto =
- "payto://iban/SANDBOXX/GB33BUKB20201555555555?receiver-name=User43";
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Relying on nexus %s on port %u\n",
- bc->exchange_auth.wire_gateway_url,
- (unsigned int) port);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "exchange payto: %s\n",
- bc->exchange_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "user42_payto: %s\n",
- bc->user42_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "user42_payto: %s\n",
- bc->user43_payto);
- return GNUNET_OK;
-}
-
-
-enum GNUNET_GenericReturnValue
-TALER_TESTING_prepare_bank (const char *config_filename,
- bool reset_db,
- const char *config_section,
- struct TALER_TESTING_BankConfiguration *bc)
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- unsigned long long port;
- struct GNUNET_OS_Process *dbreset_proc;
- enum GNUNET_OS_ProcessStatusType type;
- unsigned long code;
- char *database;
- char *exchange_payto_uri;
-
- GNUNET_assert (0 ==
- strncasecmp (config_section,
- "exchange-account-",
- strlen ("exchange-account-")));
- cfg = GNUNET_CONFIGURATION_create ();
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_load (cfg,
- config_filename))
- {
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "bank",
- "DATABASE",
- &database))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "bank",
- "DATABASE");
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- config_section,
- "PAYTO_URI",
- &exchange_payto_uri))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- config_section,
- "PAYTO_URI");
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "bank",
- "HTTP_PORT",
- &port))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "bank",
- "HTTP_PORT");
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (database);
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
- (uint16_t) port))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Required port %llu not available, skipping.\n",
- port);
- GNUNET_break (0);
- GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- /* DB preparation */
- if (reset_db)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Flushing bank database\n");
- if (NULL ==
- (dbreset_proc = GNUNET_OS_start_process (
- GNUNET_OS_INHERIT_STD_ERR,
- NULL, NULL, NULL,
- "taler-bank-manage",
- "taler-bank-manage",
- "-c", config_filename,
- "--with-db", database,
- "django",
- "flush",
- "--no-input", NULL)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to flush the bank db.\n");
- GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_SYSERR ==
- GNUNET_OS_process_wait_status (dbreset_proc,
- &type,
- &code))
- {
- GNUNET_OS_process_destroy (dbreset_proc);
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (database);
- return GNUNET_SYSERR;
- }
- if ( (type == GNUNET_OS_PROCESS_EXITED) &&
- (0 != code) )
- {
- fprintf (stderr,
- "Failed to setup database `%s'\n",
- database);
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (database);
- return GNUNET_SYSERR;
- }
- GNUNET_free (database);
- if ( (type != GNUNET_OS_PROCESS_EXITED) ||
- (0 != code) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected error running `taler-bank-manage django flush'!\n");
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- GNUNET_OS_process_destroy (dbreset_proc);
- }
- {
- char *csn;
-
- GNUNET_asprintf (&csn,
- "exchange-accountcredentials-%s",
- &config_section[strlen ("exchange-account-")]);
-
- if (GNUNET_OK !=
- TALER_BANK_auth_parse_cfg (cfg,
- csn,
- &bc->exchange_auth))
- {
- GNUNET_break (0);
- GNUNET_free (csn);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- GNUNET_free (csn);
- }
- GNUNET_CONFIGURATION_destroy (cfg);
- bc->exchange_payto = exchange_payto_uri;
- bc->user42_payto = "payto://x-taler-bank/localhost/42?receiver-name=42";
- bc->user43_payto = "payto://x-taler-bank/localhost/43?receiver-name=43";
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Using bank %s on port %u\n",
- bc->exchange_auth.wire_gateway_url,
- (unsigned int) port);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "exchange payto: %s\n",
- bc->exchange_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "user42_payto: %s\n",
- bc->user42_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "user43_payto: %s\n",
- bc->user43_payto);
- return GNUNET_OK;
-}
-
-
-enum GNUNET_GenericReturnValue
-TALER_TESTING_prepare_fakebank (const char *config_filename,
- const char *config_section,
- struct TALER_TESTING_BankConfiguration *bc)
-{
- struct GNUNET_CONFIGURATION_Handle *cfg;
- unsigned long long fakebank_port;
- char *exchange_payto_uri;
-
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
- config_filename))
- return GNUNET_SYSERR;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "BANK",
- "HTTP_PORT",
- &fakebank_port))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- "BANK",
- "HTTP_PORT");
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- config_section,
- "PAYTO_URI",
- &exchange_payto_uri))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- config_section,
- "PAYTO_URI");
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- {
- char *exchange_xtalerbank_account;
-
- exchange_xtalerbank_account
- = TALER_xtalerbank_account_from_payto (exchange_payto_uri);
- if (NULL == exchange_xtalerbank_account)
- {
- GNUNET_break (0);
- GNUNET_free (exchange_payto_uri);
- return GNUNET_SYSERR;
- }
- GNUNET_asprintf (&bc->exchange_auth.wire_gateway_url,
- "http://localhost:%u/%s/",
- (unsigned int) fakebank_port,
- exchange_xtalerbank_account);
- GNUNET_free (exchange_xtalerbank_account);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Using fakebank %s on port %u\n",
- bc->exchange_auth.wire_gateway_url,
- (unsigned int) fakebank_port);
-
- GNUNET_CONFIGURATION_destroy (cfg);
- if (GNUNET_OK !=
- TALER_TESTING_url_port_free (bc->exchange_auth.wire_gateway_url))
- {
- GNUNET_free (bc->exchange_auth.wire_gateway_url);
- bc->exchange_auth.wire_gateway_url = NULL;
- GNUNET_free (exchange_payto_uri);
- return GNUNET_SYSERR;
- }
- /* Now we know it's the fake bank, for purpose of authentication, we
- * don't have any auth. */
- bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
- bc->exchange_payto = exchange_payto_uri;
- bc->user42_payto = "payto://x-taler-bank/localhost/42?receiver-name=42";
- bc->user43_payto = "payto://x-taler-bank/localhost/43?receiver-name=43";
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",
- bc->exchange_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "user42_payto: %s\n",
- bc->user42_payto);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "user43_payto: %s\n",
- bc->user43_payto);
- return GNUNET_OK;
-}
-
-
-/* end of testing_api_helpers_bank.c */