summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-13 10:53:36 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-13 10:53:36 +0200
commit49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50 (patch)
tree4dd590ad96656752308af959a02c3de5843fa678
parent3d27addfb97a6d4f10eedecce8d707c5d18774b7 (diff)
downloadanastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.tar.gz
anastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.tar.bz2
anastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.zip
major work on test_iban
-rw-r--r--src/authorization/anastasis_authorization_plugin_iban.c30
-rw-r--r--src/cli/test_free_reducer.conf2
-rwxr-xr-xsrc/cli/test_iban.sh67
-rw-r--r--src/restclient/anastasis_api_truth_challenge.c3
4 files changed, 80 insertions, 22 deletions
diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c
index 3887ecd..b48aa56 100644
--- a/src/authorization/anastasis_authorization_plugin_iban.c
+++ b/src/authorization/anastasis_authorization_plugin_iban.c
@@ -450,16 +450,24 @@ iban_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
resp = TALER_MHD_MAKE_JSON_PACK (
GNUNET_JSON_pack_string ("challenge_type",
"IBAN_WIRE"),
- GNUNET_JSON_pack_uint64 ("answer_code",
- as->code),
- TALER_JSON_pack_amount ("challenge_amount",
- &ctx->expected_amount),
- GNUNET_JSON_pack_string ("credit_iban",
- ctx->business_iban),
- GNUNET_JSON_pack_string ("business_name",
- ctx->business_name),
- GNUNET_JSON_pack_string ("wire_transfer_subject",
- subject));
+ GNUNET_JSON_pack_object_steal (
+ "wire_details",
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 (
+ "answer_code",
+ as->code),
+ TALER_JSON_pack_amount (
+ "challenge_amount",
+ &ctx->expected_amount),
+ GNUNET_JSON_pack_string (
+ "credit_iban",
+ ctx->business_iban),
+ GNUNET_JSON_pack_string (
+ "business_name",
+ ctx->business_name),
+ GNUNET_JSON_pack_string (
+ "wire_transfer_subject",
+ subject))));
}
else
{
@@ -485,7 +493,7 @@ iban_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
"text/plain"));
}
mres = MHD_queue_response (connection,
- MHD_HTTP_ACCEPTED,
+ MHD_HTTP_OK,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
diff --git a/src/cli/test_free_reducer.conf b/src/cli/test_free_reducer.conf
index 74954cd..8308537 100644
--- a/src/cli/test_free_reducer.conf
+++ b/src/cli/test_free_reducer.conf
@@ -11,7 +11,7 @@ UPLOAD_LIMIT_MB = 1
ANNUAL_POLICY_UPLOAD_LIMIT = 128
INSURANCE = EUR:0
PORT = 8086
-SERVER_SALT = BUfO1KGOKYIFlFQg
+PROVIDER_SALT = BUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss Inc."
[stasis]
diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh
index 923256b..a5e33f4 100755
--- a/src/cli/test_iban.sh
+++ b/src/cli/test_iban.sh
@@ -327,6 +327,19 @@ anastasis-reducer -a \
)" \
add_authentication < $B2FILE > $B1FILE 2>> test_reducer.err
echo -n "."
+
+# "91GPWWR" encodes "Hans"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "What is your name?",
+ "challenge": "91GPWWR"
+ } }' \
+ add_authentication < $B1FILE > $B2FILE 2>> test_reducer.err
+echo -n "."
+
+mv $B2FILE $B1FILE
+
# Finished adding authentication methods
anastasis-reducer \
next < $B1FILE > $B2FILE 2>> test_reducer.err
@@ -372,9 +385,13 @@ then
fi
echo " OK"
-echo -n "Selecting default secret"
-mv $R2FILE $R1FILE
-anastasis-reducer next < $R1FILE > $R2FILE 2>> test_reducer.err
+echo -n "Adding provider (to ensure it is loaded)"
+anastasis-reducer -a '{"provider_url" : "http://localhost:8086/" }' add_provider < $R2FILE > $R1FILE
+echo " OK"
+
+echo -n "Selecting secret to recover"
+anastasis-reducer -a '{"attribute_mask": 0, "providers" : [ { "version": 0, "url" : "http://localhost:8086/" } ] }' \
+ select_version < $R1FILE > $R2FILE 2>> test_reducer.err
STATE=`jq -r -e .recovery_state < $R2FILE`
if test "$STATE" != "CHALLENGE_SELECTING"
@@ -385,7 +402,22 @@ echo " OK"
echo -n "Running challenge selection logic ..."
-NAME_UUID=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
+UUID0=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
+UUID1=`jq -r -e .recovery_information.challenges[1].uuid < $R2FILE`
+UUID0Q=`jq -r -e .recovery_information.challenges[0].instructions < $R2FILE`
+UUID1Q=`jq -r -e .recovery_information.challenges[1].instructions < $R2FILE`
+
+if test "$UUID1Q" = 'What is your name?'
+then
+ NAME_UUID=$UUID1
+ IBAN_UUID=$UUID0
+else
+ NAME_UUID=$UUID0
+ IBAN_UUID=$UUID1
+fi
+
+echo "OK"
+echo -n "Solving first challenge ..."
anastasis-reducer -a \
"$(jq -n '
{
@@ -395,15 +427,30 @@ anastasis-reducer -a \
)" \
select_challenge < $R2FILE > $R1FILE 2>> test_reducer.err
+anastasis-reducer -a '{"answer": "Hans"}' \
+ solve_challenge < $R1FILE > $R2FILE
+
+echo "OK"
+echo -n "Solving IBAN challenge ..."
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$IBAN_UUID"
+ )" \
+ select_challenge < $R2FILE > $R1FILE 2>> test_reducer.err
echo "OK"
-METHOD=`jq -r -e .challenge_feedback.\"$NAME_UUID\".method < $R1FILE`
-if test "$METHOD" != "iban"
+
+METHOD=`jq -r -e .challenge_feedback.\"$IBAN_UUID\".state < $R1FILE`
+if test "$METHOD" != "iban-instructions"
then
- exit_fail "Expected method to be 'iban', got ${METHOD}"
+ exit_fail "Expected method to be 'iban-instructions', got ${METHOD}"
fi
-ACC=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.credit_iban < $R1FILE`
+ACC=`jq -r -e .challenge_feedback.\"$IBAN_UUID\".target_iban < $R1FILE`
if test "$ACC" != ${IBAN_CREDIT}
then
exit_fail "Expected account to be ${IBAN_CREDIT}, got ${ACC}"
@@ -413,8 +460,8 @@ anastasis-reducer \
back < $R1FILE > $R2FILE 2>> test_reducer.err
-AMOUNT=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.challenge_amount < $R1FILE`
-SUBJECT=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.wire_transfer_subject < $R1FILE`
+AMOUNT=`jq -r -e .challenge_feedback.\"$IBAN_UUID\".challenge_amount < $R1FILE`
+SUBJECT=`jq -r -e .challenge_feedback.\"$IBAN_UUID\".wire_transfer_subject < $R1FILE`
echo -n "Performing authorization wire transfer ..."
wire_transfer_to_anastasis "${AMOUNT}" "${SUBJECT}"
diff --git a/src/restclient/anastasis_api_truth_challenge.c b/src/restclient/anastasis_api_truth_challenge.c
index 606bcfb..aa9119c 100644
--- a/src/restclient/anastasis_api_truth_challenge.c
+++ b/src/restclient/anastasis_api_truth_challenge.c
@@ -219,6 +219,9 @@ handle_truth_challenge_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected challenge type `%s'\n",
ct);
+ json_dumpf (j,
+ stderr,
+ JSON_INDENT (2));
tcd.http_status = 0;
tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;