aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-22 17:04:01 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-22 17:04:01 +0200
commitb160641b833ff2bb7b4a72d5b158a685d14cf825 (patch)
treebb6662ac467872e043eebfba4b9113b120f478dc
parentb44c62c82078733e74b3299122cec3209492de98 (diff)
downloadanastasis-b160641b833ff2bb7b4a72d5b158a685d14cf825.tar.gz
anastasis-b160641b833ff2bb7b4a72d5b158a685d14cf825.zip
-more work on test_iban.sh
-rw-r--r--doc/sphinx/manpages/anastasis.conf.5.rst2
-rw-r--r--src/cli/Makefile.am1
-rw-r--r--src/cli/test_anastasis_reducer_1.conf1
-rw-r--r--src/cli/test_anastasis_reducer_2.conf1
-rw-r--r--src/cli/test_anastasis_reducer_3.conf1
-rw-r--r--src/cli/test_anastasis_reducer_4.conf1
-rwxr-xr-xsrc/cli/test_anastasis_reducer_add_authentication.sh1
-rwxr-xr-xsrc/cli/test_anastasis_reducer_backup_enter_user_attributes.sh1
-rwxr-xr-xsrc/cli/test_anastasis_reducer_done_policy_review.sh1
-rwxr-xr-xsrc/cli/test_anastasis_reducer_enter_secret.sh2
-rwxr-xr-xsrc/cli/test_anastasis_reducer_initialize_state.sh1
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh3
-rwxr-xr-xsrc/cli/test_anastasis_reducer_select_country.sh1
-rw-r--r--src/cli/test_free_reducer.conf27
-rwxr-xr-xsrc/cli/test_iban.sh261
-rw-r--r--src/cli/test_reducer.conf1
-rw-r--r--src/reducer/anastasis_api_backup_redux.c48
-rw-r--r--src/reducer/anastasis_api_recovery_redux.c4
-rw-r--r--src/restclient/anastasis_api_config.c4
19 files changed, 333 insertions, 29 deletions
diff --git a/doc/sphinx/manpages/anastasis.conf.5.rst b/doc/sphinx/manpages/anastasis.conf.5.rst
index 40a3b7e..f0e683c 100644
--- a/doc/sphinx/manpages/anastasis.conf.5.rst
+++ b/doc/sphinx/manpages/anastasis.conf.5.rst
@@ -148,6 +148,8 @@ CREDIT_IBAN
148BUSINESS_NAME 148BUSINESS_NAME
149 Name of the account holder. 149 Name of the account holder.
150 150
151WIRE_GATEWAY_URL
152 Base URL of the LibEuFin wire gateway.
151 153
152 154
153Postgres database configuration 155Postgres database configuration
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 1dbe5d8..74cfcef 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -29,6 +29,7 @@ TESTS = \
29EXTRA_DIST = \ 29EXTRA_DIST = \
30 $(check_SCRIPTS) \ 30 $(check_SCRIPTS) \
31 test_reducer.conf \ 31 test_reducer.conf \
32 test_free_reducer.conf \
32 test_anastasis_reducer_1.conf \ 33 test_anastasis_reducer_1.conf \
33 test_anastasis_reducer_2.conf \ 34 test_anastasis_reducer_2.conf \
34 test_anastasis_reducer_3.conf \ 35 test_anastasis_reducer_3.conf \
diff --git a/src/cli/test_anastasis_reducer_1.conf b/src/cli/test_anastasis_reducer_1.conf
index 6a9704d..3a05690 100644
--- a/src/cli/test_anastasis_reducer_1.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -1,3 +1,4 @@
1# This file is in the public domain.
1@INLINE@ test_reducer.conf 2@INLINE@ test_reducer.conf
2 3
3[anastasis] 4[anastasis]
diff --git a/src/cli/test_anastasis_reducer_2.conf b/src/cli/test_anastasis_reducer_2.conf
index f909ade..4eef5f0 100644
--- a/src/cli/test_anastasis_reducer_2.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -1,3 +1,4 @@
1# This file is in the public domain.
1@INLINE@ test_reducer.conf 2@INLINE@ test_reducer.conf
2 3
3[anastasis] 4[anastasis]
diff --git a/src/cli/test_anastasis_reducer_3.conf b/src/cli/test_anastasis_reducer_3.conf
index 63c38ff..08f4700 100644
--- a/src/cli/test_anastasis_reducer_3.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -1,3 +1,4 @@
1# This file is in the public domain.
1@INLINE@ test_reducer.conf 2@INLINE@ test_reducer.conf
2 3
3[anastasis] 4[anastasis]
diff --git a/src/cli/test_anastasis_reducer_4.conf b/src/cli/test_anastasis_reducer_4.conf
index a6d590e..dee90e3 100644
--- a/src/cli/test_anastasis_reducer_4.conf
+++ b/src/cli/test_anastasis_reducer_4.conf
@@ -1,3 +1,4 @@
1# This file is in the public domain.
1@INLINE@ test_reducer.conf 2@INLINE@ test_reducer.conf
2 3
3[anastasis] 4[anastasis]
diff --git a/src/cli/test_anastasis_reducer_add_authentication.sh b/src/cli/test_anastasis_reducer_add_authentication.sh
index 7d69076..ec5a68e 100755
--- a/src/cli/test_anastasis_reducer_add_authentication.sh
+++ b/src/cli/test_anastasis_reducer_add_authentication.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
diff --git a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
index 433438e..b8662e8 100755
--- a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
diff --git a/src/cli/test_anastasis_reducer_done_policy_review.sh b/src/cli/test_anastasis_reducer_done_policy_review.sh
index 7052067..91cb8f8 100755
--- a/src/cli/test_anastasis_reducer_done_policy_review.sh
+++ b/src/cli/test_anastasis_reducer_done_policy_review.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh b/src/cli/test_anastasis_reducer_enter_secret.sh
index 2b305b9..8005f08 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -1,4 +1,6 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
3
2## Coloring style Text shell script 4## Coloring style Text shell script
3COLOR='\033[0;35m' 5COLOR='\033[0;35m'
4NOCOLOR='\033[0m' 6NOCOLOR='\033[0m'
diff --git a/src/cli/test_anastasis_reducer_initialize_state.sh b/src/cli/test_anastasis_reducer_initialize_state.sh
index 9dc0c59..b92ef45 100755
--- a/src/cli/test_anastasis_reducer_initialize_state.sh
+++ b/src/cli/test_anastasis_reducer_initialize_state.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index ad1aea0..d65020e 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
@@ -32,7 +33,7 @@ CONF_3="test_anastasis_reducer_3.conf"
32CONF_4="test_anastasis_reducer_4.conf" 33CONF_4="test_anastasis_reducer_4.conf"
33 34
34 35
35# Exchange configuration file will be edited, so we create one 36# Configuration file will be edited, so we create one
36# from the template. 37# from the template.
37CONF=`mktemp test_reducerXXXXXX.conf` 38CONF=`mktemp test_reducerXXXXXX.conf`
38cp test_reducer.conf $CONF 39cp test_reducer.conf $CONF
diff --git a/src/cli/test_anastasis_reducer_select_country.sh b/src/cli/test_anastasis_reducer_select_country.sh
index db17052..c02f61f 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# This file is in the public domain.
2 3
3set -eu 4set -eu
4 5
diff --git a/src/cli/test_free_reducer.conf b/src/cli/test_free_reducer.conf
new file mode 100644
index 0000000..364758c
--- /dev/null
+++ b/src/cli/test_free_reducer.conf
@@ -0,0 +1,27 @@
1# This file is in the public domain.
2# It is used by test_iban.sh
3[taler]
4CURRENCY = TESTKUDOS
5
6[anastasis]
7DB = postgres
8ANNUAL_FEE = TESTKUDOS:0
9TRUTH_UPLOAD_FEE = TESTKUDOS:0
10UPLOAD_LIMIT_MB = 1
11ANNUAL_POLICY_UPLOAD_LIMIT = 128
12INSURANCE = TESTKUDOS:0
13PORT = 8086
14SERVER_SALT = BUfO1KGOKYIFlFQg
15BUSINESS_NAME = "Data loss Inc."
16
17[anastasis-merchant-backend]
18# Technically not needed...
19PAYMENT_BACKEND_URL = http://localhost:9966/
20
21[authorization-question]
22COST = TESTKUDOS:0.0
23
24[authorization-iban]
25ENABLED = YES
26COST = TESTKUDOS:5
27BUSINESS_NAME = "Data loss inc."
diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh
index 95adbd8..e364280 100755
--- a/src/cli/test_iban.sh
+++ b/src/cli/test_iban.sh
@@ -21,24 +21,23 @@ function cleanup()
21 do 21 do
22 kill $n 2> /dev/null || true 22 kill $n 2> /dev/null || true
23 done 23 done
24 rm -rf $CONF $R1FILE $R2FILE $B1FILE $B2FILE
24 wait 25 wait
25} 26}
26 27
27# Install cleanup handler (except for kill -9)
28trap cleanup EXIT
29 28
30# $1=ebics username, $2=ebics partner name, $3=person name, $4=sandbox bank account name, $5=iban 29# $1=ebics username, $2=ebics partner name, $3=person name, $4=sandbox bank account name, $5=iban
31function prepare_sandbox_account() { 30function prepare_sandbox_account() {
32 31
33 echo Activating ebics subscriber $1 at the sandbox 32 echo -n "Activating ebics subscriber $1 at the sandbox ..."
34 libeufin-cli \ 33 libeufin-cli \
35 sandbox --sandbox-url=$SANDBOX_URL \ 34 sandbox --sandbox-url=$SANDBOX_URL \
36 ebicssubscriber create \ 35 ebicssubscriber create \
37 --host-id=ebicstesthost \ 36 --host-id=ebicstesthost \
38 --partner-id=$2 \ 37 --partner-id=$2 \
39 --user-id=$1 38 --user-id=$1
40 39 echo " OK"
41 echo "Giving a bank account ($4) to $1" 40 echo -n "Giving a bank account ($4) to $1 ..."
42 libeufin-cli \ 41 libeufin-cli \
43 sandbox --sandbox-url=$SANDBOX_URL \ 42 sandbox --sandbox-url=$SANDBOX_URL \
44 ebicsbankaccount create \ 43 ebicsbankaccount create \
@@ -50,10 +49,28 @@ function prepare_sandbox_account() {
50 --ebics-host-id=ebicstesthost \ 49 --ebics-host-id=ebicstesthost \
51 --ebics-partner-id=$2 \ 50 --ebics-partner-id=$2 \
52 --currency=$CURRENCY 51 --currency=$CURRENCY
52 echo " OK"
53}
53 54
55# Configuration file will be edited, so we create one
56# from the template.
57CONF=`mktemp test_free_reducerXXXXXX.conf`
58cp test_free_reducer.conf $CONF
54 59
60B1FILE=`mktemp test_reducer_stateB1XXXXXX`
61B2FILE=`mktemp test_reducer_stateB2XXXXXX`
62R1FILE=`mktemp test_reducer_stateR1XXXXXX`
63R2FILE=`mktemp test_reducer_stateR2XXXXXX`
55 64
56} 65export CONF
66export B2FILE
67export B1FILE
68export R2FILE
69export R1FILE
70
71
72# Install cleanup handler (except for kill -9)
73trap cleanup EXIT
57 74
58# Script's guidelines: 75# Script's guidelines:
59 76
@@ -63,7 +80,6 @@ function prepare_sandbox_account() {
63# or an sqlite file created via "mktemp /tmp/test-XXXXXX" 80# or an sqlite file created via "mktemp /tmp/test-XXXXXX"
64# or something like that 81# or something like that
65#* exits with 77 if libeufin is not properly installed/available 82#* exits with 77 if libeufin is not properly installed/available
66#* exits with 77 if Postgres with 'anastasischeck' is not properly
67# installed/available 83# installed/available
68#* starts Nexus (in background) 84#* starts Nexus (in background)
69#* starts sandbox (in background) 85#* starts sandbox (in background)
@@ -101,42 +117,257 @@ if ! libeufin-sandbox --version &> /dev/null; then
101 exit_skip "libeufin-sandbox not found" 117 exit_skip "libeufin-sandbox not found"
102fi 118fi
103 119
104if ! psql -d anastasischeck -c "\q" &> /dev/null; then 120
105 exit_skip "Postgresql database 'anastasischeck' not reachable" 121# Check we can actually run
106fi 122echo -n "Testing for jq"
123jq -h > /dev/null || exit_skip "jq required"
124echo " FOUND"
125echo -n "Testing for anastasis-reducer ..."
126anastasis-reducer -h > /dev/null || exit_skip "anastasis-reducer required"
127echo " FOUND"
107 128
108export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/nexus-db-XXXXXX.sqlite)" 129export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/nexus-db-XXXXXX.sqlite)"
109export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/sandbox-db-XXXXXX.sqlite)" 130export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/sandbox-db-XXXXXX.sqlite)"
110NEXUS_URL="http://localhost:5001/" 131NEXUS_URL="http://localhost:5001/"
111SANDBOX_URL="http://localhost:5000/" 132SANDBOX_URL="http://localhost:5000/"
112 133
113echo "Starting Nexus .." 134echo -n "Starting Nexus ..."
114libeufin-nexus serve &> nexus.log & 135libeufin-nexus serve &> nexus.log &
115nexus_pid=$! 136nexus_pid=$!
116if ! curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null; then 137if ! curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null; then
117 exit_skip "Could not launch Nexus" 138 exit_skip "Could not launch Nexus"
118fi 139fi
119echo "Nexus started." 140echo "OK"
120 141
121echo "Starting Sandbox .." 142echo -n "Starting Sandbox ..."
122libeufin-sandbox serve &> sandbox.log & 143libeufin-sandbox serve &> sandbox.log &
123sandbox_pid=$! 144sandbox_pid=$!
124if ! curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null; then 145if ! curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null; then
125 exit_skip "Could not launch Sandbox" 146 exit_skip "Could not launch Sandbox"
126fi 147fi
127echo "Sandbox started." 148echo " OK"
128 149
129CURRENCY="TESTKUDOS" 150CURRENCY="TESTKUDOS"
130IBAN1="AA3314655813489414469157" 151IBAN1="AA3314655813489414469157"
131IBAN2="BB3314655813489414469157" 152IBAN2="BB3314655813489414469157"
153export IBAN1
154export IBAN2
132 155
133echo Making a ebics host at the sandbox 156echo -n "Making an ebics host at the sandbox "
134libeufin-cli \ 157libeufin-cli \
135 sandbox --sandbox-url=$SANDBOX_URL \ 158 sandbox --sandbox-url=$SANDBOX_URL \
136 ebicshost create \ 159 ebicshost create \
137 --host-id=ebicstesthost 160 --host-id=ebicstesthost
161echo " OK"
138 162
139prepare_sandbox_account \ 163prepare_sandbox_account \
140 ebicsuser01 ebicspartner01 Person01 sandbox-account-01 $IBAN1 164 ebicsuser01 ebicspartner01 Person01 sandbox-account-01 $IBAN1
141prepare_sandbox_account \ 165prepare_sandbox_account \
142 ebicsuser02 ebicspartner02 Person02 sandbox-account-02 $IBAN2 166 ebicsuser02 ebicspartner02 Person02 sandbox-account-02 $IBAN2
167
168
169echo -n "Initialize Anastasis database ..."
170# Name of the Postgres database we will use for the script.
171# Will be dropped, do NOT use anything that might be used
172# elsewhere
173
174TARGET_DB=`anastasis-config -c $CONF -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
175
176dropdb $TARGET_DB >/dev/null 2>/dev/null || true
177createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
178anastasis-dbinit -c $CONF 2> anastasis-dbinit.log
179
180echo " OK"
181
182echo -n "Configuring Anastasis IBAN account ..."
183anastasis-config -c $CONF \
184 -s authorization-iban \
185 -o CREDIT_IBAN \
186 -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 \
190 -s authorization-iban \
191 -o WIRE_GATEWAY_URL \
192 -V ${NEXUS_URL}
193anastasis-config -c $CONF \
194 -s authorization-iban \
195 -o WIRE_GATEWAY_AUTH_METHOD \
196 -V "external"
197echo " OK"
198
199echo -n "Launching Anastasis service ..."
200PREFIX="" #valgrind
201$PREFIX anastasis-httpd -c $CONF 2> anastasis-httpd_1.log &
202echo " OK"
203
204echo -n "Waiting for Anastasis service ..."
205# Wait for Anastasis service to be available
206for n in `seq 1 50`
207do
208 echo -n "."
209 sleep 0.1
210 OK=0
211 # anastasis_01
212 wget --tries=1 --timeout=1 http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || continue
213 OK=1
214 break
215done
216if [ 1 != $OK ]
217then
218 exit_skip "Failed to launch Anastasis service"
219fi
220echo "OK"
221
222
223
224echo -n "Running backup logic ...,"
225anastasis-reducer -b > $B1FILE
226echo -n "."
227anastasis-reducer -a \
228 '{"continent": "Testcontinent"}' \
229 select_continent < $B1FILE > $B2FILE
230echo -n "."
231anastasis-reducer -a \
232 '{"country_code": "xx",
233 "currencies":["TESTKUDOS"]}' \
234 select_country < $B2FILE > $B1FILE 2>> test_reducer.err
235echo -n "."
236
237anastasis-reducer -a \
238 '{"identity_attributes": {
239 "full_name": "Max Musterman",
240 "sq_number": "4",
241 "birthdate": "2000-01-01"}}' \
242 enter_user_attributes < $B1FILE > $B2FILE 2>> test_reducer.err
243echo -n ","
244
245BASEIBAN=`echo $IBAN2 | gnunet-base32`
246anastasis-reducer -a \
247 "$(jq -n '{ authentication_method: {
248 type: "iban",
249 instructions: "Send me your money!",
250 challenge: $CHALLENGE
251 } }' \
252 --arg CHALLENGE "$BASEIBAN"
253 )" \
254 add_authentication < $B2FILE > $B1FILE 2>> test_reducer.err
255echo -n "."
256# Finished adding authentication methods
257anastasis-reducer \
258 next < $B1FILE > $B2FILE 2>> test_reducer.err
259
260echo -n ","
261# Finished policy review
262anastasis-reducer \
263 next < $B2FILE > $B1FILE 2>> test_reducer.err
264echo -n "."
265
266# Note: 'secret' must here be a Crockford base32-encoded value
267anastasis-reducer -a \
268 '{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
269 enter_secret < $B1FILE > $B2FILE 2>> test_reducer.err
270mv $B2FILE $B1FILE
271anastasis-reducer next < $B1FILE > $B2FILE 2>> test_reducer.err
272echo " OK"
273
274echo -n "Final backup checks ..."
275STATE=`jq -r -e .backup_state < $B2FILE`
276if test "$STATE" != "BACKUP_FINISHED"
277then
278 exit_fail "Expected new state to be 'BACKUP_FINISHED', got '$STATE'"
279fi
280jq -r -e .core_secret < $B2FILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
281echo " OK"
282
283
284
285echo -n "Running recovery basic logic ..."
286anastasis-reducer -r > $R1FILE
287anastasis-reducer -a \
288 '{"continent": "Testcontinent"}' \
289 select_continent < $R1FILE > $R2FILE
290anastasis-reducer -a \
291 '{"country_code": "xx",
292 "currencies":["TESTKUDOS"]}' \
293 select_country < $R2FILE > $R1FILE 2>> test_reducer.err
294anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < $R1FILE > $R2FILE 2>> test_reducer.err
295
296
297STATE=`jq -r -e .recovery_state < $R2FILE`
298if test "$STATE" != "SECRET_SELECTING"
299then
300 exit_fail "Expected new state to be 'SECRET_SELECTING', got '$STATE'"
301fi
302echo " OK"
303
304echo -n "Selecting default secret"
305mv $R2FILE $R1FILE
306anastasis-reducer next < $R1FILE > $R2FILE 2>> test_reducer.err
307
308STATE=`jq -r -e .recovery_state < $R2FILE`
309if test "$STATE" != "CHALLENGE_SELECTING"
310then
311 exit_fail "Expected new state to be 'CHALLENGE_SELECTING', got '$STATE'"
312fi
313echo " OK"
314
315echo -n "Running challenge logic ..."
316
317NAME_UUID=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
318anastasis-reducer -a \
319 "$(jq -n '
320 {
321 uuid: $UUID
322 }' \
323 --arg UUID "$NAME_UUID"
324 )" \
325 select_challenge < $R2FILE > $R1FILE 2>> test_reducer.err
326
327# FIXME: check $IBAN1 is properly in $R1FILE
328# FIXME: check TESTKUDOS:5 is properly in $R1FILE
329# FIXME: extract wire transfer subject from $R1FILE
330
331# FIXME-MS: must do wire transfer here!
332
333# bash
334
335echo "TEST INCOMPLETE --- BAILING for now"
336
337exit 77
338
339# Check for inbound wire transfer (fails with 'Failed to load bank access configuration data')
340anastasis-helper-authorization-iban -c $CONF -t
341
342# Now we should get the secret...
343anastasis-reducer poll < $R1FILE > $R2FILE
344
345echo " OK"
346
347echo -n "Checking recovered secret ..."
348# finally: check here that we recovered the secret...
349
350STATE=`jq -r -e .recovery_state < $R2FILE`
351if test "$STATE" != "RECOVERY_FINISHED"
352then
353 jq -e . $R2FILE
354 exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
355fi
356
357SECRET=`jq -r -e .core_secret.value < $R2FILE`
358if test "$SECRET" != "VERYHARDT0GVESSSECRET"
359then
360 jq -e . $R2FILE
361 exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got '$SECRET'"
362fi
363
364MIME=`jq -r -e .core_secret.mime < $R2FILE`
365if test "$MIME" != "text/plain"
366then
367 jq -e . $R2FILE
368 exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
369fi
370
371echo " OK"
372
373exit 0
diff --git a/src/cli/test_reducer.conf b/src/cli/test_reducer.conf
index ef923bb..df68b14 100644
--- a/src/cli/test_reducer.conf
+++ b/src/cli/test_reducer.conf
@@ -1,3 +1,4 @@
1# This file is in the public domain.
1[PATHS] 2[PATHS]
2TALER_HOME = ${PWD}/test_reducer_home/ 3TALER_HOME = ${PWD}/test_reducer_home/
3TALER_DATA_HOME = $TALER_HOME/.local/share/taler/ 4TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c
index d2e5a46..de6537e 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -278,6 +278,10 @@ add_authentication (json_t *state,
278 GNUNET_JSON_spec_end () 278 GNUNET_JSON_spec_end ()
279 }; 279 };
280 280
281 if (MHD_HTTP_OK !=
282 json_integer_value (json_object_get (details,
283 "http_status")))
284 continue; /* skip providers that are down */
281 if (GNUNET_OK != 285 if (GNUNET_OK !=
282 GNUNET_JSON_parse (details, 286 GNUNET_JSON_parse (details,
283 ispec, 287 ispec,
@@ -856,6 +860,13 @@ eval_provider_selection (struct PolicyBuilder *pb,
856 return; 860 return;
857 } 861 }
858 862
863 if (MHD_HTTP_OK !=
864 json_integer_value (json_object_get (provider_cfg,
865 "http_status")))
866 {
867 GNUNET_JSON_parse_free (mspec);
868 return; /* skip providers that are down */
869 }
859 if (GNUNET_OK != 870 if (GNUNET_OK !=
860 GNUNET_JSON_parse (provider_cfg, 871 GNUNET_JSON_parse (provider_cfg,
861 pspec, 872 pspec,
@@ -1144,13 +1155,18 @@ lookup_salt (const json_t *state,
1144 GNUNET_break (0); 1155 GNUNET_break (0);
1145 return GNUNET_SYSERR; 1156 return GNUNET_SYSERR;
1146 } 1157 }
1158 if (MHD_HTTP_OK !=
1159 json_integer_value (json_object_get (cfg,
1160 "http_status")))
1161 return GNUNET_NO; /* skip providers that are down */
1147 if (GNUNET_OK != 1162 if (GNUNET_OK !=
1148 GNUNET_JSON_parse (cfg, 1163 GNUNET_JSON_parse (cfg,
1149 spec, 1164 spec,
1150 NULL, NULL)) 1165 NULL, NULL))
1151 { 1166 {
1152 GNUNET_break (0); 1167 /* provider not working */
1153 return GNUNET_SYSERR; 1168 GNUNET_break_op (0);
1169 return GNUNET_NO;
1154 } 1170 }
1155 return GNUNET_OK; 1171 return GNUNET_OK;
1156} 1172}
@@ -1608,6 +1624,7 @@ done_authentication (json_t *state,
1608 json_t *details; 1624 json_t *details;
1609 1625
1610 policy_providers = json_array (); 1626 policy_providers = json_array ();
1627 GNUNET_assert (NULL != policy_providers);
1611 json_object_foreach (available, url, details) 1628 json_object_foreach (available, url, details)
1612 { 1629 {
1613 json_t *provider; 1630 json_t *provider;
@@ -1853,19 +1870,18 @@ add_policy (json_t *state,
1853 "provider URL unknown"); 1870 "provider URL unknown");
1854 return NULL; 1871 return NULL;
1855 } 1872 }
1873 if (MHD_HTTP_OK !=
1874 json_integer_value (json_object_get (prov_cfg,
1875 "http_status")))
1876 continue;
1856 if (GNUNET_OK != 1877 if (GNUNET_OK !=
1857 GNUNET_JSON_parse (prov_cfg, 1878 GNUNET_JSON_parse (prov_cfg,
1858 spec, 1879 spec,
1859 NULL, NULL)) 1880 NULL, NULL))
1860 { 1881 {
1861 GNUNET_break (0); 1882 /* skip provider, likely was down */
1862 json_decref (methods); 1883 json_decref (methods);
1863 ANASTASIS_redux_fail_ (cb, 1884 continue;
1864 cb_cls,
1865 TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
1866 "provider lacks authentication methods");
1867 return NULL;
1868
1869 } 1885 }
1870 if (! json_is_array (prov_methods)) 1886 if (! json_is_array (prov_methods))
1871 { 1887 {
@@ -2310,13 +2326,18 @@ update_expiration_cost (json_t *state,
2310 }; 2326 };
2311 struct TALER_Amount fee; 2327 struct TALER_Amount fee;
2312 2328
2329 if (MHD_HTTP_OK !=
2330 json_integer_value (json_object_get (provider,
2331 "http_status")))
2332 continue; /* skip providers that are down */
2313 if (GNUNET_OK != 2333 if (GNUNET_OK !=
2314 GNUNET_JSON_parse (provider, 2334 GNUNET_JSON_parse (provider,
2315 pspec, 2335 pspec,
2316 NULL, NULL)) 2336 NULL, NULL))
2317 { 2337 {
2318 GNUNET_break (0); 2338 /* strange, skip as well */
2319 return GNUNET_SYSERR; 2339 GNUNET_break_op (0);
2340 continue;
2320 } 2341 }
2321 if (0 > 2342 if (0 >
2322 TALER_amount_multiply (&fee, 2343 TALER_amount_multiply (&fee,
@@ -4043,12 +4064,17 @@ check_upload_size_limit (json_t *state,
4043 GNUNET_JSON_spec_end () 4064 GNUNET_JSON_spec_end ()
4044 }; 4065 };
4045 4066
4067 if (MHD_HTTP_OK !=
4068 json_integer_value (json_object_get (ap,
4069 "http_status")))
4070 continue; /* skip providers that are down */
4046 if (GNUNET_OK != 4071 if (GNUNET_OK !=
4047 GNUNET_JSON_parse (ap, 4072 GNUNET_JSON_parse (ap,
4048 spec, 4073 spec,
4049 NULL, NULL)) 4074 NULL, NULL))
4050 { 4075 {
4051 /* skip malformed provider, likely /config failed */ 4076 /* skip malformed provider, likely /config failed */
4077 GNUNET_break_op (0);
4052 continue; 4078 continue;
4053 } 4079 }
4054 if (0 == limit) 4080 if (0 == limit)
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c
index c549d35..5513e83 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -2552,6 +2552,10 @@ launch_recovery (struct RecoverSecretState *rss,
2552 GNUNET_JSON_spec_end () 2552 GNUNET_JSON_spec_end ()
2553 }; 2553 };
2554 2554
2555 if (MHD_HTTP_OK !=
2556 json_integer_value (json_object_get (p_cfg,
2557 "http_status")))
2558 return false; /* skip providers that are down */
2555 if (GNUNET_OK != 2559 if (GNUNET_OK !=
2556 GNUNET_JSON_parse (p_cfg, 2560 GNUNET_JSON_parse (p_cfg,
2557 spec, 2561 spec,
diff --git a/src/restclient/anastasis_api_config.c b/src/restclient/anastasis_api_config.c
index c4857b3..2f6dc3c 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -91,8 +91,8 @@ handle_config_finished (void *cls,
91 switch (response_code) 91 switch (response_code)
92 { 92 {
93 case 0: 93 case 0:
94 /* Hard error */ 94 /* No reply received */
95 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 95 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
96 "Backend `%s' failed to respond to GET /config\n", 96 "Backend `%s' failed to respond to GET /config\n",
97 co->url); 97 co->url);
98 break; 98 break;