summaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rwxr-xr-xsrc/cli/test_iban.sh129
1 files changed, 114 insertions, 15 deletions
diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh
index e364280..54d8b06 100755
--- a/src/cli/test_iban.sh
+++ b/src/cli/test_iban.sh
@@ -17,6 +17,9 @@ function exit_fail() {
# Cleanup to run whenever we exit
function cleanup()
{
+ if test $? != 0; then
+ echo "ERROR: see also nexus.log and sandbox.log"
+ fi
for n in `jobs -p`
do
kill $n 2> /dev/null || true
@@ -33,7 +36,7 @@ function prepare_sandbox_account() {
libeufin-cli \
sandbox --sandbox-url=$SANDBOX_URL \
ebicssubscriber create \
- --host-id=ebicstesthost \
+ --host-id=$EBICS_HOST \
--partner-id=$2 \
--user-id=$1
echo " OK"
@@ -46,12 +49,55 @@ function prepare_sandbox_account() {
--person-name=$3 \
--account-name=$4 \
--ebics-user-id=$1 \
- --ebics-host-id=ebicstesthost \
+ --ebics-host-id=$EBICS_HOST \
--ebics-partner-id=$2 \
--currency=$CURRENCY
echo " OK"
}
+
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
+
+# $1 = ebics user id, $2 = ebics partner, $3 = bank connection name
+# $4 = bank account name local to Nexus, $5 = bank account name as known
+# by Sandbox
+function prepare_nexus_account() {
+ echo -n Making bank connection $3
+ libeufin-cli connections new-ebics-connection \
+ --ebics-url="${SANDBOX_URL}ebicsweb" \
+ --host-id=$EBICS_HOST \
+ --partner-id=$2 \
+ --ebics-user-id=$1 \
+ $3 > /dev/null
+ echo " OK"
+ sleep 1
+ echo -n Connecting $3 ..
+ libeufin-cli connections connect $3 > /dev/null
+ echo " OK"
+ sleep 1
+ echo -n "Importing Sandbox bank account ($5) to Nexus ($4) ..."
+ libeufin-cli connections download-bank-accounts $3 > /dev/null
+ sleep 1
+ libeufin-cli connections import-bank-account \
+ --offered-account-id=$5 --nexus-bank-account-id=$4 $3 > /dev/null
+ echo " OK"
+}
+
+# $1 = facade name, $2 = bank connection to use, $3 = bank account name
+# local to Nexus
+function prepare_anastasis_facade() {
+ echo -n "Creating facade ..."
+ libeufin-cli facades new-anastasis-facade \
+ --currency=$CURRENCY \
+ --facade-name=$1 \
+ $2 $3
+ echo " OK"
+ sleep 1
+ # No need to setup facade permissions, as the anastasis client
+ # is superuser at Nexus.
+}
+
# Configuration file will be edited, so we create one
# from the template.
CONF=`mktemp test_free_reducerXXXXXX.conf`
@@ -69,8 +115,6 @@ export R2FILE
export R1FILE
-# Install cleanup handler (except for kill -9)
-trap cleanup EXIT
# Script's guidelines:
@@ -83,7 +127,6 @@ trap cleanup EXIT
# installed/available
#* starts Nexus (in background)
#* starts sandbox (in background)
-# ~~~~~~~~~
#* creates two IBAN accounts
#* stores IBANs of both accounts in shell variables,
# call them IBAN_CREDIT and IBAN_DEBIT.
@@ -91,6 +134,7 @@ trap cleanup EXIT
#* exports authentication credentials (URL, access token)
# for the facade to shell variables
# (FACADE_URL, FACADE_AUTH_TOKEN)
+# ~~~~~~~~~
#* contains a command to do a wire-transfer (pick your amount)
# from DEBIT to CREDIT (setup authentication as needed to
# trigger the transfer)
@@ -148,23 +192,80 @@ fi
echo " OK"
CURRENCY="TESTKUDOS"
-IBAN1="AA3314655813489414469157"
-IBAN2="BB3314655813489414469157"
-export IBAN1
-export IBAN2
+EBICS_HOST="ebicstesthost"
+IBAN_CREDIT="AA3314655813489414469157"
+IBAN_DEBIT="BB3314655813489414469157"
+export IBAN_CREDIT
+export IBAN_DEBIT
+
+echo Preparing Sandbox ...
echo -n "Making an ebics host at the sandbox "
libeufin-cli \
sandbox --sandbox-url=$SANDBOX_URL \
ebicshost create \
- --host-id=ebicstesthost
+ --host-id=$EBICS_HOST
echo " OK"
+# note: Ebisc schema doesn't allow dashed names.
prepare_sandbox_account \
- ebicsuser01 ebicspartner01 Person01 sandbox-account-01 $IBAN1
+ ebicsuserCredit \
+ ebicspartnerCredit \
+ Person01 \
+ sandbox-account-credit \
+ $IBAN_CREDIT
prepare_sandbox_account \
- ebicsuser02 ebicspartner02 Person02 sandbox-account-02 $IBAN2
+ ebicsuserDebit \
+ ebicspartnerDebit \
+ Person02 \
+ sandbox-account-debit \
+ $IBAN_DEBIT
+echo Sandbox preparation done
+echo Preparing Nexus ...
+export LIBEUFIN_NEXUS_URL=$NEXUS_URL
+# Make debit user, will buy Anastasis services.
+DEBIT_USERNAME=anastasis-debit-user
+DEBIT_PASSWORD=anastasis-debit-password
+echo -n create debit user at Nexus ...
+libeufin-nexus superuser $DEBIT_USERNAME --password=$DEBIT_PASSWORD
+echo " OK"
+export LIBEUFIN_NEXUS_USERNAME=$DEBIT_USERNAME
+export LIBEUFIN_NEXUS_PASSWORD=$DEBIT_PASSWORD
+
+prepare_nexus_account \
+ ebicsuserDebit \
+ ebicspartnerDebit \
+ bankconnection-debit \
+ nexus-bankaccount-debit \
+ sandbox-account-debit
+
+# Make credit user, will be Anastasis client.
+CREDIT_USERNAME=anastasis-credit-user
+CREDIT_PASSWORD=anastasis-credit-password
+echo -n "create credit user (for anastasis) at Nexus ..."
+libeufin-nexus superuser $CREDIT_USERNAME --password=$CREDIT_PASSWORD
+echo " OK"
+export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
+export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
+
+prepare_nexus_account \
+ ebicsuserCredit \
+ ebicspartnerCredit \
+ bankconnection-credit \
+ nexus-bankaccount-credit \
+ sandbox-account-credit
+
+echo -n create facade ...
+libeufin-cli facades new-anastasis-facade \
+ --currency=$CURRENCY \
+ --facade-name=facade-credit \
+ bankconnection-credit nexus-bankaccount-credit
+echo " OK"
+sleep 1
+FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \")
+## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD
+echo Nexus preparation done.
echo -n "Initialize Anastasis database ..."
# Name of the Postgres database we will use for the script.
@@ -184,12 +285,10 @@ anastasis-config -c $CONF \
-s authorization-iban \
-o CREDIT_IBAN \
-V ${IBAN1}
-# FIXME-MS: We need the *facade* URL and (likely) the
-# Facade authentication data here, not the NEXUS_URL!
anastasis-config -c $CONF \
-s authorization-iban \
-o WIRE_GATEWAY_URL \
- -V ${NEXUS_URL}
+ -V ${FACADE_URL}
anastasis-config -c $CONF \
-s authorization-iban \
-o WIRE_GATEWAY_AUTH_METHOD \