gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (aa804c8 -> eff66d0)


From: gnunet
Subject: [taler-anastasis] branch master updated (aa804c8 -> eff66d0)
Date: Mon, 23 Nov 2020 13:47:29 +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 aa804c8  API test fix
     new edb7bdc  indent
     new e932aec  Merge branch 'master' of ssh://git.taler.net/anastasis
     new b7c042e  Merge branch 'master' of ssh://git.taler.net/anastasis
     new ee84848  Merge branch 'master' of ssh://git.taler.net/anastasis
     new eff66d0  reducer testing

The 5 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:
 src/backend/anastasis-httpd_truth.c                |  16 +++
 src/cli/Makefile.am                                |   5 +-
 .../test_anastasis_reducer_add_authentication.sh   | 116 +++++++++++++++++++++
 .../test_anastasis_reducer_done_authentication.sh  |  64 ++++++++++++
 ...test_anastasis_reducer_enter_user_attributes.sh |  21 ++--
 src/cli/test_anastasis_reducer_select_country.sh   |  15 +--
 6 files changed, 216 insertions(+), 21 deletions(-)
 create mode 100755 src/cli/test_anastasis_reducer_add_authentication.sh
 create mode 100755 src/cli/test_anastasis_reducer_done_authentication.sh

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 25f192e..3c72e33 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -44,63 +44,78 @@ struct GetContext
    * Kept in DLL for shutdown handling while suspended.
    */
   struct GetContext *next;
+
   /**
    * Kept in DLL for shutdown handling while suspended.
    */
   struct GetContext *prev;
+
   /**
    * Connection handle for closing or resuming
    */
   struct MHD_Connection *connection;
+
   /**
    * Reference to the authorization plugin which was loaded
    */
   struct ANASTASIS_AuthorizationPlugin *authorization;
+
   /**
    * Status of the authorization
    */
   struct ANASTASIS_AUTHORIZATION_State *as;
+
   /**
    * Public key of the challenge which is solved.
    */
   struct ANASTASIS_CRYPTO_TruthPublicKeyP truth_public_key;
+
   /**
    * Used while we are awaiting proposal creation.
    */
   struct TALER_MERCHANT_PostOrdersHandle *po;
+
   /**
    * Used while we are waiting payment.
    */
   struct TALER_MERCHANT_OrderMerchantGetHandle *cpo;
+
   /**
    * HTTP response code to use on resume, if non-NULL.
    */
   struct MHD_Response *resp;
+
   /**
    * Order under which the client promised payment, or NULL.
    */
   const char *order_id;
+
   /**
    * Order ID for the client that we found in our database.
    */
   char *existing_order_id;
+
   /**
    * Timestamp of the order in @e existing_order_id. Used to
    * select the most recent unpaid offer.
    */
   struct GNUNET_TIME_Absolute existing_order_timestamp;
+
   /**
    * Payment Identifier
    */
   struct ANASTASIS_PaymentSecretP payment_identifier;
+
   /**
    * HTTP response code to use on resume, if resp is set.
    */
   unsigned int response_code;
+
   /**
    * Whether to generate a claim token.
    */
   bool make_claim_token;
+
   /**
    * The claim token
    */
@@ -110,6 +125,7 @@ struct GetContext
    * true if client provided a payment secret / order ID?
    */
   bool payment_identifier_provided;
+
   /**
    * true if client provided a payment secret / order ID?
    */
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 3b9533b..d1769aa 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -10,11 +10,12 @@ if USE_COVERAGE
 endif
 
 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_enter_user_attributes.sh
+  test_anastasis_reducer_enter_user_attributes.sh \
+  test_anastasis_reducer_add_authentication.sh \
+  test_anastasis_reducer_done_authentication.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_add_authentication.sh 
b/src/cli/test_anastasis_reducer_add_authentication.sh
new file mode 100755
index 0000000..353a460
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_add_authentication.sh
@@ -0,0 +1,116 @@
+#!/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 $UFILE
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+UFILE=test_reducer_stateAESTATE
+# Tempfile used und deleted by other test
+VFILE=test_reducer_stateAESTATE_FINAL
+
+
+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 add authentication in a backup state
+# First method
+echo " "
+echo "Test add authentication in a backup state"
+./anastasis-reducer -a \
+  '{"authentication_method": {
+    "method": "question",
+    "data": {
+      "question": "Whats your name?",
+      "answer": "Hans"
+    }}}' \
+  add_authentication $UFILE $SFILE
+
+STATE=`jq -r -e .backup_state < $SFILE`
+if test "$STATE" != "AUTHENTICATIONS_EDITING"
+then
+    exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
+fi
+
+ARRAY_LENGTH=`jq -r -e '.authentication_methods | length' < $SFILE`
+if test $ARRAY_LENGTH != 1
+then
+    exit_fail "Expected array length to be 1, got $ARRAY_LENGTH"
+fi
+
+#Second method
+./anastasis-reducer -a \
+  '{"authentication_method": {
+    "method": "question",
+    "data": {
+      "question": "How old are you?",
+      "answer": "123"
+    }}}' \
+  add_authentication $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
+
+ARRAY_LENGTH=`jq -r -e '.authentication_methods | length' < $TFILE`
+if test $ARRAY_LENGTH != 2
+then
+    exit_fail "Expected array length to be 2, got $ARRAY_LENGTH"
+fi
+
+#Third method
+touch $VFILE
+./anastasis-reducer -a \
+  '{"authentication_method": {
+    "method": "question",
+    "data": {
+      "question": "Where do you live?",
+      "answer": "Mars"
+    }}}' \
+  add_authentication $TFILE $VFILE
+
+STATE=`jq -r -e .backup_state < $VFILE`
+if test "$STATE" != "AUTHENTICATIONS_EDITING"
+then
+    exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
+fi
+
+ARRAY_LENGTH=`jq -r -e '.authentication_methods | length' < $VFILE`
+if test $ARRAY_LENGTH != 3
+then
+    exit_fail "Expected array length to be 3, got $ARRAY_LENGTH"
+fi
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_done_authentication.sh 
b/src/cli/test_anastasis_reducer_done_authentication.sh
new file mode 100755
index 0000000..eb4e6ec
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_done_authentication.sh
@@ -0,0 +1,64 @@
+#!/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 $UFILE
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+UFILE=test_reducer_stateAESTATE_FINAL
+# Tempfile used und deleted by other test
+VFILE=test_reducer_statePRSTATE
+
+
+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 done authentication in a backup state
+echo " "
+echo "Test done authentication (next) in a backup state"
+touch $VFILE
+./anastasis-reducer -a \
+  '{}' \
+  next $UFILE $VFILE
+
+STATE=`jq -r -e .backup_state < $VFILE`
+if test "$STATE" != "POLICIES_REVIEWING"
+then
+    exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
+fi
+
+ARRAY_LENGTH=`jq -r -e '.policies | length' < $VFILE`
+if test $ARRAY_LENGTH >= 3
+then
+    exit_fail "Expected policy array to be >= 3, got $ARRAY_LENGTH"
+fi
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
index fffc87b..7a85d8e 100755
--- a/src/cli/test_anastasis_reducer_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
@@ -21,13 +21,14 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $SFILE $TFILE
+    rm -f $UFILE
     wait
 }
 
 # Install cleanup handler (except for kill -9)
-SFILE=`mktemp test_reducer_stateXXXXXX`
-TFILE=`mktemp test_reducer_stateXXXXXX`
+UFILE=test_reducer_stateUACSTATE
+# Tempfile used und deleted by other test
+VFILE=test_reducer_stateAESTATE
 
 trap cleanup EXIT
 
@@ -42,13 +43,7 @@ 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
+touch $VFILE
 ./anastasis-reducer -a \
   '{"identity_attributes": {
     "full_name": "Max Musterman",
@@ -56,15 +51,15 @@ echo "Test user attributes collection in a backup state"
     "birth_year": 2000 ,
     "birth_month": 1, 
     "birth_day": 1}}' \
-  enter_user_attributes $SFILE $TFILE
+  enter_user_attributes $UFILE $VFILE
 
-STATE=`jq -r -e .backup_state < $TFILE`
+STATE=`jq -r -e .backup_state < $VFILE`
 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`
+SELECTED_COUNTRY=`jq -r -e .selected_country < $VFILE`
 if test "$SELECTED_COUNTRY" != "ch"
 then
     exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
diff --git a/src/cli/test_anastasis_reducer_select_country.sh 
b/src/cli/test_anastasis_reducer_select_country.sh
index ea2049f..4a060ca 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -32,6 +32,8 @@ CONF_3=`mktemp test_reducerXXXXXX_3.conf`
 CONF_4=`mktemp test_reducerXXXXXX_4.conf`
 SFILE=`mktemp test_reducer_stateXXXXXX`
 TFILE=`mktemp test_reducer_stateXXXXXX`
+# Tempfile used und deleted by other test
+UFILE=test_reducer_stateUACSTATE
 
 trap cleanup EXIT
 
@@ -102,37 +104,38 @@ echo " "
 echo "Test country selection in a backup state"
 ./anastasis-reducer -b $SFILE
 ./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+touch $UFILE
 ./anastasis-reducer -a \
   '{"country": "Switzerland", 
     "country_code": "ch", 
     "currency":"TESTKUDOS"}' \
-  select_country $TFILE $SFILE
+  select_country $TFILE $UFILE
 
-STATE=`jq -r -e .backup_state < $SFILE`
+STATE=`jq -r -e .backup_state < $UFILE`
 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`
+SELECTED_COUNTRY=`jq -r -e .selected_country < $UFILE`
 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`
+SELECTED_CURRENCY=`jq -r -e .currency < $UFILE`
 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`
+REQ_ATTRIBUTES=`jq -r -e .required_attributes < $UFILE`
 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`
+AUTH_PROVIDERS=`jq -r -e .authentication_providers < $UFILE`
 if test "$AUTH_PROVIDERS" == NULL
 then
     exit_fail "Expected authentication_providers array not to be NULL"

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