gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (ad50c20 -> 01da612)


From: gnunet
Subject: [taler-anastasis] branch master updated (ad50c20 -> 01da612)
Date: Mon, 07 Dec 2020 20:28:34 +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 ad50c20  new API
     new e30251d  work on rec doc upload
     new fe53da5  Merge branch 'master' of ssh://git.taler.net/anastasis
     new 8b464da  Merge branch 'master' of ssh://git.taler.net/anastasis
     new 0ead261  do not delete test ressources
     new 235bf5a  added return value to ANASTASIS_challenge_answer
     new c0e720e  set cost to zero for testing purposes...
     new ab42bfb  work on secret share
     new 2cb6e2e  work on secret share
     new fea4522  fix
     new 81993eb  fix fail curl fini
     new eb2926b  fix secret_share_payment_cb, fix configs
     new 01da612  Merge branch 'master' of ssh://git.taler.net/anastasis

The 12 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_policy_upload.c        |   4 +-
 src/cli/Makefile.am                                |   3 +-
 src/cli/test_anastasis_reducer.conf                |   7 +-
 src/cli/test_anastasis_reducer_1.conf              |   9 +-
 src/cli/test_anastasis_reducer_2.conf              |   9 +-
 src/cli/test_anastasis_reducer_3.conf              |  11 +-
 .../test_anastasis_reducer_add_authentication.sh   |   9 +-
 .../test_anastasis_reducer_done_authentication.sh  |   8 +-
 .../test_anastasis_reducer_done_policy_review.sh   |   8 +-
 src/cli/test_anastasis_reducer_enter_secret.sh     |  29 ++--
 ...test_anastasis_reducer_enter_user_attributes.sh |   8 +-
 src/cli/test_anastasis_reducer_select_country.sh   |  14 +-
 src/include/anastasis.h                            |  18 ++-
 src/lib/anastasis.c                                | 162 +++++++++++++--------
 src/lib/anastasis_api_backup_redux.c               |  94 +++++++++---
 src/lib/anastasis_api_redux.c                      |   3 +-
 src/lib/testing_cmd_challenge_answer.c             |  29 +++-
 src/lib/testing_cmd_secret_share.c                 |   6 +-
 src/lib/testing_cmd_truth_upload.c                 |  16 +-
 19 files changed, 307 insertions(+), 140 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index f90e60d..4c077ec 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -879,7 +879,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
           if (qs == 0)
           {
             // generate new payment identifier
-            GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+            GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
                                         &puc->payment_identifier,
                                         sizeof (
                                           struct ANASTASIS_PaymentSecretP));
@@ -907,7 +907,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       if (! puc->payment_identifier_provided)
       {
         // generate new payment identifier
-        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
                                     &puc->payment_identifier,
                                     sizeof (
                                       struct ANASTASIS_PaymentSecretP));
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index f9525e2..0eabb1b 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -31,7 +31,8 @@ EXTRA_DIST = \
   test_anastasis_reducer.conf \
   test_anastasis_reducer_1.conf \
   test_anastasis_reducer_2.conf \
-  test_anastasis_reducer_3.conf
+  test_anastasis_reducer_3.conf \
+  test_reducer_home/ressources
 
 anastasis_reducer_SOURCES = \
   anastasis-cli-redux.c
diff --git a/src/cli/test_anastasis_reducer.conf 
b/src/cli/test_anastasis_reducer.conf
index e95b3cd..db12c75 100644
--- a/src/cli/test_anastasis_reducer.conf
+++ b/src/cli/test_anastasis_reducer.conf
@@ -37,11 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
 ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -63,7 +64,7 @@ FILE_COST = TESTKUDOS:1.0
 SERVER_SALT = AUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
+[stasis-postgres]
 CONFIG = postgres:///anastasischeck
 
 ##########################################
@@ -76,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_1.conf 
b/src/cli/test_anastasis_reducer_1.conf
index 502da6b..5270e19 100644
--- a/src/cli/test_anastasis_reducer_1.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -37,11 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
 ANNUAL_FEE = TESTKUDOS:1.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -63,8 +64,8 @@ SUPPORTED_METHODS = question
 SERVER_SALT = BUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck1
 
 ##########################################
 # Configuration for the merchant backend #
@@ -76,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_2.conf 
b/src/cli/test_anastasis_reducer_2.conf
index e6de4d9..b5182a3 100644
--- a/src/cli/test_anastasis_reducer_2.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -37,11 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
 ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -63,8 +64,8 @@ SUPPORTED_METHODS = question
 SERVER_SALT = CUfO1KGOKYIFlFQg
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck2
 
 ##########################################
 # Configuration for the merchant backend #
@@ -76,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_3.conf 
b/src/cli/test_anastasis_reducer_3.conf
index b74f5f0..064fc35 100644
--- a/src/cli/test_anastasis_reducer_3.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -37,11 +37,12 @@ DB = postgres
 # BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
-PAYMENT_BACKEND_URL = http://localhost:8080/
+PAYMENT_BACKEND_URL = http://localhost:9966/
 
 # Annual fee we charge.
 #ANNUAL_FEE = EUR:4.99
-ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = TESTKUDOS:4.99
+ANNUAL_FEE = TESTKUDOS:0
 #ANNUAL_FEE = EUR:0
 
 # Cost of authentication by question
@@ -63,8 +64,8 @@ UPLOAD_LIMIT_MB = 1
 SUPPORTED_METHODS = question
 
 # This specifies which database the postgres backend uses.
-[anastasisdb-postgres]
-CONFIG = postgres:///anastasischeck
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck3
 
 ##########################################
 # Configuration for the merchant backend #
@@ -76,7 +77,7 @@ INSTANCES = default tor
 [merchant]
 
 # Which port do we run the backend on? (HTTP server)
-PORT = 8080
+PORT = 9966
 
 # How quickly do we want the exchange to send us our money?
 # Used only if the frontend does not specify a value.
diff --git a/src/cli/test_anastasis_reducer_add_authentication.sh 
b/src/cli/test_anastasis_reducer_add_authentication.sh
index 353a460..01dc872 100755
--- a/src/cli/test_anastasis_reducer_add_authentication.sh
+++ b/src/cli/test_anastasis_reducer_add_authentication.sh
@@ -21,16 +21,16 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $SFILE $TFILE $UFILE
+    rm -f $SFILE $TFILE
     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
+UFILE=ressources/test_reducer_stateAESTATE
+# Tempfile used by other test
+VFILE=ressources/test_reducer_stateAESTATE_FINAL
 
 
 trap cleanup EXIT
@@ -91,6 +91,7 @@ then
 fi
 
 #Third method
+mkdir -p ressources
 touch $VFILE
 ./anastasis-reducer -a \
   '{"authentication_method": {
diff --git a/src/cli/test_anastasis_reducer_done_authentication.sh 
b/src/cli/test_anastasis_reducer_done_authentication.sh
index a0a693b..10aabf3 100755
--- a/src/cli/test_anastasis_reducer_done_authentication.sh
+++ b/src/cli/test_anastasis_reducer_done_authentication.sh
@@ -21,14 +21,13 @@ function cleanup()
     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
+UFILE=ressources/test_reducer_stateAESTATE_FINAL
+# Tempfile used by other test
+VFILE=ressources/test_reducer_statePRSTATE
 
 
 trap cleanup EXIT
@@ -44,6 +43,7 @@ echo "Beginning with actual reducer test"
 # Test done authentication in a backup state
 echo " "
 echo "Test done authentication (next) in a backup state"
+mkdir -p ressources
 touch $VFILE
 ./anastasis-reducer -a \
   '{}' \
diff --git a/src/cli/test_anastasis_reducer_done_policy_review.sh 
b/src/cli/test_anastasis_reducer_done_policy_review.sh
index ed9ceae..7f463c3 100755
--- a/src/cli/test_anastasis_reducer_done_policy_review.sh
+++ b/src/cli/test_anastasis_reducer_done_policy_review.sh
@@ -21,14 +21,13 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $UFILE
     wait
 }
 
 # Install cleanup handler (except for kill -9)
-UFILE=test_reducer_statePRSTATE
-# Tempfile used und deleted by other test
-VFILE=test_reducer_stateSESTATE
+UFILE=ressources/test_reducer_statePRSTATE
+# Tempfile used by other test
+VFILE=ressources/test_reducer_stateSESTATE
 
 
 trap cleanup EXIT
@@ -44,6 +43,7 @@ echo "Beginning with actual reducer test"
 # Test done policy review in a backup state
 echo " "
 echo "Test done policy review (next) in a backup state"
+mkdir -p ressources
 touch $VFILE
 ./anastasis-reducer -a \
   '{}' \
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index e43c86d..fbca9ff 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -21,7 +21,7 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $SFILE $TFILE $CONF $CONF_1 $CONF_2 $CONF_3 $CONF_4 
+    rm -f $CONF $CONF_1 $CONF_2 $CONF_3 $CONF_4 
     wait
 }
 
@@ -32,8 +32,8 @@ 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=test_reducer_stateSESTATE
-TFILE=`mktemp test_reducer_stateXXXXXX`
+SFILE=ressources/test_reducer_stateSESTATE
+TFILE=ressources/test_reducer_statePPSTATE
 
 trap cleanup EXIT
 
@@ -63,6 +63,9 @@ echo " FOUND"
 # elsewhere
 TALER_DB=talercheck
 ANASTASIS_DB=anastasischeck
+ANASTASIS_DB_1=anastasischeck1
+ANASTASIS_DB_2=anastasischeck2
+ANASTASIS_DB_3=anastasischeck3
 
 # delete existing wallet database
 rm -f $WALLET_DB
@@ -84,6 +87,12 @@ dropdb $TALER_DB >/dev/null 2>/dev/null || true
 createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
 dropdb $ANASTASIS_DB >/dev/null 2>/dev/null || true
 createdb $ANASTASIS_DB || exit_skip "Could not create database $ANASTASIS_DB"
+dropdb $ANASTASIS_DB_1 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_1 || exit_skip "Could not create database 
$ANASTASIS_DB_1"
+dropdb $ANASTASIS_DB_2 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_2 || exit_skip "Could not create database 
$ANASTASIS_DB_2"
+dropdb $ANASTASIS_DB_3 >/dev/null 2>/dev/null || true
+createdb $ANASTASIS_DB_3 || exit_skip "Could not create database 
$ANASTASIS_DB_3"
 
 # obtain key configuration data
 MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
@@ -133,10 +142,10 @@ taler-exchange-wirewatch -c $CONF 2> 
taler-exchange-wirewatch.log &
 taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
 
 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 &
+valgrind anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
+valgrind anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
+valgrind anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
+valgrind anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
 
 # Wait for anastasis service to be available
 for n in `seq 1 50`
@@ -183,15 +192,15 @@ echo "Beginning with actual reducer test"
 # Test enter secret in a backup state
 echo " "
 echo "Test enter secret in a backup state"
+mkdir -p ressources
+touch $TFILE
 ./anastasis-reducer -a \
   '{"secret": "veryhardtoguesssecret",
     "type": "password"}' \
   enter_secret $SFILE $TFILE
 
-wait
-
 STATE=`jq -r -e .backup_state < $TFILE`
-if test "$STATE" != "BACKUP_FINISHED"
+if test "$STATE" != "POLICIES_PAYING"
 then
     exit_fail "Expected new state to be BACKUP_FINISHED, got $STATE"
 fi
diff --git a/src/cli/test_anastasis_reducer_enter_user_attributes.sh 
b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
index 7a85d8e..c29fdf5 100755
--- a/src/cli/test_anastasis_reducer_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_enter_user_attributes.sh
@@ -21,14 +21,13 @@ function cleanup()
     do
         kill $n 2> /dev/null || true
     done
-    rm -f $UFILE
     wait
 }
 
 # Install cleanup handler (except for kill -9)
-UFILE=test_reducer_stateUACSTATE
-# Tempfile used und deleted by other test
-VFILE=test_reducer_stateAESTATE
+UFILE=ressources/test_reducer_stateUACSTATE
+# Tempfile used other test
+VFILE=ressources/test_reducer_stateAESTATE
 
 trap cleanup EXIT
 
@@ -43,6 +42,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"
+mkdir -p ressources
 touch $VFILE
 ./anastasis-reducer -a \
   '{"identity_attributes": {
diff --git a/src/cli/test_anastasis_reducer_select_country.sh 
b/src/cli/test_anastasis_reducer_select_country.sh
index 4a060ca..dfa8593 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -32,8 +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
+# Tempfile used by other test
+UFILE=ressources/test_reducer_stateUACSTATE
 
 trap cleanup EXIT
 
@@ -51,6 +51,9 @@ echo " FOUND"
 # Will be dropped, do NOT use anything that might be used
 # elsewhere
 TARGET_DB=anastasischeck
+TARGET_DB_1=anastasischeck1
+TARGET_DB_2=anastasischeck2
+TARGET_DB_3=anastasischeck3
 
 # Configuration file will be edited, so we create one
 # from the template.
@@ -62,6 +65,12 @@ 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"
+dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
+dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
+dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
 
 # Launch services
 echo "Launching anastasis service"
@@ -104,6 +113,7 @@ echo " "
 echo "Test country selection in a backup state"
 ./anastasis-reducer -b $SFILE
 ./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+mkdir -p ressources
 touch $UFILE
 ./anastasis-reducer -a \
   '{"country": "Switzerland", 
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 705ed89..f65d52b 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -117,6 +117,21 @@ typedef void
                             enum TALER_ErrorCode ec);
 
 
+/**
+ * Handle to a challenge answer operation.
+ */
+struct ANASTASIS_ChallengeAnswerOperation;
+
+/**
+ * Cancel a challenge answer operation.
+ *
+ * @param pso the challenge answer operation to cancel
+ */
+void
+ANASTASIS_challenge_answer_cancel (struct
+                                   ANASTASIS_ChallengeAnswerOperation *cao);
+
+
 /**
  * Challenge answer from the user like input SMS pin. Is referenced to a 
challenge and
  * sends back an AnswerFeedback.
@@ -126,8 +141,9 @@ typedef void
  * @param answer user input instruction defines which input is needed
  * @param af reference to the answerfeedback which is passed back to the user
  * @param af_cls handle for the challenge answer struct
+ * @return handle to an challenge answer operation
  */
-void
+struct ANASTASIS_ChallengeAnswerOperation *
 ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
                             struct ANASTASIS_Challenge *c,
                             const char *answer,
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 6e6ce75..cb2b4a5 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -228,10 +228,12 @@ struct ANASTASIS_Challenge
    * Cost for authentication
    */
   struct TALER_Amount cost;
+
   /**
    * Passes back the payment information for the current challenge
    */
   ANASTASIS_ChallengePaymentCallback cpc;
+
   /**
    * Closure for the payment callback
    */
@@ -241,14 +243,17 @@ struct ANASTASIS_Challenge
    * The /truth GET operation handle.
    */
   struct ANASTASIS_ChallengeRunOperation *cro;
+
   /**
    * Sends back the status and the instructions of the challenge start
    */
   ANASTASIS_ChallengeStartCallback csc;
+
   /**
    * Closure for the Challenge Start
    */
   void *csc_cls;
+
   /**
    * Payment identifier.
    */
@@ -267,6 +272,12 @@ struct ANASTASIS_Challenge
   bool payment_requested;
 };
 
+
+struct ANASTASIS_ChallengeAnswerOperation
+{
+  struct ANASTASIS_Challenge *c;
+};
+
 /**
  * Function called with the results of a #ANASTASIS_keyshare_lookup().
  *
@@ -403,13 +414,34 @@ keyshare_lookup_cb (void *cls,
 }
 
 
+/**
+ * Cancel a challenge answer operation.
+ *
+ * @param pso the challenge answer operation to cancel
+ */
 void
+ANASTASIS_challenge_answer_cancel (struct
+                                   ANASTASIS_ChallengeAnswerOperation *cao)
+{
+  if (NULL != cao->c)
+  {
+    GNUNET_free (cao->c);
+  }
+  GNUNET_free (cao);
+}
+
+
+struct ANASTASIS_ChallengeAnswerOperation *
 ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
                             struct ANASTASIS_Challenge *c,
                             const char *answer_str,
                             ANASTASIS_AnswerFeedback af,
                             void *af_cls)
 {
+  struct ANASTASIS_ChallengeAnswerOperation *cao;
+
+  cao = GNUNET_new (struct ANASTASIS_ChallengeAnswerOperation);
+  cao->c = c;
   c->af = af;
   c->ctx = ctx;
   c->af_cls = af_cls;
@@ -446,6 +478,11 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context 
*ctx,
                                          &keyshare_lookup_cb,
                                          c);
     GNUNET_free (str);
+    if (NULL == c->kslo)
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
   }
   else
   {
@@ -458,7 +495,13 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context 
*ctx,
                                          answer_str,
                                          &keyshare_lookup_cb,
                                          c);
+    if (NULL == c->kslo)
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
   }
+  return cao;
 }
 
 
@@ -590,6 +633,11 @@ ANASTASIS_challenge_start (struct GNUNET_CURL_Context *ctx,
                                     c->payment_requested,
                                     &challenge_run_cb,
                                     c);
+  if (NULL == c->cro)
+  {
+    GNUNET_break (0);
+    return;
+  }
 }
 
 
@@ -881,6 +929,11 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
                                               &policy_lookup_cb,
                                               r,
                                               &version);
+    if (NULL == r->plo)
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
   }
   else
   {
@@ -889,6 +942,11 @@ ANASTASIS_recovery_begin (struct GNUNET_CURL_Context *ctx,
                                       &r->pub_key,
                                       &policy_lookup_cb,
                                       r);
+    if (NULL == r->plo)
+    {
+      GNUNET_break (0);
+      return NULL;
+    }
   }
 
   return r;
@@ -1029,7 +1087,6 @@ truth_store_callback (void *cls,
   struct ANASTASIS_TruthUpload *tu = cls;
   tu->tso = NULL;
 
-  // FIXME
   if (NULL != ud)
   {
     switch (ud->us)
@@ -1217,11 +1274,13 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   if (NULL == truth)
   {
     GNUNET_break (0);
-    return tu;
+    return NULL;
   }
 
   ANASTASIS_CRYPTO_truth_public_key_derive (&t->nonce,
                                             &pub_key);
+  tu->tc = tc;
+  tu->tc_cls = tc_cls;
   tu->tso = ANASTASIS_truth_store (tu->ctx,
                                    t->url,
                                    &pub_key,
@@ -1230,15 +1289,18 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                                    tu->paid_order_id,
                                    &truth_store_callback,
                                    tu);
-  // SETUP TRUTH CALLBACK
-  tu->tc = tc;
-  tu->tc_cls = tc_cls;
+  if (NULL == tu->tso)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   if (NULL != tu->tc)
   {
     tu->tc (tu->tc_cls,
             t);
     tu->tc = NULL;
   }
+
   // FIXME PAYMENT CALLBACK
   return tu;
 }
@@ -1254,7 +1316,7 @@ ANASTASIS_truth_upload_cancel (struct 
ANASTASIS_TruthUpload *tu)
   if (NULL != tu->tso)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "truth lookup aborted");
+                "truth lookup aborted \n");
     ANASTASIS_truth_store_cancel (tu->tso);
     tu->tso = NULL;
   }
@@ -1404,6 +1466,8 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 }
 
 
+struct ANASTASIS_SecretShare;
+
 /**
  * State for a "policy store" CMD.
  */
@@ -1503,13 +1567,7 @@ struct PolicyStoreState
    * reference to SecretShare
    */
   struct ANASTASIS_SecretShare *ss;
-};
 
-/**
-* Defines a recovery document upload process (recovery document consists of 
multiple policies)
-*/
-struct ANASTASIS_SecretShare
-{
   /**
    * Callback which gives back the payment details
    */
@@ -1529,7 +1587,13 @@ struct ANASTASIS_SecretShare
    * Closure for the Result Callback
    */
   void *src_cls;
+};
 
+/**
+* Defines a recovery document upload process (recovery document consists of 
multiple policies)
+*/
+struct ANASTASIS_SecretShare
+{
   /**
    * Closure for the Result Callback
    */
@@ -1564,13 +1628,9 @@ policy_store_cleanup (void *cls)
     pss->pso = NULL;
   }
   if (NULL != pss->recovery_data)
-  {
     GNUNET_free (pss->recovery_data);
-  }
   if (NULL != pss->payment_order_id)
-  {
     GNUNET_free (pss->payment_order_id);
-  }
   GNUNET_free (pss);
 }
 
@@ -1598,15 +1658,14 @@ policy_store_cb (void *cls,
                                (json_int_t) ec,
                                "hint",
                                "Unexpected response code!");
-    if (NULL != pss->ss->src)
+    if (NULL != pss->src)
     {
-      pss->ss->src (pss->ss->src_cls,
-                    &pss->curr_hash,
-                    pss->anastasis_url,
-                    ec,
-                    http_status);
-      pss->ss->src = NULL;
-      policy_store_cleanup (pss);
+      pss->src (pss->src_cls,
+                &pss->curr_hash,
+                pss->anastasis_url,
+                ec,
+                http_status);
+      pss->src = NULL;
     }
     return;
   }
@@ -1666,16 +1725,16 @@ policy_store_cb (void *cls,
         memset (&pss->curr_hash,
                 0,
                 sizeof (struct GNUNET_HashCode));
-        if (NULL != pss->ss->spc)
+        if (NULL != pss->spc)
         {
-          pss->ss->spc (pss->ss->spc_cls,
-                        ud->details.payment_request,
-                        pss->anastasis_url,
-                        ec);
-          pss->ss->spc = NULL;
+          pss->spc (pss->spc_cls,
+                    ud->details.payment_request,
+                    pss->anastasis_url,
+                    ec);
+          pss->spc = NULL;
+          return;
         }
       }
-      return;
     case ANASTASIS_US_CONFLICTING_POLICY:
       GNUNET_break (0);
       return;
@@ -1691,16 +1750,18 @@ policy_store_cb (void *cls,
       GNUNET_break (0);
       return;
     }
-    if (NULL != pss->ss->src)
+    if (NULL != pss->src)
     {
-      pss->ss->src (pss->ss->src_cls,
-                    &pss->curr_hash,
-                    pss->anastasis_url,
-                    ec,
-                    http_status);
-      pss->ss->src = NULL;
+      pss->src (pss->src_cls,
+                &pss->curr_hash,
+                pss->anastasis_url,
+                ec,
+                http_status);
+      pss->src = NULL;
+      return;
     }
   }
+  GNUNET_break (0);
 }
 
 
@@ -1815,7 +1876,6 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
     encrypted_master_keys[policies_len];
   struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[policies_len];
   void *encrypted_core_secret;
-
   // Recovery document contains the array decryption policies and the array 
escrow methods
   json_t *recovery_document;
   size_t recovery_document_size;
@@ -1842,10 +1902,6 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   }
   ss->pss = pss;
   ss->pss_length = pss_length;
-  ss->spc = spc;
-  ss->spc_cls = spc_cls;
-  ss->src = src;
-  ss->src_cls = src_cls;
   ss->ctx = ctx;
 
   for (unsigned int i = 0; i < policies_len; i++)
@@ -2051,6 +2107,11 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
   {
     ss->pss[l]->http_status = MHD_HTTP_NO_CONTENT;
 
+    ss->pss[l]->spc = spc;
+    ss->pss[l]->spc_cls = spc_cls;
+    ss->pss[l]->src = src;
+    ss->pss[l]->src_cls = src_cls;
+
     ANASTASIS_CRYPTO_user_identifier_derive (id_data,
                                              ss->pss[l]->server_salt,
                                              &ss->pss[l]->id);
@@ -2107,18 +2168,5 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
 void
 ANASTASIS_secret_share_cancel (struct ANASTASIS_SecretShare *ss)
 {
-  if (NULL != ss)
-  {
-    if (NULL != ss->pss)
-    {
-      for (unsigned int i = 0; i< ss->pss_length; i++)
-      {
-        if (NULL != ss->pss[i])
-        {
-          GNUNET_free (ss->pss[i]);
-        }
-      }
-    }
-    GNUNET_free (ss);
-  }
+  GNUNET_free (ss);
 }
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 489ee34..04fc979 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -227,6 +227,10 @@ struct SecretShareState
   json_t *state;
 };
 
+/**
+ * Generic container for an action with asynchronous activities.
+ */
+static struct ANASTASIS_ReduxAction *ra;
 
 /**
  * Array of truth upload states.
@@ -1180,13 +1184,15 @@ done_policy_review (json_t *state,
 
 
 /**
- * Check if all uploads passed (status code 204).
+ * Check if all uploads have response code 204 or 402.
  *
  * @param uploads json array representing uploads (truth, recovery document)
- * @return true if all uploads passed, else false
+ * @param pass if true, all response codes must be 204 to return true
+ * @return true if all response codes are 204 or 402, else false
  */
 static bool
-check_uploads (json_t *uploads)
+check_uploads (json_t *uploads,
+               bool pass)
 {
   GNUNET_assert (json_is_array (uploads));
   size_t index;
@@ -1196,7 +1202,10 @@ check_uploads (json_t *uploads)
   {
     int status = json_integer_value (json_object_get (upload,
                                                       "status"));
-    if (status != 204)
+    if (pass && (status != 204))
+      return false;
+    if ((status != 204)&&
+        (status != 402) )
     {
       return false;
     }
@@ -1330,7 +1339,7 @@ secret_share_payment_cb (void *cls,
   {
     const char *url = json_string_value (
       json_object_get (upload,
-                       "backend_url"));
+                       "provider_url"));
     if (0 == strcmp (url, server_url))
     {
       GNUNET_assert (0 ==
@@ -1372,10 +1381,13 @@ secret_share_payment_cb (void *cls,
   set_state (sss->state,
              ANASTASIS_backup_state_to_string (
                ANASTASIS_BACKUP_STATE_POLICIES_PAYING));
-  sss->cb (sss->cb_cls,
-           ANASTASIS_EC_NONE,
-           sss->state);
-  sss->cb = NULL;
+  if (check_uploads (rec_doc_uploads, false))
+  {
+    sss->cb (sss->cb_cls,
+             ANASTASIS_EC_NONE,
+             sss->state);
+    sss->cb = NULL;
+  }
   // FIXME: payment
 }
 
@@ -1406,9 +1418,8 @@ secret_share_result_cb (void *cls,
   json_t *rec_doc_uploads = json_object_get (sss->state,
                                              "recovery_document_uploads");
 
-  GNUNET_assert (json_is_array (rec_doc_uploads));
   sss->sso = NULL;
-
+  GNUNET_assert (json_is_array (rec_doc_uploads));
   json_array_foreach (rec_doc_uploads, index, upload)
   {
     const char *url = json_string_value (
@@ -1436,21 +1447,24 @@ secret_share_result_cb (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d http status is %u\n", __FILE__, __LINE__,
                 http_status);
-
-    if (check_uploads (rec_doc_uploads))
-    {
-      set_state (sss->state,
-                 ANASTASIS_backup_state_to_string (
-                   ANASTASIS_BACKUP_STATE_BACKUP_FINISHED));
-    }
     if (http_status == sss->http_status)
     {
-      sss->cb (sss->cb_cls,
-               ANASTASIS_EC_NONE,
-               sss->state);
-      sss->cb = NULL;
+      if (check_uploads (rec_doc_uploads, true))
+      {
+        set_state (sss->state,
+                   ANASTASIS_backup_state_to_string (
+                     ANASTASIS_BACKUP_STATE_BACKUP_FINISHED));
+      }
+      if (check_uploads (rec_doc_uploads, false))
+      {
+        sss->cb (sss->cb_cls,
+                 ANASTASIS_EC_NONE,
+                 sss->state);
+        sss->cb = NULL;
+      }
       return;
     }
+
     json_t *error = json_pack ("{s:I, s:s}",
                                "code",
                                (json_int_t) ec,
@@ -1466,6 +1480,30 @@ secret_share_result_cb (void *cls,
 }
 
 
+/**
+ * Function to free a #SecretShareState.
+ *
+ * @param cls closure for a #SecretShareState.
+ */
+static void
+free_enter_secret (void *cls)
+{
+  struct SecretShareState *sss = cls;
+  for (unsigned int i = 0; i < tus_arr_length; i++)
+  {
+    if (NULL != tus_arr[i]->tuo)
+    {
+      ANASTASIS_truth_upload_cancel (tus_arr[i]->tuo);
+      tus_arr[i]->tuo = NULL;
+    }
+    GNUNET_free (tus_arr[i]);
+  }
+  ANASTASIS_secret_share_cancel (sss->sso);
+  sss->sso = NULL;
+  GNUNET_free (sss);
+}
+
+
 /**
  * Upload recovery documents.
  *
@@ -1542,6 +1580,11 @@ upload_rec_documents (json_t *state,
     GNUNET_break (0);
     return;
   }
+  {
+    ra = GNUNET_new (struct ANASTASIS_ReduxAction);
+    ra->cleanup_cls = sss;
+    ra->cleanup = free_enter_secret;
+  }
 }
 
 
@@ -1578,7 +1621,7 @@ truth_upload_cb (void *cls,
                                   json_integer ((json_int_t) 204)));
   tus->truth = t;
 
-  if (check_uploads (truth_uploads) &&
+  if (check_uploads (truth_uploads, true) &&
       (json_array_size (
          json_object_get (tus->state, "truths"))
        == (size_t) tus_arr_length))
@@ -1658,6 +1701,9 @@ enter_secret (json_t *state,
               ANASTASIS_ActionCallback cb,
               void *cb_cls)
 {
+  if (NULL != ra)
+    GNUNET_free (ra);
+
   if (NULL == arguments)
   {
     json_t *error = json_pack ("{s:I, s:s}",
@@ -1770,7 +1816,7 @@ enter_secret (json_t *state,
       }
     }
   }
-  return NULL;
+  return ra;
 }
 
 
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 2bbc4f6..69a1895 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -154,7 +154,6 @@ struct ConfigRequest
   json_t *backend_methods;
 
   struct GNUNET_SCHEDULER_Task *tt;
-
 };
 
 
@@ -207,7 +206,7 @@ typedef struct ANASTASIS_ReduxAction *
 
 
 /**
- * Function to free a #ConfigRequest an async operation.
+ * Function to free a #ConfigRequest, an async operation.
  *
  * @param cr state for a "get config" operation
  */
diff --git a/src/lib/testing_cmd_challenge_answer.c 
b/src/lib/testing_cmd_challenge_answer.c
index 4abca36..3f7baa2 100644
--- a/src/lib/testing_cmd_challenge_answer.c
+++ b/src/lib/testing_cmd_challenge_answer.c
@@ -66,6 +66,11 @@ struct ChallengeState
    * 0 for no plugin needed 1 for plugin needed to authenticate
    */
   unsigned int mode;
+
+  /**
+   * Handle for an challenge answer operation
+   */
+  struct ANASTASIS_ChallengeAnswerOperation *cao;
 };
 
 
@@ -145,11 +150,17 @@ challenge_answer_run (void *cls,
     cs->answer = code;
   }
 
-  ANASTASIS_challenge_answer (is->ctx,
-                              (struct ANASTASIS_Challenge *) c,
-                              cs->answer,
-                              &challenge_answer_cb,
-                              cs);
+  cs->cao = ANASTASIS_challenge_answer (is->ctx,
+                                        (struct ANASTASIS_Challenge *) c,
+                                        cs->answer,
+                                        &challenge_answer_cb,
+                                        cs);
+  if (NULL == cs->cao)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (cs->is);
+    return;
+  }
 }
 
 
@@ -165,6 +176,14 @@ challenge_answer_cleanup (void *cls,
                           const struct TALER_TESTING_Command *cmd)
 {
   struct ChallengeState *cs = cls;
+  if (NULL != cs->cao)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Command '%s' did not complete (challenge answer)\n",
+                cmd->label);
+    ANASTASIS_challenge_answer_cancel (cs->cao);
+    cs->cao = NULL;
+  }
   GNUNET_free (cs);
 }
 
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
index 6669821..253efcd 100644
--- a/src/lib/testing_cmd_secret_share.c
+++ b/src/lib/testing_cmd_secret_share.c
@@ -403,7 +403,11 @@ secret_share_cleanup (void *cls,
   }
   if (NULL != sss->sso)
   {
-    GNUNET_free (sss->sso);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Command '%s' did not complete\n",
+                cmd->label);
+    ANASTASIS_secret_share_cancel (sss->sso);
+    sss->sso = NULL;
   }
   json_decref ((json_t *) sss->id_data);
   GNUNET_free (sss);
diff --git a/src/lib/testing_cmd_truth_upload.c 
b/src/lib/testing_cmd_truth_upload.c
index 792a7b0..c5665c2 100644
--- a/src/lib/testing_cmd_truth_upload.c
+++ b/src/lib/testing_cmd_truth_upload.c
@@ -150,7 +150,18 @@ truth_payment_cb (void *cls,
   struct TruthUploadState *tus = cls;
   tus->tuo = NULL;
   // FIXME: Payment handling
-  return;
+  if (NULL == taler_pay_url)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Errorcode /%d in command %s in %s:%u\n",
+                (int) ec,
+                tus->is->commands[tus->is->ip].label,
+                __FILE__,
+                __LINE__);
+    TALER_TESTING_interpreter_fail (tus->is);
+    return;
+  }
+  TALER_TESTING_interpreter_next (tus->is);
 }
 
 
@@ -216,7 +227,6 @@ truth_upload_run (void *cls,
   {
     GNUNET_break (0);
     TALER_TESTING_interpreter_fail (tus->is);
-    return;
   }
 }
 
@@ -247,7 +257,7 @@ truth_upload_cleanup (void *cls,
     json_decref ((json_t *) tus->id_data);
   if (NULL != tus->truth)
   {
-    GNUNET_free (tus->truth);
+    ANASTASIS_truth_free (tus->truth);
   }
   GNUNET_free (tus);
 }

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