diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-04-13 10:53:36 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-04-13 10:53:36 +0200 |
commit | 49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50 (patch) | |
tree | 4dd590ad96656752308af959a02c3de5843fa678 /src/cli/test_iban.sh | |
parent | 3d27addfb97a6d4f10eedecce8d707c5d18774b7 (diff) | |
download | anastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.tar.gz anastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.tar.bz2 anastasis-49aebaedc3d200c8c9ce306f8e3ea5bdc4449a50.zip |
major work on test_iban
Diffstat (limited to 'src/cli/test_iban.sh')
-rwxr-xr-x | src/cli/test_iban.sh | 67 |
1 files changed, 57 insertions, 10 deletions
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}" |