gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: fixed policy-store-2 test


From: gnunet
Subject: [taler-anastasis] 01/02: fixed policy-store-2 test
Date: Tue, 07 Apr 2020 22:24:48 +0200

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

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

commit 749b0ca3e9afd8897e8f921f9c0402658f7b4d7e
Author: Dennis Neufeld <address@hidden>
AuthorDate: Tue Apr 7 14:43:09 2020 +0000

    fixed policy-store-2 test
---
 src/backend/anastasis-httpd_policy_upload.c | 77 +++++++++++++++++------------
 src/lib/anastasis_api_policy_store.c        |  2 +-
 src/lib/testing_api_cmd_policy_store.c      |  1 -
 src/stasis/plugin_anastasis_postgres.c      |  3 ++
 4 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 5395b7e..378899e 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -277,7 +277,7 @@ proposal_cb (void *cls,
 {
   struct PolicyUploadContext *puc = cls;
   enum ANASTASIS_DB_QueryStatus qs;
-  unsigned int post_counter;
+  uint32_t post_counter;
 
   puc->po = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -315,10 +315,13 @@ proposal_cb (void *cls,
               "Storing payment request for order `%s'\n",
               order_id);
 
-  post_counter = amount_to_post_counter (&AH_annual_fee);
+  post_counter = (uint32_t) amount_to_post_counter (&AH_annual_fee);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Post counter to save: %i\n",
               post_counter);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Payment-Identifier to be saved to db: %s\n",
+              TALER_B2S (&puc->payment_identifier));
   qs = db->record_payment (db->cls,
                            &puc->account,
                            post_counter,
@@ -416,7 +419,7 @@ check_payment_cb (void *cls,
     qs = db->increment_lifetime (db->cls,
                                  &puc->account,
                                  &puc->payment_identifier,
-                                 GNUNET_TIME_UNIT_YEARS); /* always annual ?*/
+                                 GNUNET_TIME_UNIT_YEARS); /* FIXME: always 
annual ?*/
     if (0 <= qs)
       return; /* continue as planned */
     GNUNET_break (0);
@@ -520,11 +523,6 @@ begin_payment (struct PolicyUploadContext *puc,
                    puc->existing_order_id);
     return MHD_YES;
   }
-  // generate new payment identifier
-  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
-                              &puc->payment_identifier,
-                              sizeof (
-                                struct ANASTASIS_PaymentSecretP));
 
   order_id = GNUNET_STRINGS_data_to_string_alloc (&puc->payment_identifier,
                                                   sizeof(
@@ -588,6 +586,18 @@ handle_database_error (struct PolicyUploadContext *puc,
 
       if (NULL == order_id)
       {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Payment-Identifier generated (before): %s\n",
+                    TALER_B2S (&puc->payment_identifier));
+        // generate new payment identifier
+        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+                                    &puc->payment_identifier,
+                                    sizeof (
+                                      struct ANASTASIS_PaymentSecretP));
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "Payment-Identifier generated: %s\n",
+                    TALER_B2S (&puc->payment_identifier));
+
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Payment required, starting payment process\n");
         return begin_payment (puc,
@@ -734,30 +744,6 @@ AH_handler_policy_post (struct MHD_Connection *connection,
                                            "If-Match does not include a 
base32-encoded SHA-512 hash");
       }
     }
-    {
-      // Check if header contains Payment-Identifier
-      const char *pay_id;
-
-      pay_id = MHD_lookup_connection_value (connection,
-                                            MHD_HEADER_KIND,
-                                            "Payment-Identifier");
-
-      if ( (NULL != pay_id) &&
-           (GNUNET_OK !=
-            GNUNET_STRINGS_string_to_data (pay_id,
-                                           strlen (pay_id),
-                                           &puc->payment_identifier,
-                                           sizeof (struct
-                                                   ANASTASIS_PaymentSecretP))) 
)
-      {
-        GNUNET_break_op (0);
-        return TALER_MHD_reply_with_error (connection,
-                                           MHD_HTTP_BAD_REQUEST,
-                                           // FIXME: find error code
-                                           TALER_EC_SYNC_BAD_IF_MATCH,
-                                           "Payment-Identifier does not 
include a base32-encoded Payment-Identifier");
-      }
-    }
     {
       // Check if header contains Anastasis-Policy-Signature
       const char *sig_s;
@@ -886,6 +872,33 @@ AH_handler_policy_post (struct MHD_Connection *connection,
                 "Upload starting\n");
     return MHD_YES;
   }
+  {
+    // Check if header contains Payment-Identifier
+    const char *pay_id;
+
+    pay_id = MHD_lookup_connection_value (connection,
+                                          MHD_HEADER_KIND,
+                                          "Payment-Identifier");
+    if ( (NULL != pay_id) &&
+         (GNUNET_OK !=
+          GNUNET_STRINGS_string_to_data (pay_id,
+                                         strlen (pay_id),
+                                         &puc->payment_identifier,
+                                         sizeof (struct
+                                                 ANASTASIS_PaymentSecretP))) )
+    {
+      GNUNET_break_op (0);
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_BAD_REQUEST,
+                                         // FIXME: find error code
+                                         TALER_EC_SYNC_BAD_IF_MATCH,
+                                         "Payment-Identifier does not include 
a base32-encoded Payment-Identifier");
+    }
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Payment-Identifier from header: %s\n",
+                TALER_B2S (&puc->payment_identifier));
+  }
+
   /* handle upload */
   if (0 != *recovery_data_size)
   {
diff --git a/src/lib/anastasis_api_policy_store.c 
b/src/lib/anastasis_api_policy_store.c
index 14fee26..e34d3d9 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -265,7 +265,7 @@ handle_header (char *buffer,
  * @param recovery_data policy data to be stored
  * @param recovery_data_size number of bytes in @a recovery_data
  * @param payment_requested #GNUNET_YES if the client wants to pay more for 
the account now
- * @param paymentSecretP payment identifier of last payment
+ * @param paid_order_id payment identifier of last payment
  * @param cb callback processing the response from /policy
  * @param cb_cls closure for cb
  * @return handle for the operation
diff --git a/src/lib/testing_api_cmd_policy_store.c 
b/src/lib/testing_api_cmd_policy_store.c
index fa737c2..2cdfbe9 100644
--- a/src/lib/testing_api_cmd_policy_store.c
+++ b/src/lib/testing_api_cmd_policy_store.c
@@ -316,7 +316,6 @@ policy_store_run (void *cls,
       }
       pss->anastasis_pub = *pub;
     }
-    if (0 != (ANASTASIS_TESTING_PSO_REFERENCE_ORDER_ID & pss->psopt))
     {
       const char *order_id;
       if (GNUNET_OK !=
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index c45ab4c..1884619 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -504,6 +504,9 @@ postgres_store_recovery_document (void *cls,
   }
 
   // lookup if the user has enough uploads left and decrement
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Payment-Identifier to query db: %s\n",
+              TALER_B2S (payment_secret));
   {
     struct GNUNET_PQ_QueryParam params[] = {
       GNUNET_PQ_query_param_auto_from_type (anastasis_pub),

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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