gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (470616c -> 8fb324e)


From: gnunet
Subject: [taler-anastasis] branch master updated (470616c -> 8fb324e)
Date: Tue, 22 Dec 2020 13:30:27 +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 470616c  dlsym the validation logic
     new b90416f  fix ftbs
     new 1d27a82  fix json usage
     new 8fb324e  fix payment details collection, fix callback usage

The 3 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                          |  38 +++---
 src/cli/anastasis-cli-redux.c                  |   4 +
 src/cli/test_anastasis_reducer_enter_secret.sh |  12 +-
 src/lib/Makefile.am                            |   1 +
 src/lib/anastasis.c                            |  13 +-
 src/lib/anastasis_api_backup_redux.c           | 168 ++++++++++++++-----------
 src/lib/anastasis_api_redux.c                  |  11 +-
 7 files changed, 136 insertions(+), 111 deletions(-)

diff --git a/contrib/redux.ch.json b/contrib/redux.ch.json
index 9cfeaec..7e2901e 100644
--- a/contrib/redux.ch.json
+++ b/contrib/redux.ch.json
@@ -1,33 +1,33 @@
 {
     "required_attributes": [
        {
-           "type": "string",
-           "name": "full_name",
-                 "label": "Full name",
-                 "label_i18n":{
-                                               "de_DE":"Vollstaendiger Name",
-                                               "de_CH":"Vollstaendiger Name"
-                                        },
-           "widget": "anastasis_gtk_ia_full_name"
+               "type": "string",
+               "name": "full_name",
+               "label": "Full name",
+               "label_i18n":{
+                       "de_DE":"Vollstaendiger Name",
+                       "de_CH":"Vollstaendiger Name"
+                       },
+               "widget": "anastasis_gtk_ia_full_name"
        },
        {
            "type": "date",
            "name": "birthdate",
-                 "label": "Birthdate",
+               "label": "Birthdate",
            "label_i18n":{"de_CH":"Geburtsdatum"},
            "widget": "anastasis_gtk_ia_birthdate"
        },
        {
-      "type": "string",
-      "name": "ahv_number",
-                 "label": "AHV number",
-                 "label_i18n":{
-                                               "de_DE":"AHV-Nummer",
-                                               "de_CH":"AHV-Nummer"
-                                        },
-           "widget": "anastasis_gtk_ia_ahv",
-            "validation-regex": 
"^(756).[0-9]{4}.[0-9]{4}.[0-9]{2}|(756)[0-9]{10}$",
-            "validation-logic": "CH_AVH_check"
+               "type": "string",
+               "name": "ahv_number",
+               "label": "AHV number",
+               "label_i18n":{
+                       "de_DE":"AHV-Nummer",
+                       "de_CH":"AHV-Nummer"
+                       },
+               "widget": "anastasis_gtk_ia_ahv",
+               "validation-regex": 
"^(756).[0-9]{4}.[0-9]{4}.[0-9]{2}|(756)[0-9]{10}$",
+               "validation-logic": "CH_AVH_check"
        }
        ]
 }
diff --git a/src/cli/anastasis-cli-redux.c b/src/cli/anastasis-cli-redux.c
index acc7f55..d7689c6 100644
--- a/src/cli/anastasis-cli-redux.c
+++ b/src/cli/anastasis-cli-redux.c
@@ -202,6 +202,10 @@ run (void *cls,
               "Starting anastasis-reducer\n");
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
                                  NULL);
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_log_setup ("anastasis-reducer",
+                                   "DEBUG",
+                                   NULL));
   if (b_flag && r_flag)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh 
b/src/cli/test_anastasis_reducer_enter_secret.sh
index 88b5c98..edd283a 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -291,10 +291,10 @@ then
     exit_fail "Expected new state to be POLICIES_PAYING, got $STATE"
 fi
 
-ARRAY_LENGTH=`jq -r -e '.truth_uploads | length' < $TFILE`
-if test $ARRAY_LENGTH -lt 3
+OBJECT_SIZE=`jq -r -e '.truth_uploads | length' < $TFILE`
+if test $OBJECT_SIZE -lt 3
 then
-    exit_fail "Expected truth_uploads array length to be >= 3, got 
$ARRAY_LENGTH"
+    exit_fail "Expected truth_uploads array length to be >= 3, got 
$OBJECT_SIZE"
 fi
 
 echo " "
@@ -321,10 +321,10 @@ taler-wallet-cli --wallet-db=$WALLET_DB run-until-done
 
 echo " "
 echo -e $COLOR$BOLD"Parsing policy uploads for payment-uri"$NORM$NOCOLOR
-ARRAY_LENGTH=`jq -r -e '.recovery_document_uploads | length' < $TFILE`
-for ((INDEX=0; INDEX < $ARRAY_LENGTH; INDEX++))
+OBJECT_SIZE=`jq -r -e '.recovery_document_uploads | length' < $TFILE`
+for ((INDEX=0; INDEX < $OBJECT_SIZE; INDEX++))
 do
-    PAY_URI=`jq -r -e .recovery_document_uploads[$INDEX].pay_url < $TFILE`
+    PAY_URI=`jq --argjson INDEX $INDEX -r -e '[.recovery_document_uploads | 
keys[] as $k | .[$k].pay_url][$INDEX]' < $TFILE`
     echo " "
     echo "[$INDEX] PAY_URI: $PAY_URI"
     # run wallet CLI
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 91e5e1f..cbab0b2 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -122,6 +122,7 @@ libanastasisredux_la_LIBADD = \
   -ltalermerchant \
   -ltalerjson \
   -ljansson \
+  -ldl \
   $(XLIB)
 
 
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 05a9e07..b9f9eb0 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -1459,7 +1459,7 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth 
*truths[],
                    &truth->nonce,
                    sizeof(struct ANASTASIS_CRYPTO_NonceP));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d nocne is %s-%llu b\n", __FILE__, __LINE__,
+                "At %s:%d nonce is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (&nonces[i]),
                 (unsigned long long) sizeof (nonces[i]));
   }
@@ -1701,11 +1701,7 @@ policy_store_cb (void *cls,
                 (int) ec,
                 __FILE__,
                 __LINE__);
-    json_t *error = json_pack ("{s:I, s:s}",
-                               "code",
-                               (json_int_t) ec,
-                               "hint",
-                               "Unexpected response code!");
+
     if (NULL != pss->src)
     {
       pss->src (pss->src_cls,
@@ -2109,6 +2105,11 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
             {
               ss->pss[index_pss]->payment_secret
                 = pds[m].payment_secret;
+              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                          "At %s:%d Payment-Identifier from PD is: %s\n",
+                          __FILE__,
+                          __LINE__,
+                          TALER_B2S (&pds[m].payment_secret));
               break;
             }
           }
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 88e1168..531e165 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -1187,7 +1187,7 @@ done_policy_review (json_t *state,
 /**
  * Check if all uploads have response code 204 or 402.
  *
- * @param uploads json array representing uploads (truth, recovery document)
+ * @param uploads json object representing uploads (truth, recovery document)
  * @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
  */
@@ -1195,21 +1195,19 @@ static bool
 check_uploads (json_t *uploads,
                bool pass)
 {
-  GNUNET_assert (json_is_array (uploads));
-  size_t index;
-  json_t *upload;
+  GNUNET_assert (json_is_object (uploads));
+  const char *key;
+  json_t *value;
 
-  json_array_foreach (uploads, index, upload)
+  json_object_foreach (uploads, key, value)
   {
-    int status = json_integer_value (json_object_get (upload,
+    int status = json_integer_value (json_object_get (value,
                                                       "status"));
-    if (pass && (status != 204))
+    if (pass && (status != MHD_HTTP_NO_CONTENT))
       return false;
-    if ((status != 204) &&
-        (status != 402) )
-    {
+    if ((status != MHD_HTTP_NO_CONTENT) &&
+        (status != MHD_HTTP_PAYMENT_REQUIRED) )
       return false;
-    }
   }
   return true;
 }
@@ -1223,26 +1221,36 @@ check_uploads (json_t *uploads,
  */
 static unsigned int
 initialize_payment_details (json_t *state,
-                            struct ANASTASIS_PaymentDetails *pds)
+                            struct ANASTASIS_PaymentDetails **pds)
 {
-  size_t index;
-  json_t *upload;
+  const char *upload_key;
+  json_t *upload_value;
   json_t *rec_doc_uploads = json_object_get (state,
                                              "recovery_document_uploads");
   unsigned int pds_len = 0;
 
-  if (json_array_size (rec_doc_uploads) > 0)
+  if (json_is_object (rec_doc_uploads))
   {
-    json_array_foreach (rec_doc_uploads, index, upload)
+    json_object_foreach (rec_doc_uploads, upload_key, upload_value)
     {
       struct ANASTASIS_PaymentDetails p_details;
 
       const char *pay_uri = json_string_value (
-        json_object_get (upload,
+        json_object_get (upload_value,
                          "pay_url"));
       const char *provider_url = json_string_value (
-        json_object_get (upload,
+        json_object_get (upload_value,
                          "provider_url"));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d Pay URI is: %s\n",
+                  __FILE__,
+                  __LINE__,
+                  pay_uri);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "At %s:%d Provider URL is: %s\n",
+                  __FILE__,
+                  __LINE__,
+                  provider_url);
       if ((NULL != pay_uri) &&
           (NULL != provider_url))
       {
@@ -1266,10 +1274,9 @@ initialize_payment_details (json_t *state,
           TALER_MERCHANT_parse_pay_uri_free (&pd);
           return 0;
         }
-        TALER_MERCHANT_parse_pay_uri_free (&pd);
         p_details.provider_url = GNUNET_strdup (provider_url);
-
-        GNUNET_array_append (pds,
+        TALER_MERCHANT_parse_pay_uri_free (&pd);
+        GNUNET_array_append (*pds,
                              pds_len,
                              p_details);
       }
@@ -1288,18 +1295,22 @@ static void
 initialize_policies (json_t *state)
 {
   size_t p_index;
+  json_t *rec_doc_uploads;
+  json_t *truth_uploads;
   json_t *json_policy;
-  json_t *json_policies = json_object_get (state,
-                                           "policies");
+  json_t *json_policies;
 
+  json_policies = json_object_get (state,
+                                   "policies");
   GNUNET_assert (json_is_array (json_policies));
-  json_t *truth_uploads = json_object_get (state,
-                                           "truth_uploads");
-
-  GNUNET_assert (json_is_array (truth_uploads));
-  json_t *rec_doc_uploads = json_array ();
-
-  GNUNET_assert (json_is_array (rec_doc_uploads));
+  truth_uploads = json_object_get (state,
+                                   "truth_uploads");
+  GNUNET_assert (json_is_object (truth_uploads));
+  rec_doc_uploads = json_object_get (state,
+                                     "recovery_document_uploads");
+  if (NULL == rec_doc_uploads)
+    rec_doc_uploads = json_object ();
+  GNUNET_assert (json_is_object (rec_doc_uploads));
 
   json_array_foreach (json_policies, p_index, json_policy)
   {
@@ -1314,22 +1325,23 @@ initialize_policies (json_t *state)
                         index,
                         auth_method)
     {
-      size_t tu_index;
-      json_t *tu;
+      const char *tu_key;
+      json_t *tu_value;
       unsigned int auth_method_index = json_integer_value (json_object_get (
                                                              auth_method,
                                                              
"authentication_method"));
-      json_array_foreach (truth_uploads, tu_index, tu)
+      json_object_foreach (truth_uploads, tu_key, tu_value)
       {
         json_t *json_truth
           = json_array_get (json_object_get (state, "truths"),
-                            json_integer_value (
-                              json_object_get (tu, "truth_index")));
+                            atoi (tu_key));
         if (json_integer_value (
               json_object_get (json_truth, "auth_method_index"))
             == auth_method_index)
         {
-          truths[truth_index] = ANASTASIS_truth_from_json (tu);
+          truths[truth_index] = ANASTASIS_truth_from_json (
+            json_object_get (tu_value,
+                             "truth"));
           truth_index++;
           break;
         }
@@ -1337,16 +1349,15 @@ initialize_policies (json_t *state)
       {
         // initialize recovery document uploads array
         bool existing = false;
-        size_t upload_index;
-        json_t *upload;
+        const char *upload_key;
+        json_t *upload_value;
         json_t *provider_id = json_object_get (auth_method,
                                                "provider");
-        if (0 < json_array_size (rec_doc_uploads))
+        if (0 < json_object_size (rec_doc_uploads))
         {
-          json_array_foreach (rec_doc_uploads, upload_index, upload)
+          json_object_foreach (rec_doc_uploads, upload_key, upload_value)
           {
-            if (1 == json_equal (provider_id, json_object_get (upload,
-                                                               "provider")))
+            if (1 == json_equal (provider_id, json_string (upload_key)))
             {
               existing = true;
               break;
@@ -1360,27 +1371,28 @@ initialize_policies (json_t *state)
           const char *provider_url = get_provider_url_from_id (id,
                                                                state);
           GNUNET_assert (0 ==
-                         json_array_append (rec_doc_uploads,
-                                            json_pack ("{s:I, s:s, s:s}",
-                                                       "status",
-                                                       (json_int_t) 0,
-                                                       "provider",
-                                                       id,
-                                                       "provider_url",
-                                                       provider_url)));
+                         json_object_set (rec_doc_uploads,
+                                          id,
+                                          json_pack ("{s:I, s:s}",
+                                                     "status",
+                                                     (json_int_t) 0,
+                                                     "provider_url",
+                                                     provider_url)));
         }
       }
     }
-    GNUNET_assert (0 ==
-                   json_object_set (state,
-                                    "recovery_document_uploads",
-                                    rec_doc_uploads));
 
-    struct ANASTASIS_Policy *policy = ANASTASIS_policy_create (truths,
-                                                               truth_index);
+    if (NULL == json_object_get (state,
+                                 "recovery_document_uploads"))
+      GNUNET_assert (
+        0 == json_object_set (state,
+                              "recovery_document_uploads",
+                              rec_doc_uploads));
+
     GNUNET_array_append (policy_arr,
                          policy_arr_length,
-                         policy);
+                         ANASTASIS_policy_create (truths,
+                                                  truth_index));
   }
 }
 
@@ -1407,28 +1419,29 @@ secret_share_payment_cb (void *cls,
               __FILE__, __LINE__,
               taler_pay_url);
 
-  size_t index;
-  json_t *upload;
+  const char *upload_key;
+  json_t *upload_value;
   struct SecretShareState *sss = cls;
   json_t *rec_doc_uploads = json_object_get (sss->state,
                                              "recovery_document_uploads");
 
-  GNUNET_assert (json_is_array (rec_doc_uploads));
+  GNUNET_assert (json_is_object (rec_doc_uploads));
   sss->sso = NULL;
 
-  json_array_foreach (rec_doc_uploads, index, upload)
+  json_object_foreach (rec_doc_uploads, upload_key, upload_value)
   {
     const char *url = json_string_value (
-      json_object_get (upload,
+      json_object_get (upload_value,
                        "provider_url"));
     if (0 == strcmp (url, server_url))
     {
       GNUNET_assert (0 ==
-                     json_object_set (upload,
+                     json_object_set (upload_value,
                                       "status",
-                                      json_integer ((json_int_t) 402)));
+                                      json_integer (
+                                        (json_int_t) 
MHD_HTTP_PAYMENT_REQUIRED)));
       GNUNET_assert (0 ==
-                     json_object_set (upload,
+                     json_object_set (upload_value,
                                       "pay_url",
                                       json_string (taler_pay_url)));
       break;
@@ -1491,23 +1504,23 @@ secret_share_result_cb (void *cls,
               "At %s:%d we are in SRC\n",
               __FILE__, __LINE__);
 
-  size_t index;
-  json_t *upload;
+  const char *upload_key;
+  json_t *upload_value;
   struct SecretShareState *sss = cls;
   json_t *rec_doc_uploads = json_object_get (sss->state,
                                              "recovery_document_uploads");
 
   sss->sso = NULL;
-  GNUNET_assert (json_is_array (rec_doc_uploads));
-  json_array_foreach (rec_doc_uploads, index, upload)
+  GNUNET_assert (json_is_object (rec_doc_uploads));
+  json_object_foreach (rec_doc_uploads, upload_key, upload_value)
   {
     const char *url = json_string_value (
-      json_object_get (upload,
+      json_object_get (upload_value,
                        "provider_url"));
     if (0 == strcmp (url, server_url))
     {
       GNUNET_assert (0 ==
-                     json_object_set (upload,
+                     json_object_set (upload_value,
                                       "status",
                                       json_integer ((json_int_t) 
http_status)));
       break;
@@ -1533,15 +1546,19 @@ secret_share_result_cb (void *cls,
         set_state (sss->state,
                    ANASTASIS_backup_state_to_string (
                      ANASTASIS_BACKUP_STATE_BACKUP_FINISHED));
+        sss->cb (sss->cb_cls,
+                 ANASTASIS_EC_NONE,
+                 sss->state);
+        sss->cb = NULL;
+        return;
       }
       if (check_uploads (rec_doc_uploads, false))
       {
         sss->cb (sss->cb_cls,
                  ANASTASIS_EC_NONE,
                  sss->state);
-        sss->cb = NULL;
+        return;
       }
-      return;
     }
 
     json_t *error = json_pack ("{s:I, s:s}",
@@ -1642,7 +1659,7 @@ upload_rec_documents (json_t *state,
   }
 
   pds_len = initialize_payment_details (state,
-                                        pds);
+                                        &pds);
 
   sss->state = json_incref (state);
   // FIXME: implement PaymentDetails
@@ -1700,6 +1717,7 @@ truth_upload_cb (void *cls,
                           "enter_secret or pay");
     return;
   }
+  tus->truth = t;
   truth_uploads = json_object_get (tus->state,
                                    "truth_uploads");
   j = ANASTASIS_truth_to_json (tus->truth);
@@ -2092,7 +2110,7 @@ pay_backup (json_t *state,
     json_t *truth_uploads = json_object_get (state,
                                              "truth_uploads");
 
-    GNUNET_assert (json_is_array (truth_uploads));
+    GNUNET_assert (json_is_object (truth_uploads));
     if (check_uploads (truth_uploads, true))
       upload_rec_documents (state,
                             ctx,
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 72809ff..710082b 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -27,6 +27,7 @@
 #include "anastasis_error_codes.h"
 #include <taler/taler_json_lib.h>
 #include "anastasis_api_redux.h"
+#include <dlfcn.h>
 
 
 #define GENERATE_STRING(STRING) #STRING,
@@ -916,8 +917,8 @@ enter_user_attributes (json_t *state,
                                 "identity_attributes");
   GNUNET_assert (NULL != attributes);
 
-  *required_attributes = json_object_get (state,
-                                          "required_attributes");
+  required_attributes = json_object_get (state,
+                                         "required_attributes");
   GNUNET_assert (json_is_array (required_attributes));
   json_array_foreach (required_attributes, index, required_attribute)
   {
@@ -931,10 +932,10 @@ enter_user_attributes (json_t *state,
                                                "name"));
     attribute_value = json_string_value (json_object_get (attributes,
                                                           name));
-    regexp = json_string_value (json_object_get (attribute,
+    regexp = json_string_value (json_object_get (required_attribute,
                                                  "validation-regex"));
     if ( (NULL != regexp) &&
-         (! validate_regex (value,
+         (! validate_regex (attribute_value,
                             regexp)) )
     {
       json_t *error = json_pack (
@@ -950,7 +951,7 @@ enter_user_attributes (json_t *state,
       json_decref (error);
       return NULL;
     }
-    reglog = json_string_value (json_object_get (attribute,
+    reglog = json_string_value (json_object_get (required_attribute,
                                                  "validation-logic"));
     if ( (NULL != reglog) &&
          (NULL != (regfun = dlsym (RTLD_DEFAULT,

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