gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 18/22: proposal-lookup 404 Not Found.


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 18/22: proposal-lookup 404 Not Found.
Date: Sat, 17 Mar 2018 01:58:43 +0100

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

marcello pushed a commit to branch master
in repository merchant.

commit aa9699384375813371016dfaf89920e1118d4f4a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Mar 16 16:50:40 2018 +0100

    proposal-lookup 404 Not Found.
---
 src/include/taler_merchant_testing_lib.h |  3 ++-
 src/lib/merchant_api_proposal.c          | 14 ++++--------
 src/lib/test_merchant_api_new.c          |  3 ++-
 src/lib/test_merchant_api_twisted.c      | 14 ++++++++----
 src/lib/testing_api_cmd_proposal.c       | 39 +++++++++++++++++++++++---------
 5 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index c155eb1..c487edb 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -103,7 +103,8 @@ TALER_TESTING_cmd_proposal_lookup
    struct GNUNET_CURL_Context *ctx,
    const char *merchant_url,
    unsigned int http_status,
-   const char *proposal_reference);
+   const char *proposal_reference,
+   const char *order_id);
 
 /**
  * Make a "check payment" test command.
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 688e8ce..a670f8b 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -279,17 +279,11 @@ handle_proposal_lookup_finished (void *cls,
 
   if (MHD_HTTP_OK != response_code)
   {
-    char *s;
-
-    s = json_dumps (json,
-                    JSON_COMPACT);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Proposal lookup failed with HTTP status code %u on input 
`%s'\n",
-                (unsigned int) response_code,
-                s);
-    if (NULL != s)
-      free (s);
-    GNUNET_break_op (0);
+                "Proposal lookup failed with HTTP status code %u\n",
+                (unsigned int) response_code);
+    GNUNET_break (0);
+
     plo->cb (plo->cb_cls,
              response_code,
              json,
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index b2979fa..444636d 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -337,7 +337,8 @@ run (void *cls,
                                        is->ctx,
                                        merchant_url,
                                        MHD_HTTP_OK,
-                                       "create-proposal-2"),
+                                       "create-proposal-2",
+                                       NULL),
 
     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"),
 
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
index 3ee5042..31d0dd8 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -259,7 +259,6 @@ run (void *cls,
     TALER_TESTING_cmd_delete_object ("remove-order-id",
                                      PROXY_MERCHANT_CONFIG_FILE,
                                      "order_id"),
-
     TALER_TESTING_cmd_proposal
       ("create-proposal-3",
        twister_merchant_url,
@@ -280,10 +279,9 @@ run (void *cls,
         \"products\": [ {\"description\":\"ice cream\",\
                          \"value\":\"{EUR:5}\"} ] }",
         NULL),
-
-
     /**
-     * Cause a 404 Not Found response code.
+     * Cause a 404 Not Found response code,
+     * due to a non existing merchant instance.
      */
     TALER_TESTING_cmd_proposal
       ("create-proposal-4",
@@ -294,6 +292,14 @@ run (void *cls,
          \"summary\": \"merchant-lib testcase\"}",
        "non-existent-instance"),
 
+    /* Cause a 404 Not Found from /proposal/lookup,
+     * due to a non existing order id being queried.  */
+    TALER_TESTING_cmd_proposal_lookup ("lookup-0",
+                                       is->ctx,
+                                       twister_merchant_url,
+                                       MHD_HTTP_NOT_FOUND,
+                                       NULL,
+                                       "does-not-exist"),
     /**** Covering /history lib ****/
 
     /**
diff --git a/src/lib/testing_api_cmd_proposal.c 
b/src/lib/testing_api_cmd_proposal.c
index 410f44e..4529e40 100644
--- a/src/lib/testing_api_cmd_proposal.c
+++ b/src/lib/testing_api_cmd_proposal.c
@@ -135,6 +135,8 @@ struct ProposalLookupState
    * Reference to a proposal operation.
    */
   const char *proposal_reference;
+
+  const char *order_id;
 };
 
 /**
@@ -513,24 +515,37 @@ proposal_lookup_run (void *cls,
   const struct TALER_TESTING_Command *proposal_cmd;
   const char *order_id;
   const struct GNUNET_CRYPTO_EddsaPublicKey *nonce;
+  /* Only used if we do NOT use the nonce from traits.  */
+  struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce;
   #define GET_TRAIT_NONCE(cmd,ptr) \
     TALER_TESTING_get_trait_peer_key_pub (cmd, 1, ptr)
 
   pls->is = is;
-  proposal_cmd = TALER_TESTING_interpreter_lookup_command
-    (is, pls->proposal_reference);
 
-  if (NULL == proposal_cmd)
-    TALER_TESTING_FAIL (is);
+  if (NULL != pls->order_id)
+  {
+    order_id = pls->order_id;
+    GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+                                &dummy_nonce,
+                                sizeof (dummy_nonce));
+    nonce = &dummy_nonce;
+  }
+  else
+  {
+    proposal_cmd = TALER_TESTING_interpreter_lookup_command
+      (is, pls->proposal_reference);
 
-  if (GNUNET_OK != GET_TRAIT_NONCE (proposal_cmd,
-                                    &nonce))
-    TALER_TESTING_FAIL (is); 
+    if (NULL == proposal_cmd)
+      TALER_TESTING_FAIL (is);
 
-  if (GNUNET_OK != TALER_TESTING_get_trait_order_id
-      (proposal_cmd, 0, &order_id))
-    TALER_TESTING_FAIL (is);
+    if (GNUNET_OK != GET_TRAIT_NONCE (proposal_cmd,
+                                      &nonce))
+      TALER_TESTING_FAIL (is); 
 
+    if (GNUNET_OK != TALER_TESTING_get_trait_order_id
+        (proposal_cmd, 0, &order_id))
+      TALER_TESTING_FAIL (is);
+  }
   pls->plo = TALER_MERCHANT_proposal_lookup (pls->ctx,
                                              pls->merchant_url,
                                              order_id,
@@ -554,7 +569,8 @@ TALER_TESTING_cmd_proposal_lookup
    struct GNUNET_CURL_Context *ctx,
    const char *merchant_url,
    unsigned int http_status,
-   const char *proposal_reference)
+   const char *proposal_reference,
+   const char *order_id)
 {
   struct ProposalLookupState *pls;
   struct TALER_TESTING_Command cmd;
@@ -564,6 +580,7 @@ TALER_TESTING_cmd_proposal_lookup
   pls->proposal_reference = proposal_reference;
   pls->merchant_url = merchant_url;
   pls->ctx = ctx;
+  pls->order_id = order_id;
 
   cmd.cls = pls;
   cmd.label = label;

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



reply via email to

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