aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-08-22 05:20:06 -1100
committerMS <ms@taler.net>2021-08-22 05:52:41 -1100
commit7e4bfbf1c17a5faf04b94e7db04e5536617a4a92 (patch)
tree56256626e9e57a6c682256249272dd7eb66133cd
parentb160641b833ff2bb7b4a72d5b158a685d14cf825 (diff)
downloadanastasis-7e4bfbf1c17a5faf04b94e7db04e5536617a4a92.tar.gz
anastasis-7e4bfbf1c17a5faf04b94e7db04e5536617a4a92.zip
Anastasis/LibEuFin test.
Up to the point of extracting the facade URL (with conflict resolution)
-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() {
17# Cleanup to run whenever we exit 17# Cleanup to run whenever we exit
18function cleanup() 18function cleanup()
19{ 19{
20 if test $? != 0; then
21 echo "ERROR: see also nexus.log and sandbox.log"
22 fi
20 for n in `jobs -p` 23 for n in `jobs -p`
21 do 24 do
22 kill $n 2> /dev/null || true 25 kill $n 2> /dev/null || true
@@ -33,7 +36,7 @@ function prepare_sandbox_account() {
33 libeufin-cli \ 36 libeufin-cli \
34 sandbox --sandbox-url=$SANDBOX_URL \ 37 sandbox --sandbox-url=$SANDBOX_URL \
35 ebicssubscriber create \ 38 ebicssubscriber create \
36 --host-id=ebicstesthost \ 39 --host-id=$EBICS_HOST \
37 --partner-id=$2 \ 40 --partner-id=$2 \
38 --user-id=$1 41 --user-id=$1
39 echo " OK" 42 echo " OK"
@@ -46,12 +49,55 @@ function prepare_sandbox_account() {
46 --person-name=$3 \ 49 --person-name=$3 \
47 --account-name=$4 \ 50 --account-name=$4 \
48 --ebics-user-id=$1 \ 51 --ebics-user-id=$1 \
49 --ebics-host-id=ebicstesthost \ 52 --ebics-host-id=$EBICS_HOST \
50 --ebics-partner-id=$2 \ 53 --ebics-partner-id=$2 \
51 --currency=$CURRENCY 54 --currency=$CURRENCY
52 echo " OK" 55 echo " OK"
53} 56}
54 57
58
59# Install cleanup handler (except for kill -9)
60trap cleanup EXIT
61
62# $1 = ebics user id, $2 = ebics partner, $3 = bank connection name
63# $4 = bank account name local to Nexus, $5 = bank account name as known
64# by Sandbox
65function prepare_nexus_account() {
66 echo -n Making bank connection $3
67 libeufin-cli connections new-ebics-connection \
68 --ebics-url="${SANDBOX_URL}ebicsweb" \
69 --host-id=$EBICS_HOST \
70 --partner-id=$2 \
71 --ebics-user-id=$1 \
72 $3 > /dev/null
73 echo " OK"
74 sleep 1
75 echo -n Connecting $3 ..
76 libeufin-cli connections connect $3 > /dev/null
77 echo " OK"
78 sleep 1
79 echo -n "Importing Sandbox bank account ($5) to Nexus ($4) ..."
80 libeufin-cli connections download-bank-accounts $3 > /dev/null
81 sleep 1
82 libeufin-cli connections import-bank-account \
83 --offered-account-id=$5 --nexus-bank-account-id=$4 $3 > /dev/null
84 echo " OK"
85}
86
87# $1 = facade name, $2 = bank connection to use, $3 = bank account name
88# local to Nexus
89function prepare_anastasis_facade() {
90 echo -n "Creating facade ..."
91 libeufin-cli facades new-anastasis-facade \
92 --currency=$CURRENCY \
93 --facade-name=$1 \
94 $2 $3
95 echo " OK"
96 sleep 1
97 # No need to setup facade permissions, as the anastasis client
98 # is superuser at Nexus.
99}
100
55# Configuration file will be edited, so we create one 101# Configuration file will be edited, so we create one
56# from the template. 102# from the template.
57CONF=`mktemp test_free_reducerXXXXXX.conf` 103CONF=`mktemp test_free_reducerXXXXXX.conf`
@@ -69,8 +115,6 @@ export R2FILE
69export R1FILE 115export R1FILE
70 116
71 117
72# Install cleanup handler (except for kill -9)
73trap cleanup EXIT
74 118
75# Script's guidelines: 119# Script's guidelines:
76 120
@@ -83,7 +127,6 @@ trap cleanup EXIT
83# installed/available 127# installed/available
84#* starts Nexus (in background) 128#* starts Nexus (in background)
85#* starts sandbox (in background) 129#* starts sandbox (in background)
86# ~~~~~~~~~
87#* creates two IBAN accounts 130#* creates two IBAN accounts
88#* stores IBANs of both accounts in shell variables, 131#* stores IBANs of both accounts in shell variables,
89# call them IBAN_CREDIT and IBAN_DEBIT. 132# call them IBAN_CREDIT and IBAN_DEBIT.
@@ -91,6 +134,7 @@ trap cleanup EXIT
91#* exports authentication credentials (URL, access token) 134#* exports authentication credentials (URL, access token)
92# for the facade to shell variables 135# for the facade to shell variables
93# (FACADE_URL, FACADE_AUTH_TOKEN) 136# (FACADE_URL, FACADE_AUTH_TOKEN)
137# ~~~~~~~~~
94#* contains a command to do a wire-transfer (pick your amount) 138#* contains a command to do a wire-transfer (pick your amount)
95# from DEBIT to CREDIT (setup authentication as needed to 139# from DEBIT to CREDIT (setup authentication as needed to
96# trigger the transfer) 140# trigger the transfer)
@@ -148,23 +192,80 @@ fi
148echo " OK" 192echo " OK"
149 193
150CURRENCY="TESTKUDOS" 194CURRENCY="TESTKUDOS"
151IBAN1="AA3314655813489414469157"
152IBAN2="BB3314655813489414469157"
153export IBAN1
154export IBAN2
155 195
196EBICS_HOST="ebicstesthost"
197IBAN_CREDIT="AA3314655813489414469157"
198IBAN_DEBIT="BB3314655813489414469157"
199export IBAN_CREDIT
200export IBAN_DEBIT
201
202echo Preparing Sandbox ...
156echo -n "Making an ebics host at the sandbox " 203echo -n "Making an ebics host at the sandbox "
157libeufin-cli \ 204libeufin-cli \
158 sandbox --sandbox-url=$SANDBOX_URL \ 205 sandbox --sandbox-url=$SANDBOX_URL \
159 ebicshost create \ 206 ebicshost create \
160 --host-id=ebicstesthost 207 --host-id=$EBICS_HOST
161echo " OK" 208echo " OK"
162 209
210# note: Ebisc schema doesn't allow dashed names.
163prepare_sandbox_account \ 211prepare_sandbox_account \
164 ebicsuser01 ebicspartner01 Person01 sandbox-account-01 $IBAN1 212 ebicsuserCredit \
213 ebicspartnerCredit \
214 Person01 \
215 sandbox-account-credit \
216 $IBAN_CREDIT
165prepare_sandbox_account \ 217prepare_sandbox_account \
166 ebicsuser02 ebicspartner02 Person02 sandbox-account-02 $IBAN2 218 ebicsuserDebit \
219 ebicspartnerDebit \
220 Person02 \
221 sandbox-account-debit \
222 $IBAN_DEBIT
223echo Sandbox preparation done
224echo Preparing Nexus ...
225export LIBEUFIN_NEXUS_URL=$NEXUS_URL
226# Make debit user, will buy Anastasis services.
227DEBIT_USERNAME=anastasis-debit-user
228DEBIT_PASSWORD=anastasis-debit-password
229echo -n create debit user at Nexus ...
230libeufin-nexus superuser $DEBIT_USERNAME --password=$DEBIT_PASSWORD
231echo " OK"
232export LIBEUFIN_NEXUS_USERNAME=$DEBIT_USERNAME
233export LIBEUFIN_NEXUS_PASSWORD=$DEBIT_PASSWORD
234
235prepare_nexus_account \
236 ebicsuserDebit \
237 ebicspartnerDebit \
238 bankconnection-debit \
239 nexus-bankaccount-debit \
240 sandbox-account-debit
241
242# Make credit user, will be Anastasis client.
243CREDIT_USERNAME=anastasis-credit-user
244CREDIT_PASSWORD=anastasis-credit-password
245echo -n "create credit user (for anastasis) at Nexus ..."
246libeufin-nexus superuser $CREDIT_USERNAME --password=$CREDIT_PASSWORD
247echo " OK"
248export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
249export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
250
251prepare_nexus_account \
252 ebicsuserCredit \
253 ebicspartnerCredit \
254 bankconnection-credit \
255 nexus-bankaccount-credit \
256 sandbox-account-credit
257
258echo -n create facade ...
259libeufin-cli facades new-anastasis-facade \
260 --currency=$CURRENCY \
261 --facade-name=facade-credit \
262 bankconnection-credit nexus-bankaccount-credit
263echo " OK"
264sleep 1
265FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \")
167 266
267## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD
268echo Nexus preparation done.
168 269
169echo -n "Initialize Anastasis database ..." 270echo -n "Initialize Anastasis database ..."
170# Name of the Postgres database we will use for the script. 271# Name of the Postgres database we will use for the script.
@@ -184,12 +285,10 @@ anastasis-config -c $CONF \
184 -s authorization-iban \ 285 -s authorization-iban \
185 -o CREDIT_IBAN \ 286 -o CREDIT_IBAN \
186 -V ${IBAN1} 287 -V ${IBAN1}
187# FIXME-MS: We need the *facade* URL and (likely) the
188# Facade authentication data here, not the NEXUS_URL!
189anastasis-config -c $CONF \ 288anastasis-config -c $CONF \
190 -s authorization-iban \ 289 -s authorization-iban \
191 -o WIRE_GATEWAY_URL \ 290 -o WIRE_GATEWAY_URL \
192 -V ${NEXUS_URL} 291 -V ${FACADE_URL}
193anastasis-config -c $CONF \ 292anastasis-config -c $CONF \
194 -s authorization-iban \ 293 -s authorization-iban \
195 -o WIRE_GATEWAY_AUTH_METHOD \ 294 -o WIRE_GATEWAY_AUTH_METHOD \