diff options
author | MS <ms@taler.net> | 2021-08-22 05:20:06 -1100 |
---|---|---|
committer | MS <ms@taler.net> | 2021-08-22 05:52:41 -1100 |
commit | 7e4bfbf1c17a5faf04b94e7db04e5536617a4a92 (patch) | |
tree | 56256626e9e57a6c682256249272dd7eb66133cd | |
parent | b160641b833ff2bb7b4a72d5b158a685d14cf825 (diff) | |
download | anastasis-7e4bfbf1c17a5faf04b94e7db04e5536617a4a92.tar.gz anastasis-7e4bfbf1c17a5faf04b94e7db04e5536617a4a92.zip |
Anastasis/LibEuFin test.
Up to the point of extracting the facade URL (with conflict resolution)
-rwxr-xr-x | src/cli/test_iban.sh | 129 |
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 |
18 | function cleanup() | 18 | function 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) | ||
60 | trap 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 | ||
65 | function 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 | ||
89 | function 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. |
57 | CONF=`mktemp test_free_reducerXXXXXX.conf` | 103 | CONF=`mktemp test_free_reducerXXXXXX.conf` |
@@ -69,8 +115,6 @@ export R2FILE | |||
69 | export R1FILE | 115 | export R1FILE |
70 | 116 | ||
71 | 117 | ||
72 | # Install cleanup handler (except for kill -9) | ||
73 | trap 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 | |||
148 | echo " OK" | 192 | echo " OK" |
149 | 193 | ||
150 | CURRENCY="TESTKUDOS" | 194 | CURRENCY="TESTKUDOS" |
151 | IBAN1="AA3314655813489414469157" | ||
152 | IBAN2="BB3314655813489414469157" | ||
153 | export IBAN1 | ||
154 | export IBAN2 | ||
155 | 195 | ||
196 | EBICS_HOST="ebicstesthost" | ||
197 | IBAN_CREDIT="AA3314655813489414469157" | ||
198 | IBAN_DEBIT="BB3314655813489414469157" | ||
199 | export IBAN_CREDIT | ||
200 | export IBAN_DEBIT | ||
201 | |||
202 | echo Preparing Sandbox ... | ||
156 | echo -n "Making an ebics host at the sandbox " | 203 | echo -n "Making an ebics host at the sandbox " |
157 | libeufin-cli \ | 204 | libeufin-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 |
161 | echo " OK" | 208 | echo " OK" |
162 | 209 | ||
210 | # note: Ebisc schema doesn't allow dashed names. | ||
163 | prepare_sandbox_account \ | 211 | prepare_sandbox_account \ |
164 | ebicsuser01 ebicspartner01 Person01 sandbox-account-01 $IBAN1 | 212 | ebicsuserCredit \ |
213 | ebicspartnerCredit \ | ||
214 | Person01 \ | ||
215 | sandbox-account-credit \ | ||
216 | $IBAN_CREDIT | ||
165 | prepare_sandbox_account \ | 217 | prepare_sandbox_account \ |
166 | ebicsuser02 ebicspartner02 Person02 sandbox-account-02 $IBAN2 | 218 | ebicsuserDebit \ |
219 | ebicspartnerDebit \ | ||
220 | Person02 \ | ||
221 | sandbox-account-debit \ | ||
222 | $IBAN_DEBIT | ||
223 | echo Sandbox preparation done | ||
224 | echo Preparing Nexus ... | ||
225 | export LIBEUFIN_NEXUS_URL=$NEXUS_URL | ||
226 | # Make debit user, will buy Anastasis services. | ||
227 | DEBIT_USERNAME=anastasis-debit-user | ||
228 | DEBIT_PASSWORD=anastasis-debit-password | ||
229 | echo -n create debit user at Nexus ... | ||
230 | libeufin-nexus superuser $DEBIT_USERNAME --password=$DEBIT_PASSWORD | ||
231 | echo " OK" | ||
232 | export LIBEUFIN_NEXUS_USERNAME=$DEBIT_USERNAME | ||
233 | export LIBEUFIN_NEXUS_PASSWORD=$DEBIT_PASSWORD | ||
234 | |||
235 | prepare_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. | ||
243 | CREDIT_USERNAME=anastasis-credit-user | ||
244 | CREDIT_PASSWORD=anastasis-credit-password | ||
245 | echo -n "create credit user (for anastasis) at Nexus ..." | ||
246 | libeufin-nexus superuser $CREDIT_USERNAME --password=$CREDIT_PASSWORD | ||
247 | echo " OK" | ||
248 | export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME | ||
249 | export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD | ||
250 | |||
251 | prepare_nexus_account \ | ||
252 | ebicsuserCredit \ | ||
253 | ebicspartnerCredit \ | ||
254 | bankconnection-credit \ | ||
255 | nexus-bankaccount-credit \ | ||
256 | sandbox-account-credit | ||
257 | |||
258 | echo -n create facade ... | ||
259 | libeufin-cli facades new-anastasis-facade \ | ||
260 | --currency=$CURRENCY \ | ||
261 | --facade-name=facade-credit \ | ||
262 | bankconnection-credit nexus-bankaccount-credit | ||
263 | echo " OK" | ||
264 | sleep 1 | ||
265 | FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \") | ||
167 | 266 | ||
267 | ## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD | ||
268 | echo Nexus preparation done. | ||
168 | 269 | ||
169 | echo -n "Initialize Anastasis database ..." | 270 | echo -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! | ||
189 | anastasis-config -c $CONF \ | 288 | anastasis-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} |
193 | anastasis-config -c $CONF \ | 292 | anastasis-config -c $CONF \ |
194 | -s authorization-iban \ | 293 | -s authorization-iban \ |
195 | -o WIRE_GATEWAY_AUTH_METHOD \ | 294 | -o WIRE_GATEWAY_AUTH_METHOD \ |