gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated (4ed7e40 -> 5f18ee4)


From: gnunet
Subject: [taler-anastasis] branch master updated (4ed7e40 -> 5f18ee4)
Date: Tue, 10 Nov 2020 13:44:47 +0100

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a change to branch master
in repository anastasis.

    from 4ed7e40  dennis changes
     new 3bce1f8  fix return value from main() when run with -h/-v
     new ef66859  redux - test continent selection
     new c9fa610  redux - testing country selection
     new 47f6f14  testing user attributes collection
     new 9fbcdb9  fix ahv validation
     new 5f18ee4  Merge branch 'master' of ssh://git.taler.net/anastasis

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 contrib/redux.ch.json                              |   2 +-
 src/backend/anastasis-httpd.c                      |   6 +-
 src/cli/.gitignore                                 |   1 +
 src/cli/Makefile.am                                |  12 +-
 ...stasis_cli.conf => test_anastasis_reducer.conf} |   3 +
 ...asis_cli.conf => test_anastasis_reducer_1.conf} |  13 +-
 ...asis_cli.conf => test_anastasis_reducer_2.conf} |  11 +-
 ...asis_cli.conf => test_anastasis_reducer_3.conf} |  11 +-
 ...test_anastasis_reducer_enter_user_attributes.sh |  75 +++++++++
 src/cli/test_anastasis_reducer_initialize_state.sh | 106 ++++++++++++
 src/cli/test_anastasis_reducer_select_continent.sh | 132 +++++++++++++++
 src/cli/test_anastasis_reducer_select_country.sh   | 177 +++++++++++++++++++++
 src/include/anastasis_redux.h                      |  14 ++
 src/lib/anastasis_api_backup_redux.c               |  19 ---
 src/lib/anastasis_api_redux.c                      |  45 ++++--
 15 files changed, 574 insertions(+), 53 deletions(-)
 copy src/cli/{test_anastasis_cli.conf => test_anastasis_reducer.conf} (99%)
 copy src/cli/{test_anastasis_cli.conf => test_anastasis_reducer_1.conf} (97%)
 copy src/cli/{test_anastasis_cli.conf => test_anastasis_reducer_2.conf} (98%)
 rename src/cli/{test_anastasis_cli.conf => test_anastasis_reducer_3.conf} (98%)
 create mode 100755 src/cli/test_anastasis_reducer_enter_user_attributes.sh
 create mode 100755 src/cli/test_anastasis_reducer_initialize_state.sh
 create mode 100755 src/cli/test_anastasis_reducer_select_continent.sh
 create mode 100755 src/cli/test_anastasis_reducer_select_country.sh

diff --git a/contrib/redux.ch.json b/contrib/redux.ch.json
index 075ac6a..c8bd3dc 100644
--- a/contrib/redux.ch.json
+++ b/contrib/redux.ch.json
@@ -26,7 +26,7 @@
                                                "de_CH":"AHV-Nummer"
                                         },
            "widget": "anastasis_gtk_ia_ahv",
-      "validation": "^(756)\\.[0-9]{4}\\.[0-9]{4}\\.[0-9]{2}|(756)[0-9]{10}$"
+      "validation": "^(756).[0-9]{4}.[0-9]{4}.[0-9]{2}|(756)[0-9]{10}$"
        }
        ]
 }
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index d7e09b0..bc97bc8 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -736,6 +736,7 @@ int
 main (int argc,
       char *const *argv)
 {
+  enum GNUNET_GenericReturnValue res;
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_option_flag ('C',
                                "connection-close",
@@ -756,6 +757,9 @@ main (int argc,
                           "anastasis-httpd",
                           "Anastasis HTTP interface",
                           options, &run, NULL))
-    return 3;
+    if (GNUNET_SYSERR == res)
+      return 3;
+  if (GNUNET_NO == res)
+    return 0;
   return (GNUNET_OK == result) ? 0 : 1;
 }
diff --git a/src/cli/.gitignore b/src/cli/.gitignore
index 8850532..469eb87 100644
--- a/src/cli/.gitignore
+++ b/src/cli/.gitignore
@@ -1,3 +1,4 @@
 *.log
 anastasis-reducer
 test_reducer_home
+*.trs
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index ea04a09..3b9533b 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -10,7 +10,11 @@ if USE_COVERAGE
 endif
 
 check_SCRIPTS = \
-  test_reducer.sh
+  test_reducer.sh \
+  test_anastasis_reducer_initialize_state.sh \
+  test_anastasis_reducer_select_continent.sh \
+  test_anastasis_reducer_select_country.sh \
+  test_anastasis_reducer_enter_user_attributes.sh
 
 
 AM_TESTS_ENVIRONMENT=export 
ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export 
PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset 
XDG_CONFIG_HOME;
@@ -20,7 +24,11 @@ TESTS = \
 
 EXTRA_DIST = \
   $(check_SCRIPTS) \
-  test_reducer.conf
+  test_reducer.conf \
+  test_anastasis_reducer.conf \
+  test_anastasis_reducer_1.conf \
+  test_anastasis_reducer_2.conf \
+  test_anastasis_reducer_3.conf
 
 anastasis_reducer_SOURCES = \
   anastasis-cli-redux.c
diff --git a/src/cli/test_anastasis_cli.conf 
b/src/cli/test_anastasis_reducer.conf
similarity index 99%
copy from src/cli/test_anastasis_cli.conf
copy to src/cli/test_anastasis_reducer.conf
index 88891f3..ca7a6e9 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer.conf
@@ -53,6 +53,9 @@ UPLOAD_LIMIT_MB = 1
 
 SUPPORTED_METHODS = question
 
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
 # This specifies which database the postgres backend uses.
 [anastasisdb-postgres]
 CONFIG = postgres:///anastasischeck
diff --git a/src/cli/test_anastasis_cli.conf 
b/src/cli/test_anastasis_reducer_1.conf
similarity index 97%
copy from src/cli/test_anastasis_cli.conf
copy to src/cli/test_anastasis_reducer_1.conf
index 88891f3..30fba38 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -1,10 +1,10 @@
 # This file is in the public domain.
 #
 [PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
 TALER_TEST_HOME = test_anastasis_api_home/
 
-# Persistent data storage
+# Persistant data storage
 TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
 
 # Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
 ##########################################
 
 [anastasis]
-PORT = 8086
+PORT = 8087
 
 DB = postgres
 
@@ -41,13 +41,16 @@ PAYMENT_BACKEND_URL = http://localhost:8080/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
-ANNUAL_FEE = TESTKUDOS:4.99
+ANNUAL_FEE = TESTKUDOS:1.99
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
 #QUESTION_COST = EUR:0
 QUESTION_COST = TESTKUDOS:0
 
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
 # Upload limit
 UPLOAD_LIMIT_MB = 1
 
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
 # wire fees
 [fees-x-taler-bank]
 
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
 # If you see this after 2018, update to match the next 10 years...
 WIRE-FEE-2018 = TESTKUDOS:0.01
 WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_cli.conf 
b/src/cli/test_anastasis_reducer_2.conf
similarity index 98%
copy from src/cli/test_anastasis_cli.conf
copy to src/cli/test_anastasis_reducer_2.conf
index 88891f3..173fd4b 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -1,10 +1,10 @@
 # This file is in the public domain.
 #
 [PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
 TALER_TEST_HOME = test_anastasis_api_home/
 
-# Persistent data storage
+# Persistant data storage
 TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
 
 # Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
 ##########################################
 
 [anastasis]
-PORT = 8086
+PORT = 8088
 
 DB = postgres
 
@@ -48,6 +48,9 @@ ANNUAL_FEE = TESTKUDOS:4.99
 #QUESTION_COST = EUR:0
 QUESTION_COST = TESTKUDOS:0
 
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
 # Upload limit
 UPLOAD_LIMIT_MB = 1
 
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
 # wire fees
 [fees-x-taler-bank]
 
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
 # If you see this after 2018, update to match the next 10 years...
 WIRE-FEE-2018 = TESTKUDOS:0.01
 WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_cli.conf 
b/src/cli/test_anastasis_reducer_3.conf
similarity index 98%
rename from src/cli/test_anastasis_cli.conf
rename to src/cli/test_anastasis_reducer_3.conf
index 88891f3..9a82d0c 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -1,10 +1,10 @@
 # This file is in the public domain.
 #
 [PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
 TALER_TEST_HOME = test_anastasis_api_home/
 
-# Persistent data storage
+# Persistant data storage
 TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
 
 # Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
 ##########################################
 
 [anastasis]
-PORT = 8086
+PORT = 8089
 
 DB = postgres
 
@@ -48,6 +48,9 @@ ANNUAL_FEE = TESTKUDOS:4.99
 #QUESTION_COST = EUR:0
 QUESTION_COST = TESTKUDOS:0
 
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
 # Upload limit
 UPLOAD_LIMIT_MB = 1
 
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
 # wire fees
 [fees-x-taler-bank]
 
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
 # If you see this after 2018, update to match the next 10 years...
 WIRE-FEE-2018 = TESTKUDOS:0.01
 WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_reducer_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
new file mode 100755
index 0000000..fffc87b
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo " "
+echo "Beginning with actual reducer test"
+
+# Test user attributes collection in a backup state
+echo " "
+echo "Test user attributes collection in a backup state"
+./anastasis-reducer -b $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+./anastasis-reducer -a \
+  '{"country": "Switzerland", 
+    "country_code": "ch", 
+    "currency":"TESTKUDOS"}' \
+  select_country $TFILE $SFILE
+./anastasis-reducer -a \
+  '{"identity_attributes": {
+    "full_name": "Max Musterman",
+    "ahv_number": "756.9217.0769.85",
+    "birth_year": 2000 ,
+    "birth_month": 1, 
+    "birth_day": 1}}' \
+  enter_user_attributes $SFILE $TFILE
+
+STATE=`jq -r -e .backup_state < $TFILE`
+if test "$STATE" != "AUTHENTICATIONS_EDITING"
+then
+    exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
+fi
+
+SELECTED_COUNTRY=`jq -r -e .selected_country < $TFILE`
+if test "$SELECTED_COUNTRY" != "ch"
+then
+    exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
+fi
+
+# Test country selection in a recovery state
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_initialize_state.sh 
b/src/cli/test_anastasis_reducer_initialize_state.sh
new file mode 100755
index 0000000..2a730e8
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_initialize_state.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE $CONF
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF=`mktemp test_reducerXXXXXX.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF 2> anastasis-httpd.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # anastasis
+    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    exit_skip "Failed to launch anastasis service"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+
+echo " "
+echo "Test initialization of a backup state"
+./anastasis-reducer -b $SFILE
+
+STATE=`jq -r -e .backup_state < $SFILE`
+if test "$STATE" != "CONTINENT_SELECTING"
+then
+    exit_fail "Expected initial state to be CONTINENT_SELECTING, got $STATE"
+fi
+
+
+echo "Test initialization of a recovery state"
+./anastasis-reducer -r $TFILE
+
+STATE=`jq -r -e .recovery_state < $TFILE`
+if test "$STATE" != "CONTINENT_SELECTING"
+then
+    exit_fail "Expected initial state to be CONTINENT_SELECTING, got $STATE"
+fi
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_select_continent.sh 
b/src/cli/test_anastasis_reducer_select_continent.sh
new file mode 100755
index 0000000..cf0a437
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_select_continent.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE $CONF
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF=`mktemp test_reducerXXXXXX.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF 2> anastasis-httpd.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # anastasis
+    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    exit_skip "Failed to launch anastasis service"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+# Test continent selection in a backup state
+echo " "
+echo "Test continent selection in a backup state"
+./anastasis-reducer -b $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+
+STATE=`jq -r -e .backup_state < $TFILE`
+if test "$STATE" != "COUNTRY_SELECTING"
+then
+    exit_fail "Expected new state to be COUNTRY_SELECTING, got $STATE"
+fi
+
+SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
+if test "$SELECTED_CONTINENT" != "Europe"
+then
+    exit_fail "Expected selected continent to be Europe, got 
$SELECTED_CONTINENT"
+fi
+
+COUNTRIES=`jq -r -e .countries < $TFILE`
+if test "$COUNTRIES" == NULL
+then
+    exit_fail "Expected country array (countries) not to be NULL"
+fi
+
+# Test continent selection in a recovery state
+echo "Test continent selection in a recovery state"
+./anastasis-reducer -r $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+
+STATE=`jq -r -e .recovery_state < $TFILE`
+if test "$STATE" != "COUNTRY_SELECTING"
+then
+    exit_fail "Expected new state to be COUNTRY_SELECTING, got $STATE"
+fi
+
+SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
+if test "$SELECTED_CONTINENT" != "Europe"
+then
+    exit_fail "Expected selected continent to be Europe, got 
$SELECTED_CONTINENT"
+fi
+
+COUNTRIES=`jq -r -e .countries < $TFILE`
+if test "$COUNTRIES" == NULL
+then
+    exit_fail "Expected country array (countries) not to be NULL"
+fi
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_select_country.sh 
b/src/cli/test_anastasis_reducer_select_country.sh
new file mode 100755
index 0000000..ea2049f
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -0,0 +1,177 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE $CONF_1 $CONF_2 $CONF_3 $CONF_4 
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF_1=`mktemp test_reducerXXXXXX_1.conf`
+CONF_2=`mktemp test_reducerXXXXXX_2.conf`
+CONF_3=`mktemp test_reducerXXXXXX_3.conf`
+CONF_4=`mktemp test_reducerXXXXXX_4.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF_1
+cp test_anastasis_reducer_1.conf $CONF_2
+cp test_anastasis_reducer_2.conf $CONF_3
+cp test_anastasis_reducer_3.conf $CONF_4
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
+anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
+anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
+anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # anastasis_01
+    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # anastasis_02
+    wget http://localhost:8087/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # anastasis_03
+    wget http://localhost:8088/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    # anastasis_04
+    wget http://localhost:8089/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    exit_skip "Failed to launch anastasis services"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+# Test country selection in a backup state
+echo " "
+echo "Test country selection in a backup state"
+./anastasis-reducer -b $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+./anastasis-reducer -a \
+  '{"country": "Switzerland", 
+    "country_code": "ch", 
+    "currency":"TESTKUDOS"}' \
+  select_country $TFILE $SFILE
+
+STATE=`jq -r -e .backup_state < $SFILE`
+if test "$STATE" != "USER_ATTRIBUTES_COLLECTING"
+then
+    exit_fail "Expected new state to be USER_ATTRIBUTES_COLLECTING, got $STATE"
+fi
+
+SELECTED_COUNTRY=`jq -r -e .selected_country < $SFILE`
+if test "$SELECTED_COUNTRY" != "ch"
+then
+    exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
+fi
+
+SELECTED_CURRENCY=`jq -r -e .currency < $SFILE`
+if test "$SELECTED_CURRENCY" != "TESTKUDOS"
+then
+    exit_fail "Expected selected currency to be TESTKUDOS, got 
$SELECTED_CURRENCY"
+fi
+
+REQ_ATTRIBUTES=`jq -r -e .required_attributes < $SFILE`
+if test "$REQ_ATTRIBUTES" == NULL
+then
+    exit_fail "Expected required attributes array not to be NULL"
+fi
+
+AUTH_PROVIDERS=`jq -r -e .authentication_providers < $SFILE`
+if test "$AUTH_PROVIDERS" == NULL
+then
+    exit_fail "Expected authentication_providers array not to be NULL"
+fi
+
+# Test country selection in a recovery state
+echo "Test country selection in a recovery state"
+./anastasis-reducer -r $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+./anastasis-reducer -a '{"country": "Switzerland", "country_code": "ch", 
"currency":"TESTKUDOS"}' select_country $TFILE $SFILE
+
+STATE=`jq -r -e .recovery_state < $SFILE`
+if test "$STATE" != "USER_ATTRIBUTES_COLLECTING"
+then
+    exit_fail "Expected new state to be USER_ATTRIBUTES_COLLECTING, got $STATE"
+fi
+
+SELECTED_COUNTRY=`jq -r -e .selected_country < $SFILE`
+if test "$SELECTED_COUNTRY" != "ch"
+then
+    exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
+fi
+
+SELECTED_CURRENCY=`jq -r -e .currency < $SFILE`
+if test "$SELECTED_CURRENCY" != "TESTKUDOS"
+then
+    exit_fail "Expected selected currency to be TESTKUDOS, got 
$SELECTED_CURRENCY"
+fi
+
+REQ_ATTRIBUTES=`jq -r -e .required_attributes < $SFILE`
+if test "$REQ_ATTRIBUTES" == NULL
+then
+    exit_fail "Expected required attributes array not to be NULL"
+fi
+
+AUTH_PROVIDERS=`jq -r -e .authentication_providers < $SFILE`
+if test "$AUTH_PROVIDERS" == NULL
+then
+    exit_fail "Expected authentication_providers array not to be NULL"
+fi
+
+exit 0
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index d7e8050..143c967 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -227,4 +227,18 @@ ANASTASIS_redux_action (const json_t *state,
                         void *cb_cls);
 
 
+/**
+ * Function to return a json error response.
+ *
+ * @param cb callback to give error to
+ * @param cb_cls callback closure
+ * @param ec error code
+ * @param detail error detail
+ */
+void
+ANASTASIS_redux_fail (ANASTASIS_ActionCallback cb,
+                      void *cb_cls,
+                      enum TALER_ErrorCode ec,
+                      const char *detail);
+
 #endif  /* _ANASTASIS_REDUX_H */
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 96d51d3..831f8e1 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -37,25 +37,6 @@ static const char *backup_strings[] = {
 #undef GENERATE_STRING
 
 
-void
-ANASTASIS_redux_fail (ANASTASIS_ActionCallback cb,
-                      void *cb_cls,
-                      enum TALER_ErrorCode ec,
-                      const char *detail)
-{
-  json_t *estate;
-
-  estate = json_pack ("{s:s?, s:I, s:s}",
-                      "detail", detail,
-                      "code", (json_int_t) ec,
-                      "hint", TALER_ErrorCode_get_hint (ec));
-  cb (cb_cls,
-      ec,
-      estate);
-  json_decref (estate);
-}
-
-
 enum ANASTASIS_BackupState
 ANASTASIS_backup_state_from_string (const char *state_string)
 {
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 0eed76d..09c1cf7 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -62,6 +62,25 @@ ANASTASIS_generic_state_to_string (enum 
ANASTASIS_GenericState gs)
 }
 
 
+void
+ANASTASIS_redux_fail (ANASTASIS_ActionCallback cb,
+                      void *cb_cls,
+                      enum TALER_ErrorCode ec,
+                      const char *detail)
+{
+  json_t *estate;
+
+  estate = json_pack ("{s:s?, s:I, s:s}",
+                      "detail", detail,
+                      "code", (json_int_t) ec,
+                      "hint", TALER_ErrorCode_get_hint (ec));
+  cb (cb_cls,
+      ec,
+      estate);
+  json_decref (estate);
+}
+
+
 /**
  * How long do we wait at most for a /config reply from an Anastasis provider.
  * 60s is very generous, given the tiny bandwidth required, even for the most
@@ -513,7 +532,7 @@ validate_ahv (const char *ahv_number,
     {
       num_to_check[7 + i] = ahv_number[9 + i];
     }
-    num_to_check[11] = ahv_number[15];
+    num_to_check[11] = ahv_number[14];
   }
   else
   {
@@ -696,14 +715,10 @@ select_country (json_t *state,
 {
   if (NULL == arguments)
   {
-    json_t *error = json_pack ("{s:I, s:s}",
-                               "code",
-                               (json_int_t) ANASTASIS_EC_INVALID,
-                               "hint",
-                               "Arguments missing!");
-    cb (cb_cls,
-        ANASTASIS_EC_INVALID,
-        error);
+    ANASTASIS_redux_fail (cb,
+                          cb_cls,
+                          TALER_EC_ANASTASIS_REDUCER_ARGUMENTS_MISSING,
+                          "select_country");
     return NULL;
   }
 
@@ -929,14 +944,10 @@ enter_user_attributes (json_t *state,
 {
   if (NULL == arguments)
   {
-    json_t *error = json_pack ("{s:I, s:s}",
-                               "code",
-                               (json_int_t) ANASTASIS_EC_INVALID,
-                               "hint",
-                               "Arguments missing!");
-    cb (cb_cls,
-        ANASTASIS_EC_INVALID,
-        error);
+    ANASTASIS_redux_fail (cb,
+                          cb_cls,
+                          TALER_EC_ANASTASIS_REDUCER_ARGUMENTS_MISSING,
+                          "enter_user_attributes");
     return NULL;
   }
   json_t *attributes = json_object_get (arguments,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]