summaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-04-15 12:55:47 +0200
committerFlorian Dold <florian@dold.me>2022-04-15 12:56:02 +0200
commitcc56b7357a2531300b08ed6f3732cefca1ce878a (patch)
treef54a1c35222f57cd49bde345505bcbb391e8e57b /src/cli
parent0601dd2e424534b6c4cacf8c6844f354919cc0ca (diff)
downloadanastasis-cc56b7357a2531300b08ed6f3732cefca1ce878a.tar.gz
anastasis-cc56b7357a2531300b08ed6f3732cefca1ce878a.tar.bz2
anastasis-cc56b7357a2531300b08ed6f3732cefca1ce878a.zip
tests: also sync providers in backup
Diffstat (limited to 'src/cli')
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh50
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_no_pay.sh52
2 files changed, 70 insertions, 32 deletions
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 24cddc3..49814cd 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -26,6 +26,36 @@ function cleanup()
wait
}
+function sync_providers() {
+ infile=$1
+ outfile=$2
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ anastasis-reducer sync_providers < $infile > $outfile 2> /dev/null || true
+ CODE=$(jq -r -e ".code // 0" < $outfile)
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if test "$CODE" = "8420"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if test "$CODE" = "8400"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ if test "$CODE" != "0"; then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cat $outfile > $infile
+ done
+ echo "Providers synced."
+}
+
CONF_1="test_anastasis_reducer_1.conf"
CONF_2="test_anastasis_reducer_2.conf"
@@ -287,6 +317,9 @@ anastasis-reducer -a \
"sq_number": "4",
"birthdate": "2000-01-01"}}' \
enter_user_attributes < $B1FILE > $B2FILE
+cat $B2FILE > $B1FILE
+echo -n ","
+sync_providers $B1FILE $B2FILE
echo -n ","
# "91GPWWR" encodes "Hans"
anastasis-reducer -a \
@@ -435,22 +468,9 @@ then
fi
echo " OK"
-# Sync with providers (up to 3 providers aren't synced here)
-for x in 1 2 3; do
- echo "Synchronizing providers (round $x)"
- anastasis-reducer sync_providers < $R2FILE > $R1FILE 2> /dev/null || true
- CODE=$(jq -r -e ".code // 0" < $R1FILE)
- if test "$CODE" = "8420"; then
- break
- fi
- if test "$CODE" != "0"; then
- exit_fail "Expected no error or 8420, got $CODE"
- fi
- cat $R1FILE > $R2FILE
-done
-
-echo "Providers synced."
+cat $R2FILE > $R1FILE
+sync_providers $R1FILE $R2FILE
echo -n "Running challenge logic ..."
diff --git a/src/cli/test_anastasis_reducer_recovery_no_pay.sh b/src/cli/test_anastasis_reducer_recovery_no_pay.sh
index e65c526..f58980d 100755
--- a/src/cli/test_anastasis_reducer_recovery_no_pay.sh
+++ b/src/cli/test_anastasis_reducer_recovery_no_pay.sh
@@ -26,6 +26,36 @@ function cleanup()
wait
}
+function sync_providers() {
+ infile=$1
+ outfile=$2
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ anastasis-reducer sync_providers < $infile > $outfile 2> /dev/null || true
+ CODE=$(jq -r -e ".code // 0" < $outfile)
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if test "$CODE" = "8420"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if test "$CODE" = "8400"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ if test "$CODE" != "0"; then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cat $outfile > $infile
+ done
+ echo "Providers synced."
+}
+
CONF_1="test_anastasis_reducer_free_1.conf"
CONF_2="test_anastasis_reducer_free_2.conf"
@@ -137,6 +167,9 @@ anastasis-reducer -a \
"sq_number": "4",
"birthdate": "2000-01-01"}}' \
enter_user_attributes < $B1FILE > $B2FILE
+cat $B2FILE > $B1FILE
+echo -n ","
+sync_providers $B1FILE $B2FILE
echo -n ","
# "91GPWWR" encodes "Hans"
anastasis-reducer -a \
@@ -227,23 +260,8 @@ then
fi
echo " OK"
-echo -n "Synchronizing providers"
-# Sync with providers (up to 3 providers aren't synced here)
-for x in 1 2 3; do
- echo "Synchronizing providers (round $x)"
- anastasis-reducer sync_providers < $R2FILE > $R1FILE 2> /dev/null || true
- CODE=$(jq -r -e ".code // 0" < $R1FILE)
- if test "$CODE" = "8420"; then
- break
- fi
- if test "$CODE" != "0"; then
- exit_fail "Expected no error or 8420, got $CODE"
- fi
- cat $R1FILE > $R2FILE
-done
-
-echo "Providers synced."
-
+cat $R2FILE > $R1FILE
+sync_providers $R1FILE $R2FILE
echo -n "Running challenge logic ..."