gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 04/06: testing user attributes collection


From: gnunet
Subject: [taler-anastasis] 04/06: testing user attributes collection
Date: Tue, 10 Nov 2020 13:44:51 +0100

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

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

commit 47f6f1440bb8fd46392504922aead875d94b78fc
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Tue Nov 10 12:22:21 2020 +0100

    testing user attributes collection
---
 src/cli/Makefile.am                                |  3 +-
 ...test_anastasis_reducer_enter_user_attributes.sh | 75 ++++++++++++++++++++++
 src/cli/test_anastasis_reducer_select_country.sh   | 12 ++++
 3 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index dd22cfa..3b9533b 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -13,7 +13,8 @@ check_SCRIPTS = \
   test_reducer.sh \
   test_anastasis_reducer_initialize_state.sh \
   test_anastasis_reducer_select_continent.sh \
-  test_anastasis_reducer_select_country.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;
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..cdb22ec
--- /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",
+    "social_security_number": "123456789",
+    "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_select_country.sh 
b/src/cli/test_anastasis_reducer_select_country.sh
index 7091a87..92ca397 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -128,6 +128,12 @@ 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
@@ -158,4 +164,10 @@ 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

-- 
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]