-merge eufin branch (manually)
This commit is contained in:
parent
6834b1290f
commit
c602e11a36
@ -4,24 +4,176 @@
|
||||
# testing accounts before launching the bank properly.
|
||||
#
|
||||
# Takes 3 arguments:
|
||||
# $1: the configuration file name
|
||||
# $1: the Nexus port (Sandbox port prepends 1 to it)
|
||||
# $2: the database name
|
||||
# $3: serve-http or serve-uwsgi
|
||||
# $3: exchange base URL (used to specify the default exchange)
|
||||
# $4: config file (needs patch to specify exchange's PAYTO_URI)
|
||||
|
||||
set -eu
|
||||
|
||||
if [ "$#" -ne 3 ];
|
||||
if [ "$#" -ne 4 ];
|
||||
then
|
||||
echo "illegal number of parameters"
|
||||
echo "illegal number of parameters. \
|
||||
Give: Nexus port number, SQLIte file path, exchange base URL, config file path."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure starting accounts exist
|
||||
taler-bank-manage -c $1 --with-db $2 django provide_accounts
|
||||
taler-bank-manage -c $1 --with-db $2 django add_bank_account 42
|
||||
taler-bank-manage -c $1 --with-db $2 django add_bank_account 43
|
||||
# Must not terminate jobs here, as they are needed
|
||||
# by the script _importing_ this one. Those script
|
||||
# will then manage the termination.
|
||||
# trap cleanup EXIT
|
||||
|
||||
taler-bank-manage -c $1 --with-db $2 django changepassword_unsafe Exchange x
|
||||
export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$2"
|
||||
# Create the default demobank.
|
||||
libeufin-sandbox config --currency TESTKUDOS default
|
||||
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=secret
|
||||
libeufin-sandbox serve --port "1$1" \
|
||||
> libeufin-sandbox-stdout.log \
|
||||
2> libeufin-sandbox-stderr.log &
|
||||
echo $! > libeufin-sandbox.pid
|
||||
export LIBEUFIN_SANDBOX_URL="http://localhost:1$1/demobanks/default"
|
||||
set +e
|
||||
echo -n "Waiting for Sandbox.."
|
||||
for n in `seq 1 50`; do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
wget --timeout=1 \
|
||||
--tries=3 --waitretry=0 \
|
||||
-o /dev/null -O /dev/null \
|
||||
$LIBEUFIN_SANDBOX_URL
|
||||
break
|
||||
done
|
||||
echo OK
|
||||
|
||||
# Now run Django for good
|
||||
exec taler-bank-manage -c $1 --with-db $2 $3
|
||||
register_sandbox_account() {
|
||||
export LIBEUFIN_SANDBOX_USERNAME=$1
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=$2
|
||||
libeufin-cli sandbox \
|
||||
demobank \
|
||||
register --name "$3"
|
||||
unset LIBEUFIN_SANDBOX_USERNAME
|
||||
unset LIBEUFIN_SANDBOX_PASSWORD
|
||||
}
|
||||
set -e
|
||||
echo -n "Register the 'fortytwo' Sandbox user.."
|
||||
register_sandbox_account fortytwo x "Forty Two"
|
||||
echo OK
|
||||
echo -n "Register the 'fortythree' Sandbox user.."
|
||||
register_sandbox_account fortythree x "Forty Three"
|
||||
echo OK
|
||||
echo -n "Register 'exchange' Sandbox user.."
|
||||
register_sandbox_account exchange x "Exchange Company"
|
||||
echo OK
|
||||
echo -n "Register 'tor' Sandbox user.."
|
||||
register_sandbox_account tor x "Tor Project"
|
||||
echo OK
|
||||
echo -n "Register 'gnunet' Sandbox user.."
|
||||
register_sandbox_account gnunet x "GNUnet"
|
||||
echo OK
|
||||
echo -n "Register 'tutorial' Sandbox user.."
|
||||
register_sandbox_account tutorial x "Tutorial"
|
||||
echo OK
|
||||
echo -n "Register 'survey' Sandbox user.."
|
||||
register_sandbox_account survey x "Survey"
|
||||
echo OK
|
||||
echo -n "Specify exchange's PAYTO_URI in the config ..."
|
||||
export LIBEUFIN_SANDBOX_USERNAME=exchange
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=x
|
||||
PAYTO=`libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri'`
|
||||
taler-config -c $4 -s exchange-account-1 -o PAYTO_URI -V $PAYTO
|
||||
echo " OK"
|
||||
echo -n "Setting this exchange as the bank's default ..."
|
||||
EXCHANGE_PAYTO=`libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri'`
|
||||
libeufin-sandbox default-exchange "$3" "$EXCHANGE_PAYTO"
|
||||
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.."
|
||||
libeufin-cli sandbox \
|
||||
--sandbox-url http://localhost:1$1 \
|
||||
ebicshost create --host-id talerebics
|
||||
echo OK
|
||||
echo -n "Create exchange EBICS subscriber at Sandbox.."
|
||||
libeufin-cli sandbox \
|
||||
demobank new-ebicssubscriber --host-id talerebics \
|
||||
--user-id exchangeebics --partner-id talerpartner \
|
||||
--bank-account exchange # that's a username _and_ a bank account name
|
||||
echo OK
|
||||
unset LIBEUFIN_SANDBOX_USERNAME
|
||||
unset LIBEUFIN_SANDBOX_PASSWORD
|
||||
# Prepare Nexus, which is the side actually talking
|
||||
# to the exchange.
|
||||
export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$2"
|
||||
# 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 $1 \
|
||||
2> libeufin-nexus-stderr.log \
|
||||
> libeufin-nexus-stdout.log &
|
||||
echo $! > libeufin-nexus.pid
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:$1
|
||||
echo -n Waiting for Nexus..
|
||||
set +e
|
||||
for n in `seq 1 50`; do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
wget --timeout=1 \
|
||||
--tries=3 --waitretry=0 \
|
||||
-o /dev/null -O /dev/null \
|
||||
$LIBEUFIN_NEXUS_URL
|
||||
break
|
||||
done
|
||||
set -e
|
||||
echo OK
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
echo -n Creating a EBICS connection at Nexus..
|
||||
libeufin-cli connections new-ebics-connection \
|
||||
--ebics-url "http://localhost:1$1/ebicsweb" \
|
||||
--host-id talerebics \
|
||||
--partner-id talerpartner \
|
||||
--ebics-user-id exchangeebics \
|
||||
talerconn
|
||||
echo OK
|
||||
echo -n Setup EBICS keying..
|
||||
libeufin-cli connections connect talerconn > /dev/null
|
||||
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
|
||||
# TBD: 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:$1/facades/test-facade/taler-wire-gateway/
|
||||
|
@ -1,128 +1,115 @@
|
||||
#!/usr/bin/env python3
|
||||
# This file is in the public domain.
|
||||
#!/bin/bash
|
||||
|
||||
from requests import get, post
|
||||
from subprocess import call
|
||||
import base64
|
||||
set -eu
|
||||
|
||||
# EBICS details
|
||||
EBICS_URL = "http://localhost:5000/ebicsweb"
|
||||
HOST_ID = "HOST01"
|
||||
PARTNER_ID = "PARTNER1"
|
||||
USER_ID = "USER1"
|
||||
EBICS_VERSION = "H004"
|
||||
EBICS_URL="http://localhost:5000/ebicsweb"
|
||||
HOST_ID="HOST01"
|
||||
PARTNER_ID="PARTNER1"
|
||||
USER_ID="USER1"
|
||||
|
||||
SUBSCRIBER_IBAN = "ES9121000418450200051332"
|
||||
SUBSCRIBER_BIC = "BIC"
|
||||
SUBSCRIBER_NAME = "Exchange"
|
||||
|
||||
BANK_ACCOUNT_LABEL = "my-bank-account"
|
||||
BANK_CONNECTION_LABEL = "my-bank-connection"
|
||||
# This is used _both_ at Sandbox and at Nexus.
|
||||
# Basically, Nexus imports the offered bank account
|
||||
# using the same name used by the Sandbox.
|
||||
BANK_ACCOUNT_LABEL="my-bank-account"
|
||||
BANK_CONNECTION_LABEL="my-bank-connection"
|
||||
FACADE_LABEL="my-facade"
|
||||
|
||||
USERNAME="Exchange"
|
||||
USER_AUTHORIZATION_HEADER = "basic {}".format(
|
||||
base64.b64encode(b"Exchange:x").decode("utf-8")
|
||||
)
|
||||
export LIBEUFIN_SANDBOX_USERNAME=exchange
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=x
|
||||
export LIBEUFIN_SANDBOX_URL=http://localhost:5000/demobanks/default
|
||||
libeufin-cli sandbox demobank register --name "Exchange Company"
|
||||
|
||||
def assertResponse(response):
|
||||
if response.status_code != 200:
|
||||
print("Test failed on URL: {}".format(response.url))
|
||||
# stdout/stderr from both services is A LOT of text.
|
||||
# Confusing to dump all that to console.
|
||||
print("Check nexus.log and sandbox.log, probably under /tmp")
|
||||
exit(1)
|
||||
# Allows for finer grained checks.
|
||||
return response
|
||||
export LIBEUFIN_SANDBOX_USERNAME=fortytwo
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=x
|
||||
export LIBEUFIN_SANDBOX_URL=http://localhost:5000/demobanks/default
|
||||
libeufin-cli sandbox demobank register \
|
||||
--name User42 --iban FR7630006000011234567890189
|
||||
|
||||
# Create a nexus (super-) user
|
||||
check_call(["libeufin-nexus",
|
||||
"superuser",
|
||||
"--db-name", "/tmp/nexus-exchange-test.sqlite3",
|
||||
"Exchange",
|
||||
"--password", "x"]
|
||||
)
|
||||
export LIBEUFIN_SANDBOX_USERNAME=fortythree
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=x
|
||||
export LIBEUFIN_SANDBOX_URL=http://localhost:5000/demobanks/default
|
||||
libeufin-cli sandbox demobank register \
|
||||
--name User43 --iban GB33BUKB20201555555555
|
||||
|
||||
# Create a EBICS bank connection.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5001/bank-connections",
|
||||
json=dict(
|
||||
name=BANK_CONNECTION_LABEL,
|
||||
source="new",
|
||||
type="ebics",
|
||||
data=dict(
|
||||
ebicsURL=EBICS_URL, hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID
|
||||
),
|
||||
),
|
||||
headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
|
||||
)
|
||||
)
|
||||
export LIBEUFIN_SANDBOX_USERNAME=admin
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=secret
|
||||
export LIBEUFIN_SANDBOX_URL=http://localhost:5000/demobanks/default
|
||||
echo -n "Create EBICS host at Sandbox..."
|
||||
libeufin-cli sandbox \
|
||||
--sandbox-url "http://localhost:5000" \
|
||||
ebicshost create --host-id $HOST_ID
|
||||
echo " OK"
|
||||
|
||||
# Create a facade
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5001/facades",
|
||||
json=dict(
|
||||
name=FACADE_LABEL,
|
||||
type="taler-wire-gateway",
|
||||
creator=USERNAME,
|
||||
config=dict(
|
||||
bankAccount=BANK_ACCOUNT_LABEL,
|
||||
bankConnection=BANK_CONNECTION_LABEL,
|
||||
reserveTransferLevel="UNUSED",
|
||||
intervalIncremental="UNUSED"
|
||||
)
|
||||
),
|
||||
headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
|
||||
)
|
||||
)
|
||||
echo -n "Create exchange EBICS subscriber at Sandbox..."
|
||||
libeufin-cli sandbox \
|
||||
demobank new-ebicssubscriber --host-id $HOST_ID \
|
||||
--user-id $USER_ID --partner-id $PARTNER_ID \
|
||||
--bank-account exchange # that's a username _and_ a bank account name
|
||||
echo " OK"
|
||||
unset LIBEUFIN_SANDBOX_USERNAME
|
||||
unset LIBEUFIN_SANDBOX_PASSWORD
|
||||
unset LIBEUFIN_SANDBOX_URL
|
||||
|
||||
# Create the EBICS host at the Sandbox.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5000/admin/ebics/host",
|
||||
json=dict(hostID=HOST_ID, ebicsVersion=EBICS_VERSION),
|
||||
)
|
||||
)
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:5001/
|
||||
|
||||
# Create Exchange EBICS subscriber at the Sandbox.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5000/admin/ebics/subscribers",
|
||||
json=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID),
|
||||
)
|
||||
)
|
||||
echo -n "Create the exchange (super)user at Nexus..."
|
||||
libeufin-nexus superuser exchange --password x
|
||||
echo " DONE"
|
||||
|
||||
# Create a bank account associated to the Exchange's EBICS subscriber,
|
||||
# again at the Sandbox.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5000/admin/ebics/bank-accounts",
|
||||
json=dict(
|
||||
subscriber=dict(hostID=HOST_ID, partnerID=PARTNER_ID, userID=USER_ID),
|
||||
iban=SUBSCRIBER_IBAN,
|
||||
bic=SUBSCRIBER_BIC,
|
||||
name=SUBSCRIBER_NAME,
|
||||
label=BANK_ACCOUNT_LABEL,
|
||||
),
|
||||
)
|
||||
)
|
||||
echo -n "Creating a EBICS connection at Nexus..."
|
||||
libeufin-cli connections new-ebics-connection \
|
||||
--ebics-url $EBICS_URL \
|
||||
--host-id $HOST_ID \
|
||||
--partner-id $PARTNER_ID \
|
||||
--ebics-user-id $USER_ID \
|
||||
$BANK_CONNECTION_LABEL
|
||||
echo " OK"
|
||||
|
||||
# 'connect' to the bank: upload+download keys.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5001/bank-connections/{}/connect".format(BANK_CONNECTION_LABEL),
|
||||
json=dict(),
|
||||
headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
|
||||
)
|
||||
)
|
||||
echo -n "Setup EBICS keying..."
|
||||
libeufin-cli connections connect $BANK_CONNECTION_LABEL > /dev/null
|
||||
echo " OK"
|
||||
|
||||
# Download bank accounts.
|
||||
assertResponse(
|
||||
post(
|
||||
"http://localhost:5001/bank-connections/{}/ebics/import-accounts".format(BANK_CONNECTION_LABEL),
|
||||
json=dict(),
|
||||
headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
|
||||
)
|
||||
)
|
||||
echo -n "Download bank account name from Sandbox..."
|
||||
libeufin-cli connections download-bank-accounts $BANK_CONNECTION_LABEL
|
||||
echo " OK"
|
||||
|
||||
echo -n "Importing bank account info into Nexus..."
|
||||
libeufin-cli connections import-bank-account \
|
||||
--offered-account-id exchange \
|
||||
--nexus-bank-account-id $BANK_ACCOUNT_LABEL \
|
||||
$BANK_CONNECTION_LABEL
|
||||
echo " OK"
|
||||
|
||||
echo -n "Create the Taler facade at Nexus..."
|
||||
libeufin-cli facades \
|
||||
new-taler-wire-gateway-facade \
|
||||
--currency KUDOS --facade-name $FACADE_LABEL \
|
||||
$BANK_CONNECTION_LABEL $BANK_ACCOUNT_LABEL
|
||||
echo " DONE"
|
||||
|
||||
echo -n Setup payments submission task..
|
||||
# Tries every second.
|
||||
libeufin-cli accounts task-schedule \
|
||||
--task-type submit \
|
||||
--task-name exchange-payments \
|
||||
--task-cronspec "* * *" \
|
||||
$BANK_ACCOUNT_LABEL
|
||||
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 \
|
||||
$BANK_ACCOUNT_LABEL
|
||||
echo OK
|
||||
|
||||
# unset, in case the script gets 'source'd.
|
||||
unset LIBEUFIN_NEXUS_USERNAME
|
||||
unset LIBEUFIN_NEXUS_PASSWORD
|
||||
unset LIBEUFIN_NEXUS_URL
|
||||
|
@ -110,7 +110,7 @@ currency = TESTKUDOS
|
||||
[merchant-exchange-default]
|
||||
CURRENCY = TESTKUDOS
|
||||
EXCHANGE_BASE_URL = http://localhost:8081/
|
||||
MASTER_KEY = JM0NJXHM6Y6HYAPK2WDFH3HDJ2E9KZWGKM3E0FYRV2V3HCTB3DQ0
|
||||
MASTER_KEY = EBN9WPH07EP1SCEXWH9CGZ83S6ERGFXANDD78WF3SV4AKF8X4QH0
|
||||
|
||||
[merchant-account-merchant]
|
||||
ACTIVE_default = YES
|
||||
@ -119,9 +119,9 @@ PAYTO_URI = payto://x-taler-bank/localhost/42
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
PASSWORD = x
|
||||
USERNAME = Exchange
|
||||
USERNAME = exchange
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
WIRE_GATEWAY_URL = http://localhost:8082/taler-wire-gateway/Exchange/
|
||||
WIRE_GATEWAY_URL = http://localhost:8082/facades/test-facade/taler-wire-gateway/
|
||||
|
||||
[exchange-account-1]
|
||||
enable_credit = yes
|
||||
@ -154,7 +154,7 @@ CONFIG = postgres:///auditor-basedb
|
||||
[exchange]
|
||||
LOOKAHEAD_SIGN = 32 weeks 1 day
|
||||
SIGNKEY_DURATION = 4 weeks
|
||||
MASTER_PUBLIC_KEY = JM0NJXHM6Y6HYAPK2WDFH3HDJ2E9KZWGKM3E0FYRV2V3HCTB3DQ0
|
||||
MASTER_PUBLIC_KEY = EBN9WPH07EP1SCEXWH9CGZ83S6ERGFXANDD78WF3SV4AKF8X4QH0
|
||||
SIGNKEY_LEGAL_DURATION = 4 weeks
|
||||
UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
|
||||
|
||||
@ -172,7 +172,7 @@ DATABASE = postgres:///auditor-basedb
|
||||
CONFIG = postgres:///auditor-basedb
|
||||
|
||||
[auditor]
|
||||
PUBLIC_KEY = 73NJKBP4MHJF8274K88F4WFWKNYMK8T6MTSE6HHYS6WC01H9YH7G
|
||||
PUBLIC_KEY = VZ14T1ZX99S51PCHBKFTGGNJ89ZF9FRY1BSDQXBYZ9H5W2PWETX0
|
||||
TINY_AMOUNT = TESTKUDOS:0.01
|
||||
BASE_URL = http://localhost:8083/
|
||||
|
||||
@ -181,3 +181,4 @@ TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
|
||||
TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
|
||||
TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
|
||||
TALER_HOME = ${PWD}/generate_auditordb_home/
|
||||
|
||||
|
Binary file not shown.
@ -74,9 +74,9 @@ enable_debit = yes
|
||||
enable_credit = yes
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/taler-wire-gateway/Exchange/"
|
||||
WIRE_GATEWAY_URL = http://localhost:8082/facades/test-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
USERNAME = exchange
|
||||
PASSWORD = x
|
||||
|
||||
[merchant-account-merchant]
|
||||
|
@ -15,6 +15,20 @@
|
||||
#
|
||||
set -eu
|
||||
|
||||
function get_iban() {
|
||||
export LIBEUFIN_SANDBOX_USERNAME=$1
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=$2
|
||||
export LIBEUFIN_SANDBOX_URL=$BANK_URL
|
||||
libeufin-cli sandbox demobank info --bank-account $1 | jq --raw-output '.iban'
|
||||
}
|
||||
|
||||
function get_payto_uri() {
|
||||
export LIBEUFIN_SANDBOX_USERNAME=$1
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=$2
|
||||
export LIBEUFIN_SANDBOX_URL=$BANK_URL
|
||||
libeufin-cli sandbox demobank info --bank-account $1 | jq --raw-output '.paytoUri'
|
||||
}
|
||||
|
||||
# Cleanup to run whenever we exit
|
||||
function cleanup()
|
||||
{
|
||||
@ -22,6 +36,9 @@ function cleanup()
|
||||
do
|
||||
kill $n 2> /dev/null || true
|
||||
done
|
||||
echo Killing euFin..
|
||||
kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
|
||||
kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
|
||||
wait
|
||||
}
|
||||
|
||||
@ -34,10 +51,8 @@ function exit_skip() {
|
||||
echo $1
|
||||
exit 77
|
||||
}
|
||||
|
||||
# Where do we write the result?
|
||||
BASEDB=${1:-"auditor-basedb"}
|
||||
|
||||
# Name of the Postgres database we will use for the script.
|
||||
# Will be dropped, do NOT use anything that might be used
|
||||
# elsewhere
|
||||
@ -47,16 +62,15 @@ export WALLET_DB=${BASEDB:-"wallet"}.wdb
|
||||
|
||||
# delete existing wallet database
|
||||
rm -f $WALLET_DB
|
||||
|
||||
# delete libeufin database
|
||||
rm -f $TARGET_DB
|
||||
|
||||
# Configuration file will be edited, so we create one
|
||||
# from the template.
|
||||
CONF=${BASEDB}.conf
|
||||
cp generate-auditor-basedb.conf $CONF
|
||||
|
||||
|
||||
echo -n "Testing for taler-bank-manage"
|
||||
taler-bank-manage --help >/dev/null </dev/null || exit_skip " MISSING"
|
||||
CONF_ONCE=${BASEDB}.conf
|
||||
cp generate-auditor-basedb.conf $CONF_ONCE
|
||||
echo -n "Testing for libeufin"
|
||||
libeufin-cli --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"
|
||||
@ -69,7 +83,7 @@ echo " FOUND"
|
||||
pwd
|
||||
# Clean up
|
||||
|
||||
DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
|
||||
DATA_DIR=`taler-config -f -c $CONF_ONCE -s PATHS -o TALER_HOME`
|
||||
rm -rf $DATA_DIR || true
|
||||
|
||||
# reset database
|
||||
@ -78,59 +92,59 @@ createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
|
||||
|
||||
|
||||
# obtain key configuration data
|
||||
MASTER_PRIV_FILE=`taler-config -f -c $CONF -s exchange-offline -o MASTER_PRIV_FILE`
|
||||
MASTER_PRIV_FILE=`taler-config -f -c $CONF_ONCE -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
|
||||
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_PORT=`taler-config -c $CONF_ONCE -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_FILE=`taler-config -f -c $CONF_ONCE -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
|
||||
AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
|
||||
EXCHANGE_URL=`taler-config -c $CONF_ONCE -s EXCHANGE -o BASE_URL`
|
||||
BANK_PORT=`taler-config -c $CONF_ONCE -s BANK -o HTTP_PORT`
|
||||
BANK_URL="http://localhost:1${BANK_PORT}/demobanks/default"
|
||||
|
||||
echo "AUDITOR PUB is $AUDITOR_PUB using file $AUDITOR_PRIV_FILE"
|
||||
|
||||
# patch configuration
|
||||
taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
|
||||
taler-config -c $CONF -s auditor -o PUBLIC_KEY -V $AUDITOR_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:///$TARGET_DB
|
||||
taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF -s bank -o database -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF_ONCE -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
|
||||
taler-config -c $CONF_ONCE -s auditor -o PUBLIC_KEY -V $AUDITOR_PUB
|
||||
taler-config -c $CONF_ONCE -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
|
||||
taler-config -c $CONF_ONCE -s exchangedb-postgres -o CONFIG -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF_ONCE -s auditordb-postgres -o CONFIG -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF_ONCE -s merchantdb-postgres -o CONFIG -V postgres:///$TARGET_DB
|
||||
taler-config -c $CONF_ONCE -s bank -o database -V postgres:///$TARGET_DB
|
||||
|
||||
# setup exchange
|
||||
echo "Setting up exchange"
|
||||
taler-exchange-dbinit -c $CONF
|
||||
taler-exchange-dbinit -c $CONF_ONCE
|
||||
|
||||
echo "Setting up merchant"
|
||||
taler-merchant-dbinit -c $CONF
|
||||
taler-merchant-dbinit -c $CONF_ONCE
|
||||
|
||||
# setup auditor
|
||||
echo "Setting up auditor"
|
||||
taler-auditor-dbinit -c $CONF || exit_skip "Failed to initialize auditor DB"
|
||||
taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL || exit_skip "Failed to add exchange to auditor"
|
||||
taler-auditor-dbinit -c $CONF_ONCE || exit_skip "Failed to initialize auditor DB"
|
||||
taler-auditor-exchange -c $CONF_ONCE -m $MASTER_PUB -u $EXCHANGE_URL || exit_skip "Failed to add exchange to auditor"
|
||||
|
||||
# Launch services
|
||||
echo "Launching services"
|
||||
taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve &> taler-bank.log &
|
||||
echo "Launching services (pre audit DB: $TARGET_DB)"
|
||||
taler-bank-manage-testing $BANK_PORT $TARGET_DB $EXCHANGE_URL $CONF_ONCE
|
||||
TFN=`which taler-exchange-httpd`
|
||||
TBINPFX=`dirname $TFN`
|
||||
TLIBEXEC=${TBINPFX}/../lib/taler/libexec/
|
||||
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-exchange-secmod-eddsa -c $CONF_ONCE 2> taler-exchange-secmod-eddsa.log &
|
||||
taler-exchange-secmod-rsa -c $CONF_ONCE 2> taler-exchange-secmod-rsa.log &
|
||||
taler-exchange-secmod-cs -c $CONF_ONCE 2> taler-exchange-secmod-cs.log &
|
||||
taler-exchange-httpd -c $CONF_ONCE 2> taler-exchange-httpd.log &
|
||||
taler-merchant-httpd -c $CONF_ONCE -L INFO 2> taler-merchant-httpd.log &
|
||||
taler-exchange-wirewatch -c $CONF_ONCE 2> taler-exchange-wirewatch.log &
|
||||
taler-auditor-httpd -L INFO -c $CONF_ONCE 2> taler-auditor-httpd.log &
|
||||
|
||||
# Wait for all bank to be available (usually the slowest)
|
||||
for n in `seq 1 50`
|
||||
@ -169,14 +183,12 @@ if [ 1 != $OK ]
|
||||
then
|
||||
exit_skip "Failed to launch services"
|
||||
fi
|
||||
echo " DONE"
|
||||
|
||||
echo -n "Setting up keys"
|
||||
taler-exchange-offline -c $CONF \
|
||||
taler-exchange-offline -c $CONF_ONCE \
|
||||
download sign \
|
||||
enable-account payto://x-taler-bank/localhost/Exchange \
|
||||
enable-account `taler-config -c $CONF_ONCE -s exchange-account-1 -o PAYTO_URI` \
|
||||
enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
|
||||
wire-fee now x-taler-bank TESTKUDOS:0.07 TESTKUDOS:0.01 TESTKUDOS:0.01 \
|
||||
wire-fee now iban TESTKUDOS:0.07 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
|
||||
|
||||
@ -199,7 +211,7 @@ fi
|
||||
echo " DONE"
|
||||
echo -n "Adding auditor signatures ..."
|
||||
|
||||
taler-auditor-offline -c $CONF \
|
||||
taler-auditor-offline -c $CONF_ONCE \
|
||||
download sign upload &> taler-auditor-offline.log
|
||||
|
||||
echo " DONE"
|
||||
@ -227,16 +239,16 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'runIntegrationTest' \
|
||||
}' \
|
||||
--arg MERCHANT_URL "$MERCHANT_URL" \
|
||||
--arg EXCHANGE_URL "$EXCHANGE_URL" \
|
||||
--arg BANK_URL "$BANK_URL"
|
||||
--arg BANK_URL "$BANK_URL/access-api/"
|
||||
)" &> taler-wallet-cli.log
|
||||
|
||||
|
||||
echo "Shutting down services"
|
||||
cleanup
|
||||
|
||||
# Dump database
|
||||
echo "Dumping database"
|
||||
echo "Dumping database ${BASEDB}(-libeufin).sql"
|
||||
pg_dump -O $TARGET_DB | sed -e '/AS integer/d' > ${BASEDB}.sql
|
||||
sqlite3 $TARGET_DB ".dump" > ${BASEDB}-libeufin.sql
|
||||
|
||||
echo $MASTER_PUB > ${BASEDB}.mpub
|
||||
|
||||
@ -245,7 +257,7 @@ date +%s > ${BASEDB}.age
|
||||
# clean up
|
||||
echo "Final clean up"
|
||||
dropdb $TARGET_DB
|
||||
|
||||
rm $TARGET_DB # libeufin DB
|
||||
rm -rf $DATA_DIR || true
|
||||
|
||||
echo "====================================="
|
||||
|
@ -14,9 +14,19 @@ function cleanup()
|
||||
do
|
||||
kill $n 2> /dev/null || true
|
||||
done
|
||||
echo Killing euFin..
|
||||
kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
|
||||
kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
|
||||
wait
|
||||
}
|
||||
|
||||
function get_payto_uri() {
|
||||
export LIBEUFIN_SANDBOX_USERNAME=$1
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=$2
|
||||
export LIBEUFIN_SANDBOX_URL=$BANK_URL
|
||||
libeufin-cli sandbox demobank info --bank-account $1 | jq --raw-output '.paytoUri'
|
||||
}
|
||||
|
||||
# Install cleanup handler (except for kill -9)
|
||||
trap cleanup EXIT
|
||||
|
||||
@ -43,8 +53,8 @@ export CONF=generate-auditor-basedb-revocation.conf
|
||||
cp generate-auditor-basedb.conf $CONF
|
||||
|
||||
|
||||
echo -n "Testing for taler-bank-manage"
|
||||
taler-bank-manage --help >/dev/null </dev/null || exit_skip " MISSING"
|
||||
echo -n "Testing for libeufin(-cli)"
|
||||
libeufin-cli --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"
|
||||
@ -53,8 +63,6 @@ echo -n "Testing for curl"
|
||||
curl --help >/dev/null </dev/null || exit_skip " MISSING"
|
||||
echo " FOUND"
|
||||
|
||||
|
||||
|
||||
# Clean up
|
||||
DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
|
||||
rm -rf $DATA_DIR || true
|
||||
@ -62,6 +70,7 @@ rm -rf $DATA_DIR || true
|
||||
# reset database
|
||||
dropdb $TARGET_DB >/dev/null 2>/dev/null || true
|
||||
createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
|
||||
rm $TARGET_DB >/dev/null 2>/dev/null || true # libeufin
|
||||
|
||||
# obtain key configuration data
|
||||
MASTER_PRIV_FILE=`taler-config -f -c $CONF -s exchange-offline -o MASTER_PRIV_FILE`
|
||||
@ -73,7 +82,7 @@ export EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
|
||||
MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
|
||||
export MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
|
||||
BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
|
||||
export BANK_URL=http://localhost:${BANK_PORT}/
|
||||
export BANK_URL=http://localhost:1${BANK_PORT}/demobanks/default
|
||||
export 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`
|
||||
@ -105,7 +114,7 @@ taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
|
||||
|
||||
# Launch services
|
||||
echo "Launching services"
|
||||
taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve &> revocation-bank.log &
|
||||
taler-bank-manage-testing $BANK_PORT $TARGET_DB $EXCHANGE_URL $CONF
|
||||
TFN=`which taler-exchange-httpd`
|
||||
TBINPFX=`dirname $TFN`
|
||||
TLIBEXEC=${TBINPFX}/../lib/taler/libexec/
|
||||
@ -166,9 +175,9 @@ echo -n "Setting up keys"
|
||||
|
||||
taler-exchange-offline -c $CONF \
|
||||
download sign \
|
||||
enable-account payto://x-taler-bank/localhost/Exchange \
|
||||
enable-account `taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI` \
|
||||
enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
|
||||
wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 \
|
||||
wire-fee now iban 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
|
||||
|
||||
@ -211,7 +220,7 @@ taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance'
|
||||
bankBaseUrl: $BANK_URL,
|
||||
exchangeBaseUrl: $EXCHANGE_URL,
|
||||
}' \
|
||||
--arg BANK_URL $BANK_URL \
|
||||
--arg BANK_URL "$BANK_URL/access-api/" \
|
||||
--arg EXCHANGE_URL $EXCHANGE_URL
|
||||
)"
|
||||
|
||||
@ -388,7 +397,10 @@ cleanup
|
||||
|
||||
# Dump database
|
||||
echo "Dumping database"
|
||||
echo "Dumping PostgreSQL database: ${BASEDB}.sql"
|
||||
pg_dump -O $TARGET_DB | sed -e '/AS integer/d' > ${BASEDB}.sql
|
||||
echo "Dumping libeufin database: ${BASEDB}-libeufin.sql"
|
||||
sqlite3 $TARGET_DB ".dump" > ${BASEDB}-libeufin.sql
|
||||
|
||||
echo $MASTER_PUB > ${BASEDB}.mpub
|
||||
date +%s > ${BASEDB}.age
|
||||
@ -396,6 +408,7 @@ date +%s > ${BASEDB}.age
|
||||
# clean up
|
||||
echo "Final clean up"
|
||||
dropdb $TARGET_DB
|
||||
rm $TARGET_DB # libeufin
|
||||
rm -rf $DATA_DIR || true
|
||||
rm -f $CONF
|
||||
rm -r $TMP_DIR
|
||||
|
@ -1 +0,0 @@
|
||||
1655640625
|
@ -9,9 +9,9 @@ enable_debit = yes
|
||||
enable_credit = yes
|
||||
|
||||
[exchange-accountcredentials-1]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/taler-wire-gateway/Exchange/"
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/facades/test-facade/taler-wire-gateway/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
USERNAME = exchange
|
||||
PASSWORD = x
|
||||
|
||||
[exchangedb]
|
||||
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
MREDG0XYVSX4RPYSA6JNQZ93P2DDBG45F3M6RBZXRS49M0JTVN40
|
File diff suppressed because it is too large
Load Diff
@ -1576,10 +1576,12 @@ process_debits (void *cls)
|
||||
"Checking bank DEBIT records of account `%s'\n",
|
||||
wa->ai->section_name);
|
||||
GNUNET_assert (NULL == wa->dhh);
|
||||
// FIXME: handle the case where more than INT32_MAX transactions exist.
|
||||
// (CG: used to be INT64_MAX, changed by MS to INT32_MAX, why? To be discussed with him!)
|
||||
wa->dhh = TALER_BANK_debit_history (ctx,
|
||||
wa->ai->auth,
|
||||
wa->out_wire_off,
|
||||
INT64_MAX,
|
||||
INT32_MAX,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_debit_cb,
|
||||
wa);
|
||||
@ -2012,10 +2014,12 @@ process_credits (void *cls)
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||
"Starting bank CREDIT history of account `%s'\n",
|
||||
wa->ai->section_name);
|
||||
// NOTE: handle the case where more than INT32_MAX transactions exist.
|
||||
// (CG: used to be INT64_MAX, changed by MS to INT32_MAX, why? To be discussed with him!)
|
||||
wa->chh = TALER_BANK_credit_history (ctx,
|
||||
wa->ai->auth,
|
||||
wa->in_wire_off,
|
||||
INT64_MAX,
|
||||
INT32_MAX,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_credit_cb,
|
||||
wa);
|
||||
|
@ -28,6 +28,11 @@ TESTS=${1:-$ALL_TESTS}
|
||||
# VALGRIND=valgrind
|
||||
VALGRIND=""
|
||||
|
||||
# Number of seconds to let libeuifn background
|
||||
# tasks apply a cycle of payment submission and
|
||||
# history request.
|
||||
LIBEUFIN_SETTLE_TIME=1
|
||||
|
||||
# Exit, with status code "skip" (no 'real' failure)
|
||||
function exit_skip() {
|
||||
echo $1
|
||||
@ -48,17 +53,72 @@ function cleanup()
|
||||
kill $n 2> /dev/null || true
|
||||
done
|
||||
wait
|
||||
# kill euFin
|
||||
echo Killing euFin..
|
||||
kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
|
||||
kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
|
||||
}
|
||||
|
||||
# Install cleanup handler (except for kill -9)
|
||||
trap cleanup EXIT
|
||||
|
||||
function launch_libeufin () {
|
||||
export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3"
|
||||
libeufin-nexus serve --port 8082 \
|
||||
2> libeufin-nexus-stderr.log \
|
||||
> libeufin-nexus-stdout.log &
|
||||
echo $! > libeufin-nexus.pid
|
||||
export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3"
|
||||
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=secret
|
||||
libeufin-sandbox serve --port 18082 \
|
||||
> libeufin-sandbox-stdout.log \
|
||||
2> libeufin-sandbox-stderr.log &
|
||||
echo $! > libeufin-sandbox.pid
|
||||
}
|
||||
|
||||
# Downloads new transactions from the bank.
|
||||
function nexus_fetch_transactions () {
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:8082/
|
||||
libeufin-cli accounts fetch-transactions \
|
||||
--range-type since-last --level report exchange-nexus > /dev/null
|
||||
unset LIBEUFIN_NEXUS_USERNAME
|
||||
unset LIBEUFIN_NEXUS_PASSWORD
|
||||
unset LIBEUFIN_NEXUS_URL
|
||||
}
|
||||
|
||||
|
||||
# Instruct Nexus to all the prepared payments (= those
|
||||
# POSTed to /transfer by the exchange).
|
||||
function nexus_submit_to_sandbox () {
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:8082/
|
||||
libeufin-cli accounts submit-payments exchange-nexus
|
||||
unset LIBEUFIN_NEXUS_USERNAME
|
||||
unset LIBEUFIN_NEXUS_PASSWORD
|
||||
unset LIBEUFIN_NEXUS_URL
|
||||
}
|
||||
# Operations to run before the actual audit
|
||||
function pre_audit () {
|
||||
# Launch bank
|
||||
echo -n "Launching bank "
|
||||
taler-bank-manage-testing $CONF postgres:///$DB serve 2>bank.err >bank.log &
|
||||
echo -n "Launching bank"
|
||||
EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
|
||||
launch_libeufin
|
||||
for n in `seq 1 80`
|
||||
do
|
||||
echo -n "."
|
||||
sleep 0.1
|
||||
OK=1
|
||||
wget http://localhost:18082/ -o /dev/null -O /dev/null >/dev/null && break
|
||||
OK=0
|
||||
done
|
||||
if [ 1 != $OK ]
|
||||
then
|
||||
exit_skip "Failed to launch Sandbox"
|
||||
fi
|
||||
sleep $LIBEUFIN_SETTLE_TIME
|
||||
for n in `seq 1 80`
|
||||
do
|
||||
echo -n "."
|
||||
@ -69,7 +129,7 @@ function pre_audit () {
|
||||
done
|
||||
if [ 1 != $OK ]
|
||||
then
|
||||
exit_skip "Failed to launch bank"
|
||||
exit_skip "Failed to launch Nexus"
|
||||
fi
|
||||
echo " DONE"
|
||||
if test ${1:-no} = "aggregator"
|
||||
@ -83,6 +143,13 @@ function pre_audit () {
|
||||
echo -n "Running exchange transfer ..."
|
||||
taler-exchange-transfer -L INFO -t -c $CONF 2> transfer.log || exit_fail "FAIL"
|
||||
echo " DONE"
|
||||
echo -n "Running Nexus payment submitter ..."
|
||||
nexus_submit_to_sandbox
|
||||
echo " DONE"
|
||||
# Make outgoing transactions appear in the TWG:
|
||||
echo -n "Download bank transactions ..."
|
||||
nexus_fetch_transactions
|
||||
echo " DONE"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -111,7 +178,7 @@ function audit_only () {
|
||||
echo -n "."
|
||||
$VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire.json 2> test-wire-audit.log || exit_fail "wire audit failed"
|
||||
echo -n "."
|
||||
$VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> test-wire-audit-inc.log || exit_fail "wire audit failed"
|
||||
$VALGRIND taler-helper-auditor-wire -i -L DEBUG -c $CONF -m $MASTER_PUB > test-audit-wire-inc.json 2> test-wire-audit-inc.log || exit_fail "wire audit inc failed"
|
||||
echo -n "."
|
||||
|
||||
echo " DONE"
|
||||
@ -166,11 +233,14 @@ function run_audit () {
|
||||
# Do a full reload of the (original) database
|
||||
full_reload()
|
||||
{
|
||||
echo -n "Doing full reload of the database... "
|
||||
echo "Doing full reload of the database... "
|
||||
dropdb $DB 2> /dev/null || true
|
||||
rm $DB.sqlite3 2> /dev/null || true # libeufin
|
||||
createdb -T template0 $DB || exit_skip "could not create database"
|
||||
# Import pre-generated database, -q(ietly) using single (-1) transaction
|
||||
psql -Aqt $DB -q -1 -f ${BASEDB}.sql > /dev/null || exit_skip "Failed to load database"
|
||||
echo "Loading libeufin basedb: ${BASEDB}-libeufin.sql"
|
||||
sqlite3 $DB.sqlite3 < ${BASEDB}-libeufin.sql || exit_skip "Failed to load libEufin database"
|
||||
echo "DONE"
|
||||
}
|
||||
|
||||
@ -179,7 +249,6 @@ function test_0() {
|
||||
|
||||
echo "===========0: normal run with aggregator==========="
|
||||
run_audit aggregator
|
||||
|
||||
echo "Checking output"
|
||||
# if an emergency was detected, that is a bug and we should fail
|
||||
echo -n "Test for emergencies... "
|
||||
@ -379,7 +448,7 @@ echo "OK"
|
||||
# Change amount of wire transfer reported by exchange
|
||||
function test_2() {
|
||||
|
||||
echo "===========2: reserves_in inconsistency==========="
|
||||
echo "===========2: reserves_in inconsistency ==========="
|
||||
echo "UPDATE reserves_in SET credit_val=5 WHERE reserve_in_serial_id=1" | psql -At $DB
|
||||
|
||||
run_audit
|
||||
@ -671,10 +740,10 @@ echo "UPDATE reserves_out SET reserve_sig='$OLD_SIG' WHERE h_blind_ev='$HBE'" |
|
||||
function test_8() {
|
||||
|
||||
echo "===========8: wire-transfer-subject disagreement==========="
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE amount='TESTKUDOS:10' ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_WTID=`echo "SELECT subject FROM app_banktransaction WHERE id='$OLD_ID';" | psql $DB -Aqt`
|
||||
OLD_ID=`echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | sqlite3 $DB.sqlite3`
|
||||
OLD_WTID=`echo "SELECT reservePublicKey FROM TalerIncomingPayments WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3`
|
||||
NEW_WTID="CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG"
|
||||
echo "UPDATE app_banktransaction SET subject='$NEW_WTID' WHERE id='$OLD_ID';" | psql -Aqt $DB
|
||||
echo "UPDATE TalerIncomingPayments SET reservePublicKey='$NEW_WTID' WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3
|
||||
|
||||
run_audit
|
||||
|
||||
@ -731,19 +800,18 @@ fi
|
||||
echo PASS
|
||||
|
||||
# Undo database modification
|
||||
echo "UPDATE app_banktransaction SET subject='$OLD_WTID' WHERE id='$OLD_ID';" | psql -Aqt $DB
|
||||
echo "UPDATE TalerIncomingPayments SET reservePublicKey='$OLD_WTID' WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Test wire origin disagreement!
|
||||
function test_9() {
|
||||
|
||||
echo "===========9: wire-origin disagreement==========="
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE amount='TESTKUDOS:10' ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_ACC=`echo "SELECT debit_account_id FROM app_banktransaction WHERE id='$OLD_ID';" | psql $DB -Aqt`
|
||||
echo "UPDATE app_banktransaction SET debit_account_id=1 WHERE id='$OLD_ID';" | psql -Aqt $DB
|
||||
OLD_ID=`echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | sqlite3 $DB.sqlite3`
|
||||
OLD_ACC=`echo "SELECT incomingPaytoUri FROM TalerIncomingPayments WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3`
|
||||
echo "UPDATE TalerIncomingPayments SET incomingPaytoUri='payto://iban/SANDBOXX/DE144373?receiver-name=New+Exchange+Company' WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3
|
||||
|
||||
run_audit
|
||||
|
||||
@ -761,18 +829,18 @@ fi
|
||||
echo PASS
|
||||
|
||||
# Undo database modification
|
||||
echo "UPDATE app_banktransaction SET debit_account_id=$OLD_ACC WHERE id='$OLD_ID';" | psql -Aqt $DB
|
||||
echo "UPDATE TalerIncomingPayments SET incomingPaytoUri='$OLD_ACC' WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Test wire_in timestamp disagreement!
|
||||
function test_10() {
|
||||
|
||||
NOW_MS=`date +%s`000
|
||||
echo "===========10: wire-timestamp disagreement==========="
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE amount='TESTKUDOS:10' ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='$OLD_ID';" | psql $DB -Aqt`
|
||||
echo "UPDATE app_banktransaction SET date=NOW() WHERE id=$OLD_ID;" | psql -Aqt $DB
|
||||
OLD_ID=`echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | sqlite3 $DB.sqlite3`
|
||||
OLD_DATE=`echo "SELECT timestampMs FROM TalerIncomingPayments WHERE payment='$OLD_ID';" | sqlite3 $DB.sqlite3`
|
||||
echo "UPDATE TalerIncomingPayments SET timestampMs=$NOW_MS WHERE payment=$OLD_ID;" | sqlite3 $DB.sqlite3
|
||||
|
||||
run_audit
|
||||
|
||||
@ -790,24 +858,35 @@ fi
|
||||
echo PASS
|
||||
|
||||
# Undo database modification
|
||||
echo "UPDATE app_banktransaction SET date='$OLD_DATE' WHERE id=$OLD_ID;" | psql -Aqt $DB
|
||||
echo "UPDATE TalerIncomingPayments SET timestampMs='$OLD_DATE' WHERE payment=$OLD_ID;" | sqlite3 $DB.sqlite3
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Test for extra outgoing wire transfer.
|
||||
# In case of changing the subject in the Nexus
|
||||
# ingested table: '.batches[0].batchTransactions[0].details.unstructuredRemittanceInformation'
|
||||
function test_11() {
|
||||
|
||||
echo "===========11: spurious outgoing transfer ==========="
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE amount='TESTKUDOS:10' ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_ACC=`echo "SELECT debit_account_id FROM app_banktransaction WHERE id=$OLD_ID;" | psql $DB -Aqt`
|
||||
OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE id=$OLD_ID;" | psql $DB -Aqt`
|
||||
OLD_ID=`echo "SELECT id FROM NexusBankTransactions WHERE amount='10' AND currency='TESTKUDOS' ORDER BY id LIMIT 1;" | sqlite3 $DB.sqlite3`
|
||||
OLD_TX=`echo "SELECT transactionJson FROM NexusBankTransactions WHERE id='$OLD_ID';" | sqlite3 $DB.sqlite3`
|
||||
# Change wire transfer to be FROM the exchange (#2) to elsewhere!
|
||||
# (Note: this change also causes a missing incoming wire transfer, but
|
||||
# this test is only concerned about the outgoing wire transfer
|
||||
# being detected as such, and we simply ignore the other
|
||||
# errors being reported.)
|
||||
echo -e "UPDATE app_banktransaction SET debit_account_id=2,credit_account_id=1,subject='CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG http://exchange.example.com/' WHERE id=$OLD_ID;" | psql -Aqt $DB
|
||||
OTHER_IBAN=`echo -e "SELECT iban FROM BankAccounts WHERE label='fortytwo'" | sqlite3 $DB.sqlite3`
|
||||
NEW_TX=$(echo "$OLD_TX" | jq .batches[0].batchTransactions[0].details.creditDebitIndicator='"DBIT"' | jq 'del(.batches[0].batchTransactions[0].details.debtor)' | jq 'del(.batches[0].batchTransactions[0].details.debtorAccount)' | jq 'del(.batches[0].batchTransactions[0].details.debtorAgent)' | jq '.batches[0].batchTransactions[0].details.creditor'='{"name": "Forty Two"}' | jq .batches[0].batchTransactions[0].details.creditorAccount='{"iban": "'$OTHER_IBAN'"}' | jq .batches[0].batchTransactions[0].details.creditorAgent='{"bic": "SANDBOXX"}' | jq .batches[0].batchTransactions[0].details.unstructuredRemittanceInformation='"CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG http://exchange.example.com/"')
|
||||
echo -e "UPDATE NexusBankTransactions SET transactionJson='"$NEW_TX"' WHERE id=$OLD_ID" | sqlite3 $DB.sqlite3
|
||||
# Now fake that the exchange prepared this payment (= it POSTed to /transfer)
|
||||
# This step is necessary, because the TWG table that accounts for outgoing
|
||||
# payments needs it. Worth noting here is the column 'rawConfirmation' that
|
||||
# points to the transaction from the main Nexus ledger; without that column set,
|
||||
# a prepared payment won't appear as actually outgoing.
|
||||
echo -e "INSERT INTO PaymentInitiations (bankAccount,preparationDate,submissionDate,sum,currency,endToEndId,paymentInformationId,instructionId,subject,creditorIban,creditorBic,creditorName,submitted,messageId,rawConfirmation) VALUES (1,1,1,10,'TESTKUDOS','NOTGIVEN','unused','unused','CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG http://exchange.example.com/','"$OTHER_IBAN"','SANDBOXX','Forty Two','unused',1,$OLD_ID)" | sqlite3 $DB.sqlite3
|
||||
# Now populate the TWG table that accounts for outgoing payments, in
|
||||
# order to let /history/outgoing return one result.
|
||||
echo -e "INSERT INTO TalerRequestedPayments (facade,payment,requestUid,amount,exchangeBaseUrl,wtid,creditAccount) VALUES (1,1,'unused','TESTKUDOS:10','http://exchange.example.com/','CK9QBFY972KR32FVA1MW958JWACEB6XCMHHKVFMCH1A780Q12SVG','payto://iban/SANDBOXX/"$OTHER_IBAN"?receiver-name=Forty+Two')" | sqlite3 $DB.sqlite3
|
||||
|
||||
run_audit
|
||||
|
||||
@ -839,13 +918,14 @@ then
|
||||
fi
|
||||
echo PASS
|
||||
|
||||
# Undo database modification (exchange always has account #2)
|
||||
echo "UPDATE app_banktransaction SET debit_account_id=$OLD_ACC,credit_account_id=2,subject='$OLD_SUBJECT' WHERE id=$OLD_ID;" | psql -Aqt $DB
|
||||
|
||||
# Undo database modification
|
||||
echo -e "UPDATE NexusBankTransactions SET transactionJson='"$OLD_TX"' WHERE id=$OLD_ID;" | sqlite3 $DB.sqlite3
|
||||
# No other prepared payment should exist at this point,
|
||||
# so OK to remove the number 1.
|
||||
echo -e "DELETE FROM PaymentInitiations WHERE id=1" | sqlite3 $DB.sqlite3
|
||||
echo -e "DELETE FROM TalerRequestedPayments WHERE id=1" | sqlite3 $DB.sqlite3
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Test for hanging/pending refresh.
|
||||
function test_12() {
|
||||
|
||||
@ -999,13 +1079,11 @@ then
|
||||
pre_audit aggregator
|
||||
|
||||
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
||||
# (exchange account is #2, so the logic below should select the outgoing
|
||||
# (Only one payment out exist, so the logic below should select the outgoing
|
||||
# wire transfer):
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
||||
OLD_AMOUNT=`echo "SELECT amount FROM TalerRequestedPayments WHERE id='1';" | sqlite3 $DB.sqlite3`
|
||||
NEW_AMOUNT="TESTKUDOS:50"
|
||||
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||
|
||||
echo "UPDATE TalerRequestedPayments SET amount='${NEW_AMOUNT}' WHERE id='1';" | sqlite3 $DB.sqlite3
|
||||
audit_only
|
||||
|
||||
echo -n "Testing inconsistency detection... "
|
||||
@ -1034,8 +1112,7 @@ then
|
||||
|
||||
echo "Second modification: wire nothing"
|
||||
NEW_AMOUNT="TESTKUDOS:0"
|
||||
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||
|
||||
echo "UPDATE TalerRequestedPayments SET amount='${NEW_AMOUNT}' WHERE id='1';" | sqlite3 $DB.sqlite3
|
||||
audit_only
|
||||
|
||||
echo -n "Testing inconsistency detection... "
|
||||
@ -1078,7 +1155,6 @@ fi
|
||||
# Test where wire-out timestamp is wrong
|
||||
function test_17() {
|
||||
echo "===========17: incorrect wire_out timestamp================="
|
||||
|
||||
# Check wire transfer lag reported (no aggregator!)
|
||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||
# re-generating the test database as we do not
|
||||
@ -1092,14 +1168,15 @@ then
|
||||
pre_audit aggregator
|
||||
|
||||
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
||||
# (exchange account is #2, so the logic below should select the outgoing
|
||||
# (exchange payed only once, so the logic below should select the outgoing
|
||||
# wire transfer):
|
||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||
OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
||||
OLD_ID=1
|
||||
OLD_PREP=`echo "SELECT payment FROM TalerRequestedPayments WHERE id='${OLD_ID}';" | sqlite3 $DB.sqlite3`
|
||||
OLD_DATE=`echo "SELECT preparationDate FROM PaymentInitiations WHERE id='${OLD_ID}';" | sqlite3 $DB.sqlite3`
|
||||
# Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB
|
||||
# (due to rounding, if this machine is fast...)
|
||||
echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||
|
||||
NOW_1HR=$(expr $(date +%s) - 3600)
|
||||
echo "UPDATE PaymentInitiations SET preparationDate='$NOW_1HR' WHERE id='${OLD_PREP}';" | sqlite3 $DB.sqlite3
|
||||
audit_only
|
||||
post_audit
|
||||
|
||||
@ -1272,8 +1349,8 @@ then
|
||||
pre_audit aggregator
|
||||
|
||||
# remove transaction from bank DB
|
||||
echo "DELETE FROM app_banktransaction WHERE debit_account_id=2 AND amount='TESTKUDOS:${VAL_DELTA}';" | psql -Aqt $DB
|
||||
|
||||
# Currently emulating this (to be deleted):
|
||||
echo "DELETE FROM TalerRequestedPayments WHERE amount='TESTKUDOS:${VAL_DELTA}'" | sqlite3 $DB.sqlite3
|
||||
audit_only
|
||||
post_audit
|
||||
|
||||
@ -1559,12 +1636,13 @@ then
|
||||
pre_audit aggregator
|
||||
|
||||
# Obtain data to duplicate.
|
||||
ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 LIMIT 1" | psql $DB -Aqt`
|
||||
WTID=`echo "SELECT subject FROM app_banktransaction WHERE debit_account_id=2 LIMIT 1" | psql $DB -Aqt`
|
||||
WTID=`echo SELECT wtid FROM TalerRequestedPayments WHERE id=1 | sqlite3 $DB.sqlite3`
|
||||
echo WTID=$WTID
|
||||
UUID="992e8936-a64d-4845-87d7-021440330f8a"
|
||||
echo "INSERT INTO app_banktransaction (amount,subject,date,credit_account_id,debit_account_id,cancelled,request_uid) VALUES ('TESTKUDOS:1','$WTID',NOW(),12,2,'f','$UUID')" | psql -Aqt $DB
|
||||
|
||||
OTHER_IBAN=`echo -e "SELECT iban FROM BankAccounts WHERE label='fortytwo'" | sqlite3 $DB.sqlite3`
|
||||
# 'rawConfirmation' is set to 2 here, that doesn't
|
||||
# point to any record. That's only needed to set a non null value.
|
||||
echo -e "INSERT INTO PaymentInitiations (bankAccount,preparationDate,submissionDate,sum,currency,endToEndId,paymentInformationId,instructionId,subject,creditorIban,creditorBic,creditorName,submitted,messageId,rawConfirmation) VALUES (1,$(date +%s),$(expr $(date +%s) + 2),10,'TESTKUDOS','NOTGIVEN','unused','unused','$WTID http://exchange.example.com/','$OTHER_IBAN','SANDBOXX','Forty Two','unused',1,2)" | sqlite3 $DB.sqlite3
|
||||
echo -e "INSERT INTO TalerRequestedPayments (facade,payment,requestUid,amount,exchangeBaseUrl,wtid,creditAccount) VALUES (1,2,'unused','TESTKUDOS:1','http://exchange.example.com/','$WTID','payto://iban/SANDBOXX/$OTHER_IBAN?receiver-name=Forty+Two')" | sqlite3 $DB.sqlite3
|
||||
audit_only
|
||||
post_audit
|
||||
|
||||
@ -2003,8 +2081,9 @@ CONF=${DB}.conf
|
||||
# test required commands exist
|
||||
echo "Testing for jq"
|
||||
jq -h > /dev/null || exit_skip "jq required"
|
||||
echo "Testing for taler-bank-manage"
|
||||
taler-bank-manage --help >/dev/null </dev/null || exit_skip "taler-bank-manage required"
|
||||
# NOTE: really check for all three libeufin commands?
|
||||
echo "Testing for libeufin"
|
||||
libeufin-cli --help >/dev/null </dev/null || exit_skip "libeufin required"
|
||||
echo "Testing for pdflatex"
|
||||
which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
|
||||
|
||||
|
@ -47,17 +47,89 @@ function cleanup()
|
||||
kill $n 2> /dev/null || true
|
||||
done
|
||||
wait
|
||||
# kill euFin
|
||||
echo Killing euFin..
|
||||
kill `cat libeufin-sandbox.pid 2> /dev/null` &> /dev/null || true
|
||||
kill `cat libeufin-nexus.pid 2> /dev/null` &> /dev/null || true
|
||||
# So far only Sandbox gave exit issues / delays ..
|
||||
count=0
|
||||
while ps xo pid | grep `cat libeufin-sandbox.pid`; do
|
||||
if test $count = 5; then
|
||||
echo "Sandbox unkillable, failing now .."
|
||||
exit 1
|
||||
fi
|
||||
echo "Sandbox didn't exit yet.."
|
||||
sleep 1;
|
||||
count=`expr $count + 1`
|
||||
done
|
||||
}
|
||||
|
||||
# Install cleanup handler (except for kill -9)
|
||||
trap cleanup EXIT
|
||||
|
||||
# Downloads new transactions from the bank.
|
||||
function nexus_fetch_transactions () {
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:8082/
|
||||
libeufin-cli accounts fetch-transactions \
|
||||
--range-type since-last --level report exchange-nexus > /dev/null
|
||||
unset LIBEUFIN_NEXUS_USERNAME
|
||||
unset LIBEUFIN_NEXUS_PASSWORD
|
||||
unset LIBEUFIN_NEXUS_URL
|
||||
}
|
||||
|
||||
# Instruct Nexus to all the prepared payments (= those
|
||||
# POSTed to /transfer by the exchange).
|
||||
function nexus_submit_to_sandbox () {
|
||||
export LIBEUFIN_NEXUS_USERNAME=exchange
|
||||
export LIBEUFIN_NEXUS_PASSWORD=x
|
||||
export LIBEUFIN_NEXUS_URL=http://localhost:8082/
|
||||
libeufin-cli accounts submit-payments exchange-nexus
|
||||
unset LIBEUFIN_NEXUS_USERNAME
|
||||
unset LIBEUFIN_NEXUS_PASSWORD
|
||||
unset LIBEUFIN_NEXUS_URL
|
||||
}
|
||||
|
||||
function get_payto_uri() {
|
||||
export LIBEUFIN_SANDBOX_USERNAME=$1
|
||||
export LIBEUFIN_SANDBOX_PASSWORD=$2
|
||||
export LIBEUFIN_SANDBOX_URL=http://localhost:18082/demobanks/default
|
||||
libeufin-cli sandbox demobank info --bank-account $1 | jq --raw-output '.paytoUri'
|
||||
}
|
||||
|
||||
function launch_libeufin () {
|
||||
export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3"
|
||||
libeufin-nexus serve --port 8082 \
|
||||
2> libeufin-nexus-stderr.log \
|
||||
> libeufin-nexus-stdout.log &
|
||||
echo $! > libeufin-nexus.pid
|
||||
export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$DB.sqlite3"
|
||||
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=secret
|
||||
libeufin-sandbox serve --port 18082 \
|
||||
> libeufin-sandbox-stdout.log \
|
||||
2> libeufin-sandbox-stderr.log &
|
||||
echo $! > libeufin-sandbox.pid
|
||||
}
|
||||
|
||||
# Operations to run before the actual audit
|
||||
function pre_audit () {
|
||||
# Launch bank
|
||||
echo -n "Launching bank "
|
||||
taler-bank-manage-testing $CONF postgres:///$DB serve 2>bank.err >bank.log &
|
||||
EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
|
||||
launch_libeufin
|
||||
for n in `seq 1 80`
|
||||
do
|
||||
echo -n "."
|
||||
sleep 0.1
|
||||
OK=1
|
||||
wget http://localhost:18082/ -o /dev/null -O /dev/null >/dev/null && break
|
||||
OK=0
|
||||
done
|
||||
if [ 1 != $OK ]
|
||||
then
|
||||
exit_skip "Failed to launch Sandbox"
|
||||
fi
|
||||
for n in `seq 1 80`
|
||||
do
|
||||
echo -n "."
|
||||
@ -68,14 +140,13 @@ function pre_audit () {
|
||||
done
|
||||
if [ 1 != $OK ]
|
||||
then
|
||||
exit_skip "Failed to launch bank"
|
||||
exit_skip "Failed to launch Nexus"
|
||||
fi
|
||||
echo " DONE"
|
||||
|
||||
if test ${1:-no} = "aggregator"
|
||||
then
|
||||
export CONF
|
||||
echo -n "Running exchange aggregator ..."
|
||||
echo -n "Running exchange aggregator ... (config: $CONF)"
|
||||
taler-exchange-aggregator -L INFO -t -c $CONF -y 2> aggregator.log || exit_fail "FAIL"
|
||||
echo " DONE"
|
||||
echo -n "Running exchange closer ..."
|
||||
@ -84,13 +155,20 @@ function pre_audit () {
|
||||
echo -n "Running exchange transfer ..."
|
||||
taler-exchange-transfer -L INFO -t -c $CONF 2> transfer.log || exit_fail "FAIL"
|
||||
echo " DONE"
|
||||
echo -n "Running Nexus payment submitter ..."
|
||||
nexus_submit_to_sandbox
|
||||
echo " DONE"
|
||||
# Make outgoing transactions appear in the TWG:
|
||||
echo -n "Download bank transactions ..."
|
||||
nexus_fetch_transactions
|
||||
echo " DONE"
|
||||
fi
|
||||
}
|
||||
|
||||
# actual audit run
|
||||
function audit_only () {
|
||||
# Run the auditor!
|
||||
echo -n "Running audit(s) ..."
|
||||
echo -n "Running audit(s) ... (conf is $CONF)"
|
||||
|
||||
# Restart so that first run is always fresh, and second one is incremental
|
||||
taler-auditor-dbinit -r -c $CONF
|
||||
@ -152,10 +230,22 @@ full_reload()
|
||||
{
|
||||
echo -n "Doing full reload of the database... "
|
||||
dropdb $DB 2> /dev/null || true
|
||||
rm -f $DB.sqlite3 || true # libeufin
|
||||
createdb -T template0 $DB || exit_skip "could not create database"
|
||||
# Import pre-generated database, -q(ietly) using single (-1) transaction
|
||||
psql -Aqt $DB -q -1 -f ${BASEDB}.sql > /dev/null || exit_skip "Failed to load database"
|
||||
sqlite3 $DB.sqlite3 < ${BASEDB}-libeufin.sql || exit_skip "Failed to load libEufin database"
|
||||
echo "DONE"
|
||||
# Exchange payto URI contains the (dynamically generated)
|
||||
# IBAN, that can only be written in CONF after libeufin is
|
||||
# setup.
|
||||
taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI &> /dev/null || (
|
||||
echo -n "Specifying exchange payto URI in the configuration ($CONF) (grab IBAN from $DB.sqlite3)...";
|
||||
EXCHANGE_IBAN=`echo "SELECT iban FROM BankAccounts WHERE label='exchange'" | sqlite3 $DB.sqlite3`;
|
||||
taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI \
|
||||
-V "payto://iban/SANDBOXX/$EXCHANGE_IBAN?receiver-name=Exchange+Company"
|
||||
echo " DONE"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -462,7 +552,6 @@ check_with_database()
|
||||
|
||||
# Load database
|
||||
full_reload
|
||||
|
||||
# Run test suite
|
||||
fail=0
|
||||
for i in $TESTS
|
||||
@ -492,8 +581,8 @@ CONF=revoke-basedb.conf
|
||||
# test required commands exist
|
||||
echo "Testing for jq"
|
||||
jq -h > /dev/null || exit_skip "jq required"
|
||||
echo "Testing for taler-bank-manage"
|
||||
taler-bank-manage --help >/dev/null </dev/null || exit_skip "taler-bank-manage required"
|
||||
echo "Testing for libeufin(-cli)"
|
||||
libeufin-cli --help >/dev/null </dev/null || exit_skip "libeufin required"
|
||||
echo "Testing for pdflatex"
|
||||
which pdflatex > /dev/null </dev/null || exit_skip "pdflatex required"
|
||||
|
||||
|
@ -37,6 +37,13 @@
|
||||
#define CONFIG_FILE_PYBANK "test_bank_api_pybank.conf"
|
||||
#define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf"
|
||||
|
||||
|
||||
/**
|
||||
* Configuration file. It changes based on
|
||||
* whether Nexus or Fakebank are used.
|
||||
*/
|
||||
const char *cfgfile;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
@ -88,14 +95,24 @@ run (void *cls,
|
||||
"KUDOS:5.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
/**
|
||||
* This CMD doesn't care about the HTTP response code; that's
|
||||
* because Fakebank and euFin behaves differently when a reserve
|
||||
* pub is duplicate. Fakebank responds with 409, whereas euFin
|
||||
* with 200 but it bounces the payment back to the customer.
|
||||
*/
|
||||
TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail",
|
||||
"KUDOS:2.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto,
|
||||
"credit-1",
|
||||
MHD_HTTP_CONFLICT),
|
||||
-1),
|
||||
TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle",
|
||||
4),
|
||||
/**
|
||||
* Check that the incoming payment with a duplicate
|
||||
* reserve public key didn't make it to the exchange.
|
||||
*/
|
||||
TALER_TESTING_cmd_bank_credits ("history-1c",
|
||||
&bc.exchange_auth,
|
||||
NULL,
|
||||
@ -164,7 +181,6 @@ main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
int rv;
|
||||
const char *cfgfile;
|
||||
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
@ -1,22 +1,20 @@
|
||||
# This file is in the public domain.
|
||||
|
||||
[taler]
|
||||
currency = KUDOS
|
||||
currency = TESTKUDOS
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler/
|
||||
WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
# the exchange authenticates as the 'admin' user,
|
||||
# since that makes the test preparation just easier.
|
||||
USERNAME = Exchange
|
||||
USERNAME = exchange
|
||||
PASSWORD = x
|
||||
|
||||
[bank]
|
||||
# not (!) used by the nexus, only by the helper
|
||||
# check to make sure the port is free for the nexus.
|
||||
# check to make sure the port is free for Nexus.
|
||||
HTTP_PORT = 5001
|
||||
|
||||
[auditor]
|
||||
|
@ -217,6 +217,26 @@ confirmation_cb (void *cls,
|
||||
fts->reserve_history.details.in_details.timestamp = timestamp;
|
||||
fts->reserve_history.details.in_details.wire_reference = serial_id;
|
||||
fts->aih = NULL;
|
||||
/**
|
||||
* Test case not caring about the HTTP status code.
|
||||
* That helps when Fakebank and Libeufin diverge in
|
||||
* the response status code. An example is the
|
||||
* /admin/add-incoming: libeufin return ALWAYS '200 OK'
|
||||
* (see note below) whereas the Fakebank responds with
|
||||
* '409 Conflict' upon a duplicate reserve public key.
|
||||
*
|
||||
* Note: this decision aims at avoiding to put Taler
|
||||
* logic into the Sandbox; that's because banks DO allow
|
||||
* their customers to wire the same subject multiple
|
||||
* times. Hence, instead of triggering any error, libeufin
|
||||
* bounces the payment back in the same way it does for
|
||||
* malformed reserve public keys.
|
||||
*/
|
||||
if (-1 == fts->expected_http_status)
|
||||
{
|
||||
TALER_TESTING_interpreter_next (is);
|
||||
return;
|
||||
}
|
||||
if (http_status != fts->expected_http_status)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
|
@ -168,9 +168,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
|
||||
/* @var turns GNUNET_YES whenever either no 'start' value was
|
||||
* given for the history query, or the given value is found
|
||||
* in the list of all the CMDs. *///
|
||||
int ok;
|
||||
const uint64_t *row_id_start = NULL;
|
||||
|
||||
@ -208,7 +205,11 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
start = is->ip - 1;
|
||||
end = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ok equals GNUNET_YES whenever a starting row_id
|
||||
* was provided AND was found among the CMDs, OR no
|
||||
* starting row was given in the first place.
|
||||
*/
|
||||
ok = GNUNET_NO;
|
||||
if (NULL == row_id_start)
|
||||
ok = GNUNET_YES;
|
||||
@ -228,9 +229,11 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
const char **exchange_credit_url;
|
||||
|
||||
/* The following command allows us to skip over those CMDs
|
||||
/**
|
||||
* The following command allows us to skip over those CMDs
|
||||
* that do not offer a "row_id" trait. Such skipped CMDs are
|
||||
* not interesting for building a history. *///
|
||||
* not interesting for building a history.
|
||||
*/
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_bank_row (cmd,
|
||||
&row_id)) ||
|
||||
@ -250,22 +253,29 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
TALER_TESTING_get_trait_exchange_bank_account_url (
|
||||
cmd,
|
||||
&exchange_credit_url)) )
|
||||
continue; /* not an interesting event */
|
||||
/* Seek "/history/incoming" starting row. */
|
||||
continue; // Not an interesting event
|
||||
/**
|
||||
* Is the interesting event a match with regard to
|
||||
* the row_id value? If yes, store this condition
|
||||
* to the state and analyze the next CMDs.
|
||||
*/
|
||||
if ( (NULL != row_id_start) &&
|
||||
(*row_id_start == *row_id) &&
|
||||
(GNUNET_NO == ok) )
|
||||
{
|
||||
/* Until here, nothing counted. */
|
||||
ok = GNUNET_YES;
|
||||
continue;
|
||||
}
|
||||
/* when 'start' was _not_ given, then ok == GNUNET_YES */
|
||||
/**
|
||||
* The interesting event didn't match the wanted
|
||||
* row_id value, analyze the next CMDs. Note: this
|
||||
* branch is relevant only when row_id WAS given.
|
||||
*/
|
||||
if (GNUNET_NO == ok)
|
||||
continue; /* skip until we find the marker */
|
||||
continue;
|
||||
if (0 != strcasecmp (hs->account_url,
|
||||
*exchange_credit_url))
|
||||
continue; /* account mismatch */
|
||||
continue; // Account mismatch
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
|
@ -92,6 +92,12 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
|
||||
struct TALER_TESTING_LibeufinServices ret = { 0 };
|
||||
unsigned int iter;
|
||||
char *curl_check_cmd;
|
||||
const char *db_conn = "jdbc:sqlite:/tmp/libeufin-exchange-test.sqlite3";
|
||||
|
||||
setenv (
|
||||
"LIBEUFIN_NEXUS_DB_CONNECTION",
|
||||
db_conn,
|
||||
1); // not overwriting any potentially existing DB.
|
||||
|
||||
nexus_proc = GNUNET_OS_start_process (
|
||||
GNUNET_OS_INHERIT_STD_ERR,
|
||||
@ -99,7 +105,6 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
|
||||
"libeufin-nexus",
|
||||
"libeufin-nexus",
|
||||
"serve",
|
||||
"--db-name", "/tmp/nexus-exchange-test.sqlite3",
|
||||
NULL);
|
||||
if (NULL == nexus_proc)
|
||||
{
|
||||
@ -139,14 +144,26 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
|
||||
// start sandbox.
|
||||
GNUNET_free (curl_check_cmd);
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
setenv (
|
||||
"LIBEUFIN_SANDBOX_DB_CONNECTION",
|
||||
db_conn,
|
||||
1); // not overwriting existing 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",
|
||||
"--db-name", "/tmp/sandbox-exchange-test.sqlite3",
|
||||
NULL);
|
||||
if (NULL == sandbox_proc)
|
||||
{
|
||||
@ -350,8 +367,7 @@ TALER_TESTING_prepare_nexus (const char *config_filename,
|
||||
/* DB preparation */
|
||||
if (GNUNET_YES == reset_db)
|
||||
{
|
||||
if (0 != system (
|
||||
"rm -f /tmp/nexus-exchange-test.sqlite3 && rm -f /tmp/sandbox-exchange-test.sqlite3"))
|
||||
if (0 != system ("rm -f /tmp/libeufin-exchange-test.sqlite3"))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to invoke db-removal command.\n");
|
||||
@ -384,9 +400,9 @@ TALER_TESTING_prepare_nexus (const char *config_filename,
|
||||
GNUNET_CONFIGURATION_destroy (cfg);
|
||||
bc->exchange_payto = exchange_payto_uri;
|
||||
bc->user42_payto =
|
||||
"payto://iban/BIC/FR7630006000011234567890189?receiver-name=User42";
|
||||
"payto://iban/SANDBOXX/FR7630006000011234567890189?receiver-name=User42";
|
||||
bc->user43_payto =
|
||||
"payto://iban/BIC/GB33BUKB20201555555555?receiver-name=User43";
|
||||
"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,
|
||||
|
Loading…
Reference in New Issue
Block a user