gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (b43c8f6 -> 7c488d1)


From: gnunet
Subject: [taler-anastasis] branch master updated (b43c8f6 -> 7c488d1)
Date: Tue, 21 Jan 2020 12:29:01 +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 b43c8f6  conflict? this file is generated
     new 4ed17d2  Worked on payment for policy upload
     new 7c488d1  Merge, worked on payment testing (policy upload)

The 2 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.c                      | 20 ++++--
 src/backend/anastasis-httpd_policy_upload.c        | 78 ++++++++++++---------
 src/include/anastasis_crypto_lib.h                 |  2 +-
 src/include/anastasis_service.h                    |  9 +--
 src/include/anastasis_testing_lib.h                | 27 ++++++++
 src/lib/Makefile.am                                |  1 +
 src/lib/anastasis_api_policy_store.c               | 33 ++++++++-
 src/lib/test_anastasis_api.c                       | 44 ++++--------
 src/lib/test_anastasis_api.conf                    | 12 ++--
 src/lib/testing_api_cmd_policy_store.c             | 81 ++++++++++------------
 ...ub.c => testing_api_trait_payment_identifier.c} | 35 +++++-----
 11 files changed, 197 insertions(+), 145 deletions(-)
 copy src/lib/{testing_api_trait_account_pub.c => 
testing_api_trait_payment_identifier.c} (57%)

diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 8d31620..ba4f8f7 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -266,7 +266,6 @@ url_handler (void *cls,
   }
 
   GNUNET_SCHEDULER_begin_async_scope (&aid);
-
   if (NULL != correlation_id)
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Handling request for (%s) URL '%s', correlation_id=%s\n",
@@ -290,11 +289,20 @@ url_handler (void *cls,
     }
     if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
     {
-      return AH_handler_policy_post (connection,
-                                     con_cls,
-                                     url,
-                                     upload_data,
-                                     upload_data_size);
+      int ret;
+      ret = AH_handler_policy_post (connection,
+                                    con_cls,
+                                    url,
+                                    upload_data,
+                                    upload_data_size);
+      hc = *con_cls;
+      if (NULL != hc)
+      {
+        /* Store the async context ID, so we can restore it if
+         * we get another callack for this request. */
+        hc->async_scope_id = aid;
+      }
+      return ret;
     }
   }
   if (0 == strncmp (url,
diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 15b3c05..f6336f8 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -374,7 +374,10 @@ check_payment_cb (void *cls,
   if (NULL != puc->existing_order_id)
   {
     /* repeat payment request */
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Repeating payment request\n");
     puc->resp = make_payment_request (puc->existing_order_id);
+    GNUNET_assert (NULL != puc->resp);
     puc->response_code = MHD_HTTP_PAYMENT_REQUIRED;
     return;
   }
@@ -382,6 +385,7 @@ check_payment_cb (void *cls,
               "Timeout waiting for payment\n");
   puc->resp = TALER_MHD_make_error (TALER_EC_SYNC_PAYMENT_TIMEOUT,
                                     "Timeout awaiting promised payment");
+  GNUNET_assert (NULL != puc->resp);
   puc->response_code = MHD_HTTP_REQUEST_TIMEOUT;
 }
 
@@ -451,11 +455,20 @@ begin_payment (struct PolicyUploadContext *puc,
     return ret;
   }
 
-  // generate new payment identifier
-  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
-                              &puc->payment_identifier,
-                              sizeof (
-                                struct ANASTASIS_PaymentSecretP));
+  if (NULL == puc->order_id)
+  {
+    // 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(
+                                                      struct
+                                                      
ANASTASIS_PaymentSecretP));
+
+  }
 
   if (qs == ANASTASIS_DB_STATUS_NO_RESULTS)
   {
@@ -466,11 +479,16 @@ begin_payment (struct PolicyUploadContext *puc,
                                  GNUNET_TIME_UNIT_ZERO);
   }
 
-  order_id = GNUNET_STRINGS_data_to_string_alloc (&puc->payment_identifier,
-                                                  sizeof(
-                                                    struct
-                                                    ANASTASIS_PaymentSecretP));
-  puc->order_id = order_id;
+  if (NULL != puc->existing_order_id)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Have existing order, waiting for `%s' to complete\n",
+                puc->existing_order_id);
+    await_payment (puc,
+                   GNUNET_TIME_UNIT_ZERO /* no long polling */,
+                   puc->existing_order_id);
+    return MHD_YES;
+  }
 
   GNUNET_CONTAINER_DLL_insert (puc_head,
                                puc_tail,
@@ -479,19 +497,22 @@ begin_payment (struct PolicyUploadContext *puc,
               "Suspending connection while creating order at `%s'\n",
               AH_backend_url);
   MHD_suspend_connection (puc->con);
-  order = json_pack ("{s:o, s:s, s:s}",
+  order = json_pack ("{s:o, s:s, s:s, s:s}",
                      "amount", TALER_JSON_from_amount (&AH_annual_fee),
                      "summary", "annual fee for anastasis service",
                      "fulfillment_url", AH_fulfillment_url,
                      "order_id", order_id);
+
   puc->po = TALER_MERCHANT_order_put (AH_ctx,
                                       AH_backend_url,
                                       order,
                                       &proposal_cb,
                                       puc);
+
+  puc->existing_order_id = order_id;
+
   AH_trigger_curl ();
   json_decref (order);
-  GNUNET_free_non_null (&order_id);
   return MHD_YES;
 }
 
@@ -522,12 +543,9 @@ handle_database_error (struct PolicyUploadContext *puc,
     {
       char *order_id;
 
-      order_id = GNUNET_STRINGS_data_to_string_alloc (&puc->payment_identifier,
-                                                      sizeof (
-                                                        struct
-                                                        
ANASTASIS_PaymentSecretP));
-
-      puc->order_id = order_id;
+      order_id = MHD_lookup_connection_value (puc->con,
+                                              MHD_GET_ARGUMENT_KIND,
+                                              "paying");
 
       if ((NULL == order_id) || GNUNET_is_zero (order_id))
       {
@@ -536,6 +554,7 @@ handle_database_error (struct PolicyUploadContext *puc,
         return begin_payment (puc,
                               GNUNET_NO);
       }
+
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Payment required, awaiting completion of `%s'\n",
                   order_id);
@@ -793,20 +812,21 @@ AH_handler_policy_post (struct MHD_Connection *connection,
         resp = MHD_create_response_from_buffer (0,
                                                 NULL,
                                                 MHD_RESPMEM_PERSISTENT);
-        GNUNET_break (MHD_YES ==
-                      MHD_add_response_header (resp,
-                                               
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                               "*"));
+        TALER_MHD_add_global_headers (resp);
         ret = MHD_queue_response (connection,
                                   MHD_HTTP_NOT_MODIFIED,
                                   resp);
+        (MHD_YES == ret);
         MHD_destroy_response (resp);
         return ret;
       }
+
       if (0 != GNUNET_memcmp (&hc,
                               &puc->old_policy_upload_hash))
       {
         /* Refuse upload: if-none-match failed! */
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    "Conflict detected, returning existing recovery 
document\n");
         return AH_return_policy (connection,
                                  &accountPubP,
                                  MHD_HTTP_CONFLICT);
@@ -814,7 +834,6 @@ AH_handler_policy_post (struct MHD_Connection *connection,
     }
     /* check if the client insists on paying */
     {
-      // FIXME: How should the client show his will to pay?
       const char *order_req;
 
       order_req = MHD_lookup_connection_value (connection,
@@ -897,7 +916,8 @@ AH_handler_policy_post (struct MHD_Connection *connection,
 
     // FIXME: version has to be delivered by header
     uint32_t version;
-
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Uploading recovery document\n");
     qs = db->store_recovery_document (db->cls,
                                       &accountPubP,
                                       &puc->account_sig,
@@ -921,10 +941,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       resp = MHD_create_response_from_buffer (0,
                                               NULL,
                                               MHD_RESPMEM_PERSISTENT);
-      GNUNET_break (MHD_YES ==
-                    MHD_add_response_header (resp,
-                                             
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                             "*"));
+      TALER_MHD_add_global_headers (resp);
       ret = MHD_queue_response (connection,
                                 MHD_HTTP_NOT_MODIFIED,
                                 resp);
@@ -941,10 +958,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
     resp = MHD_create_response_from_buffer (0,
                                             NULL,
                                             MHD_RESPMEM_PERSISTENT);
-    GNUNET_break (MHD_YES ==
-                  MHD_add_response_header (resp,
-                                           
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
-                                           "*"));
+    TALER_MHD_add_global_headers (resp);
     ret = MHD_queue_response (connection,
                               MHD_HTTP_NO_CONTENT,
                               resp);
diff --git a/src/include/anastasis_crypto_lib.h 
b/src/include/anastasis_crypto_lib.h
index aa22b66..f406aa0 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -24,7 +24,7 @@ struct ANASTAIS_CRYPTO_Encrypted_Truth;
 
 struct ANASTASIS_CRYPTO_AccountSignatureP
 {
-  struct GNUNET_CRYPTO_EddsaSignatureP eddsa_sig;
+  struct GNUNET_CRYPTO_EddsaSignature eddsa_sig;
 };
 
 struct ANASTASIS_CRYPTO_KeyShare
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 43644cf..e314bd0 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -206,9 +206,9 @@ struct ANASTASIS_KeyShareDownloadDetails
    */
   const void *encrypted_key_share;
 
-   /**
-     * Number of bytes in truth_data.
-     */
+  /**
+    * Number of bytes in truth_data.
+    */
   size_t encrypted_key_share_size;
 };
 
@@ -432,7 +432,8 @@ struct ANASTASIS_KeyShareLookupOperation;
 typedef void
 (*ANASTASIS_KeyShareLookupCallback) (void *cls,
                                      unsigned int http_status,
-                                     const struct 
ANASTASIS_KeyShareDownloadDetails *kdd);
+                                     const struct
+                                     ANASTASIS_KeyShareDownloadDetails *kdd);
 
 /**
  * Does a GET /truth.
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index a617fb5..dde2b37 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -131,6 +131,33 @@ ANASTASIS_TESTING_make_trait_account_priv (unsigned int 
index,
                                            const struct
                                            ANASTASIS_AccountPrivP *priv);
 
+/**
+ * Obtain an account public key from @a cmd.
+ *
+ * @param cmd command to extract the payment identifier from.
+ * @param index the payment identifier's index number.
+ * @param n[out] set to the payment identifier coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_payment_identifier (const struct
+                                                TALER_TESTING_Command *cmd,
+                                                unsigned int index,
+                                                const struct
+                                                ANASTASIS_PaymentSecretP **
+                                                payment_identifier);
+
+/**
+ * Offer a payment identifier.
+ *
+ * @param index usually zero
+ * @param h the payment identifier to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_payment_identifier (unsigned int index,
+                                                 const struct
+                                                 ANASTASIS_PaymentSecretP *h);
 
 /**
  * Prepare the merchant execution.  Create tables and check if
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d156841..e893b22 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -55,6 +55,7 @@ libanastasistesting_la_SOURCES = \
   testing_api_helpers.c \
   testing_api_trait_account_pub.c \
   testing_api_trait_account_priv.c \
+  testing_api_trait_payment_identifier.c \
   testing_api_trait_hash.c
 libanastasistesting_la_LIBADD = \
   libanastasisrest.la \
diff --git a/src/lib/anastasis_api_policy_store.c 
b/src/lib/anastasis_api_policy_store.c
index 13172f3..b569f7f 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -232,8 +232,18 @@ handle_header (char *buffer,
   if (0 == strcasecmp (hdr_type,
                        "Taler"))
   {
+    size_t len;
+
     /* found payment URI we care about! */
     pso->pay_uri = GNUNET_strdup (hdr_val);
+    len = strlen (pso->pay_uri);
+    while ( (len > 0) &&
+            ( ('\n' == pso->pay_uri[len - 1]) ||
+              ('\r' == pso->pay_uri[len - 1]) ) )
+    {
+      len--;
+      pso->pay_uri[len] = '\0';
+    }
   }
   GNUNET_free (ndup);
   return total;
@@ -282,6 +292,7 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
   usp.purpose.size = htonl (sizeof (usp));
   if (NULL != prev_recovery_data_hash)
     usp.old_recovery_data_hash = *prev_recovery_data_hash;
+
   GNUNET_CRYPTO_hash (recovery_data,
                       recovery_data_size,
                       &usp.new_recovery_data_hash);
@@ -357,7 +368,6 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
       }
       job_headers = ext;
     }
-
     /* Setup Payment-Identifier header */
     if (NULL != paymentSecretP)
     {
@@ -367,6 +377,7 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
                        "Payment-Identifier: %s",
                        val);
       GNUNET_free (val);
+
       ext = curl_slist_append (job_headers,
                                hdr);
       GNUNET_free (hdr);
@@ -397,8 +408,24 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
                      "policy/%s",
                      acc_pub_str);
     GNUNET_free (acc_pub_str);
-    pso->url = TALER_url_join (backend_url,
-                               path);
+
+    pso->url = (GNUNET_YES == payment_requested)
+              ? TALER_url_join (backend_url,
+                                path,
+                                "pay",
+                                "y",
+                                (NULL != paymentSecretP)
+                                ? "paying"
+                                : NULL,
+                                paymentSecretP,
+                                NULL)
+              : TALER_url_join (backend_url,
+                                path,
+                                (NULL != paymentSecretP)
+                                ? "paying"
+                                : NULL,
+                                paymentSecretP,
+                                NULL);
     GNUNET_free (path);
   }
   pso->ctx = ctx;
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 33348ec..1203a6d 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -37,6 +37,7 @@
 #include <taler/taler_error_codes.h>
 #include <taler/taler_merchant_testing_lib.h>
 #include "anastasis_testing_lib.h"
+#include "anastasis_service.h"
 
 /**
  * Configuration file we use.  One (big) configuration is used
@@ -49,11 +50,6 @@
  */
 #define EXCHANGE_URL "http://localhost:8081/";
 
-/**
- * Payment Secret for the test, set to a random value
- */
-static struct ANASTASIS_PaymentSecretP paymentSecret;
-
 /**
  * URL of the fakebank.
  */
@@ -70,24 +66,24 @@ static char *merchant_url;
 static char *anastasis_url;
 
 /**
- * Merchant process.
+ * Exchange base URL.
  */
-static struct GNUNET_OS_Process *merchantd;
+static char *exchange_url;
 
 /**
- * Anastasis process.
+ * Auditor base URL; only used to fix FTBFS.
  */
-static struct GNUNET_OS_Process *anastasisd;
+static char *auditor_url;
 
 /**
- * Exchange base URL.
+ * Merchant process.
  */
-static char *exchange_url;
+static struct GNUNET_OS_Process *merchantd;
 
 /**
- * Auditor base URL; only used to fix FTBFS.
+ * Anastasis process.
  */
-static char *auditor_url;
+static struct GNUNET_OS_Process *anastasisd;
 
 /**
  * Account number of the exchange at the bank.
@@ -224,12 +220,6 @@ static void
 run (void *cls,
      struct TALER_TESTING_Interpreter *is)
 {
-
-  // fill data
-  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
-                              &paymentSecret,
-                              sizeof (paymentSecret));
-
   struct TALER_TESTING_Command pay[] = {
     /**
      * Move money to the exchange's bank account.
@@ -241,14 +231,6 @@ run (void *cls,
      * transfer.
      */
     CMD_EXEC_WIREWATCH ("wirewatch-1"),
-
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-2",
-      EXCHANGE_URL,
-      "EUR:10.02",
-      USER_ACCOUNT_NO,
-      EXCHANGE_ACCOUNT_NO),
-
     TALER_TESTING_cmd_withdraw_amount
       ("withdraw-coin-1",
       "create-reserve-1",
@@ -303,10 +285,10 @@ run (void *cls,
     ANASTASIS_TESTING_cmd_policy_store ("policy-store-2",
                                         anastasis_url,
                                         "policy-store-1",
-                                        MHD_HTTP_OK,
+                                        MHD_HTTP_NO_CONTENT,
                                         ANASTASIS_TESTING_PSO_NONE,
-                                        "Test-2",
-                                        strlen ("Test-2")),
+                                        "Test-1",
+                                        strlen ("Test-1")),
 
     ANASTASIS_TESTING_cmd_policy_lookup ("policy-lookup-1",
                                          anastasis_url,
@@ -363,6 +345,7 @@ main (int argc,
                         (CONFIG_FILE,
                         "account-exchange")))
     return 77;
+
   if (NULL ==
       (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
     return 77;
@@ -384,7 +367,6 @@ main (int argc,
     return 77;
 
   case GNUNET_OK:
-
     if (NULL == (merchantd =
                    TALER_TESTING_run_merchant (CONFIG_FILE, merchant_url)))
       return 1;
diff --git a/src/lib/test_anastasis_api.conf b/src/lib/test_anastasis_api.conf
index 7c5bbf9..c0cf0be 100644
--- a/src/lib/test_anastasis_api.conf
+++ b/src/lib/test_anastasis_api.conf
@@ -2,16 +2,16 @@
 #
 [PATHS]
 # Persistant data storage for the testcase
-TALER_TEST_HOME = test_anastasis_api_home
+TALER_TEST_HOME = test_anastasis_api_home/
 
 # Persistant data storage
-TALER_DATA_HOME = $TALER_HOME/.local/share/taler
+TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
 
 # Configuration files
-TALER_CONFIG_HOME = $TALER_HOME/.config/taler
+TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
 
 # Cached data, no big deal if lost
-TALER_CACHE_HOME = $TALER_HOME/.cache/taler
+TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
 
 [taler]
 # What currency do we use?
@@ -28,7 +28,7 @@ PORT = 8086
 DB = postgres
 
 # Base URL of anastasis.
-BASE_URL = http://localhost:8086/
+# BASE_URL = http://localhost:8086/
 
 # Where does our payment backend run?  Must match PORT under [merchant]
 PAYMENT_BACKEND_URL = http://localhost:8080/
@@ -217,7 +217,7 @@ BASE_URL = "http://localhost:8081/";
 CONFIG = "postgres:///talercheck"
 
 [auditordb-postgres]
-CONFIG = postgres:///talercheck
+CONFIG = "postgres:///talercheck"
 
 # Account of the EXCHANGE
 [account-exchange]
diff --git a/src/lib/testing_api_cmd_policy_store.c 
b/src/lib/testing_api_cmd_policy_store.c
index 64a86b1..606ccbf 100644
--- a/src/lib/testing_api_cmd_policy_store.c
+++ b/src/lib/testing_api_cmd_policy_store.c
@@ -95,7 +95,7 @@ struct PolicyStoreState
   /**
    * Payment identifier.
    */
-  const struct ANASTASIS_PaymentSecretP *payment_id;
+  struct ANASTASIS_PaymentSecretP *payment_id;
 
   /**
    * Previous upload, or NULL for none. Used to calculate what THIS
@@ -143,10 +143,6 @@ policy_store_cb (void *cls,
   pss->pso = NULL;
   if (http_status != pss->http_status)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "\n\n\n HTTP-STATUS 1:  %d\n HTTP-STATUS 2:   %d\n\n\n",
-                http_status,
-                pss->http_status);
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Unexpected response code %u to command %s in %s:%u\n",
                 http_status,
@@ -206,6 +202,7 @@ policy_store_cb (void *cls,
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Order ID from Anastasis service is `%s'\n",
                     pss->payment_order_id);
+
         memset (&pss->curr_hash,
                 0,
                 sizeof (struct GNUNET_HashCode));
@@ -262,7 +259,6 @@ policy_store_run (void *cls,
                   struct TALER_TESTING_Interpreter *is)
 {
   struct PolicyStoreState *pss = cls;
-
   pss->is = is;
   if (NULL != pss->prev_upload)
   {
@@ -319,29 +315,45 @@ policy_store_run (void *cls,
       }
       pss->anastasis_pub = *pub;
     }
-    if (0 != (ANASTASIS_TESTING_PSO_REFERENCE_ORDER_ID & pss->psopt))
     {
-      const char *order_id;
+      const struct ANASTASIS_PaymentSecretP *payment_identifier;
 
       if (GNUNET_OK !=
-          TALER_TESTING_get_trait_order_id (ref,
-                                            0,
-                                            &order_id))
+          ANASTASIS_TESTING_get_trait_payment_identifier (ref,
+                                                          0,
+                                                          &payment_identifier))
       {
         GNUNET_break (0);
         TALER_TESTING_interpreter_fail (pss->is);
         return;
       }
-      pss->payment_order_req = order_id;
-      if (NULL == pss->payment_order_req)
+      pss->payment_id = payment_identifier;
+    }
+    if (0 != (ANASTASIS_TESTING_PSO_REFERENCE_ORDER_ID & pss->psopt))
+    {
       {
-        GNUNET_break (0);
-        TALER_TESTING_interpreter_fail (pss->is);
-        return;
+        const char *order_id;
+
+        if (GNUNET_OK !=
+            TALER_TESTING_get_trait_order_id (ref,
+                                              0,
+                                              &order_id))
+        {
+          GNUNET_break (0);
+          TALER_TESTING_interpreter_fail (pss->is);
+          return;
+        }
+        pss->payment_order_req = order_id;
+        if (NULL == pss->payment_order_req)
+        {
+          GNUNET_break (0);
+          TALER_TESTING_interpreter_fail (pss->is);
+          return;
+        }
       }
     }
   }
-
+  else
   {
     // Create an eddsa private key
     struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
@@ -352,38 +364,19 @@ policy_store_run (void *cls,
                                         &pss->anastasis_pub.pub);
     GNUNET_free (priv);
   }
-  {
+  /*{
     // generate nonce
     GNUNET_CRYPTO_random_block
       (GNUNET_CRYPTO_QUALITY_WEAK,
       &pss->nonce,
       sizeof (pss->nonce));
-  }
+  }*/
   {
     // hash recovery data
     GNUNET_CRYPTO_hash (pss->recovery_data,
                         pss->recovery_data_size,
                         &pss->curr_hash);
   }
-  if (NULL != pss->payment_order_req)
-  {
-    if (! GNUNET_is_zero (pss->payment_order_req))
-    {
-      const char *pay_req;
-      struct ANASTASIS_PaymentSecretP pay_sec;
-
-      pay_req = pss->payment_order_req;
-
-      GNUNET_STRINGS_string_to_data (pay_req,
-                                     strlen (pay_req),
-                                     &pay_sec,
-                                     sizeof (
-                                       struct ANASTASIS_PaymentSecretP));
-      pss->payment_id = &pay_sec;
-      GNUNET_free (&pay_req);
-      GNUNET_free (&pay_sec);
-    }
-  }
   pss->pso = ANASTASIS_policy_store (is->ctx,
                                      pss->anastasis_url,
                                      &pss->anastasis_priv,
@@ -400,9 +393,7 @@ policy_store_run (void *cls,
                                      (0 !=
                                       (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT
                                        & pss->psopt)),
-                                     (NULL != pss->payment_id)
-                                     ? pss->payment_id
-                                     : NULL,
+                                     pss->payment_id,
                                      &policy_store_cb,
                                      pss);
   if (NULL == pss->pso)
@@ -436,7 +427,7 @@ policy_store_cleanup (void *cls,
     pss->pso = NULL;
   }
 
-  // GNUNET_free_non_null ((void *) pss->order_id);
+  GNUNET_free_non_null ((void *) pss->payment_order_id);
   GNUNET_free (pss);
 }
 
@@ -466,6 +457,8 @@ policy_store_traits (void *cls,
                                                &pss->anastasis_priv),
     TALER_TESTING_make_trait_order_id (0,
                                        pss->payment_order_id),
+    ANASTASIS_TESTING_make_trait_payment_identifier (0,
+                                                     &pss->payment_id),
     TALER_TESTING_trait_end ()
   };
 
@@ -484,9 +477,6 @@ policy_store_traits (void *cls,
  *        the policy store request.
  * @param http_status expected HTTP status.
  * @param pso policy store options
- * @param priv private account identifier
- * @param pub account identifier
- * @param payment_id payment identifier
  * @param recovery_data recovery data to post
  * @param recovery_data_size size of recovery/policy data
  * @return the command
@@ -509,6 +499,7 @@ ANASTASIS_TESTING_cmd_policy_store (const char *label,
   pss->http_status = http_status;
   pss->psopt = pso;
   pss->anastasis_url = anastasis_url;
+  pss->prev_upload = prev_upload;
 
   struct TALER_TESTING_Command cmd = {
     .cls = pss,
diff --git a/src/lib/testing_api_trait_account_pub.c 
b/src/lib/testing_api_trait_payment_identifier.c
similarity index 57%
copy from src/lib/testing_api_trait_account_pub.c
copy to src/lib/testing_api_trait_payment_identifier.c
index 60d4b28..5256a79 100644
--- a/src/lib/testing_api_trait_account_pub.c
+++ b/src/lib/testing_api_trait_payment_identifier.c
@@ -17,57 +17,58 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file lib/testing_api_trait_account_pub.c
- * @brief traits to offer a account_pub
- * @author Christian Grothoff
+ * @file lib/testing_api_trait_payment_identifier.c
+ * @brief traits to offer a payment identifier
+ * @author Dennis Neufeld
  */
 #include "platform.h"
 #include "anastasis_service.h"
 #include "anastasis_testing_lib.h"
 
-#define ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB "anastasis-account_pub"
+#define ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER \
+  "anastasis-payment_identifier"
 
 
 /**
  * Obtain an account public key from @a cmd.
  *
- * @param cmd command to extract the public key from.
- * @param index the public key's index number.
- * @param n[out] set to the public key coming from @a cmd.
+ * @param cmd command to extract the payment identifier from.
+ * @param index the payment identifier's index number.
+ * @param n[out] set to the payment identifier coming from @a cmd.
  * @return #GNUNET_OK on success.
  */
 int
-ANASTASIS_TESTING_get_trait_account_pub
+ANASTASIS_TESTING_get_trait_payment_identifier
   (const struct TALER_TESTING_Command *cmd,
   unsigned int index,
-  const struct ANASTASIS_AccountPubP **pub)
+  const struct ANASTASIS_PaymentSecretP **payment_identifier)
 {
   return cmd->traits (cmd->cls,
-                      (const void **) pub,
-                      ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB,
+                      (const void **) payment_identifier,
+                      ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER,
                       index);
 }
 
 
 /**
- * Offer an account public key.
+ * Offer a payment identifier.
  *
  * @param index usually zero
- * @param h the account_pub to offer.
+ * @param h the payment identifier to offer.
  * @return #GNUNET_OK on success.
  */
 struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_pub
+ANASTASIS_TESTING_make_trait_payment_identifier
   (unsigned int index,
-  const struct ANASTASIS_AccountPubP *h)
+  const struct ANASTASIS_PaymentSecretP *h)
 {
   struct TALER_TESTING_Trait ret = {
     .index = index,
-    .trait_name = ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB,
+    .trait_name = ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER,
     .ptr = (const void *) h
   };
   return ret;
 }
 
 
-/* end of testing_api_trait_account_pub.c */
+/* end of testing_api_trait_payment_identifier.c */

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



reply via email to

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