gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: extend client and testing libs t


From: gnunet
Subject: [taler-merchant] branch master updated: extend client and testing libs to support setting authentication tokens (#6731)
Date: Tue, 02 Feb 2021 12:20:45 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 96726fd5 extend client and testing libs to support setting 
authentication tokens (#6731)
96726fd5 is described below

commit 96726fd5ab6dc067af4957c3d1826f9fd2745c95
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Feb 2 12:20:43 2021 +0100

    extend client and testing libs to support setting authentication tokens 
(#6731)
---
 src/backend/taler-merchant-httpd.c           |  2 +-
 src/include/taler_merchant_service.h         | 25 ++++++++++++++++---------
 src/include/taler_merchant_testing_lib.h     |  4 ++++
 src/lib/merchant_api_patch_instance.c        |  5 ++++-
 src/lib/merchant_api_post_instances.c        |  8 ++++++--
 src/testing/test_merchant_api.c              |  3 +++
 src/testing/testing_api_cmd_patch_instance.c |  8 ++++++++
 src/testing/testing_api_cmd_post_instances.c |  9 +++++++++
 8 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index f33d4346..4290668d 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2014-2020 Taler Systems SA
+  (C) 2014-2021 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index f7a8d667..9937750b 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -503,6 +503,7 @@ typedef void
  * @param default_max_deposit_fee default maximum deposit fee merchant is 
willing to pay
  * @param default_wire_transfer_delay default wire transfer delay merchant 
will ask for
  * @param default_pay_delay default validity period for offers merchant makes
+ * @param auth_token authorization token needed to access the instance, can be 
NULL
  * @param cb function to call with the
  *        backend's instances information
  * @param cb_cls closure for @a config_cb
@@ -523,6 +524,7 @@ TALER_MERCHANT_instances_post (
   const struct TALER_Amount *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   TALER_MERCHANT_InstancesPostCallback cb,
   void *cb_cls);
 
@@ -572,6 +574,7 @@ typedef void
  * @param default_max_deposit_fee default maximum deposit fee merchant is 
willing to pay
  * @param default_wire_transfer_delay default wire transfer delay merchant 
will ask for
  * @param default_pay_delay default validity period for offers merchant makes
+ * @param auth_token authorization token needed to access the instance, can be 
NULL
  * @param cb function to call with the
  *        backend's instances information
  * @param cb_cls closure for @a config_cb
@@ -592,6 +595,7 @@ TALER_MERCHANT_instance_patch (
   const struct TALER_Amount *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   TALER_MERCHANT_InstancePatchCallback cb,
   void *cb_cls);
 
@@ -1244,14 +1248,16 @@ struct TALER_MERCHANT_PostOrdersReply
    * Details of the reply, depending on the HTTP
    * status code.
    */
-  union {
+  union
+  {
 
     /**
      * Details provided if the @e hr.http_status is
      * #MHD_HTTP_OK and the order was created.
      */
-    struct {
-      
+    struct
+    {
+
       /**
        * order id of the newly created order
        */
@@ -1262,14 +1268,15 @@ struct TALER_MERCHANT_PostOrdersReply
        * (NULL if it was NOT generated).
        */
       const struct TALER_ClaimTokenP *token;
-      
+
     } ok;
 
     /**
      * Details provided if the @e hr.http_status is
      * #MHD_HTTP_GONE because a product was out of stock.
-     */    
-    struct {
+     */
+    struct
+    {
       /**
        * ID of the product of the order that is out of
        * stock.
@@ -1291,11 +1298,11 @@ struct TALER_MERCHANT_PostOrdersReply
        * restocked? 0 for unknown.
        */
       struct GNUNET_TIME_Absolute restock_expected;
-      
+
     } gone;
-    
+
   } details;
-  
+
 };
 
 
diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index 8cd23d9d..c1f8d4dc 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -137,6 +137,7 @@ TALER_TESTING_cmd_merchant_post_instances (const char 
*label,
  * @param default_max_deposit_fee default maximum deposit fee merchant is 
willing to pay
  * @param default_wire_transfer_delay default wire transfer delay merchant 
will ask for
  * @param default_pay_delay default validity period for offers merchant makes
+ * @param auth_token authorization token needed to access the instance, can be 
NULL
  * @param http_status expected HTTP response code.
  * @return the command.
  */
@@ -155,6 +156,7 @@ TALER_TESTING_cmd_merchant_post_instances2 (
   const char *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   unsigned int http_status);
 
 
@@ -175,6 +177,7 @@ TALER_TESTING_cmd_merchant_post_instances2 (
  * @param default_max_deposit_fee default maximum deposit fee merchant is 
willing to pay
  * @param default_wire_transfer_delay default wire transfer delay merchant 
will ask for
  * @param default_pay_delay default validity period for offers merchant makes
+ * @param auth_token authorization token needed to access the instance, can be 
NULL
  * @param http_status expected HTTP response code.
  * @return the command.
  */
@@ -193,6 +196,7 @@ TALER_TESTING_cmd_merchant_patch_instance (
   const char *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   unsigned int http_status);
 
 
diff --git a/src/lib/merchant_api_patch_instance.c 
b/src/lib/merchant_api_patch_instance.c
index 7e38b23b..721f8dd1 100644
--- a/src/lib/merchant_api_patch_instance.c
+++ b/src/lib/merchant_api_patch_instance.c
@@ -164,6 +164,7 @@ TALER_MERCHANT_instance_patch (
   const struct TALER_Amount *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   TALER_MERCHANT_InstancePatchCallback cb,
   void *cb_cls)
 {
@@ -188,8 +189,10 @@ TALER_MERCHANT_instance_patch (
       return NULL;
     }
   }
-  req_obj = json_pack ("{s:o, s:s, s:O, s:O"
+  req_obj = json_pack ("{s:s?, s:o, s:s, s:O, s:O"
                        " s:o, s:I: s:o, s:o, s:o}",
+                       "auth_token",
+                       auth_token,
                        "payto_uris",
                        jpayto_uris,
                        "name",
diff --git a/src/lib/merchant_api_post_instances.c 
b/src/lib/merchant_api_post_instances.c
index 1d52f053..a21b9b55 100644
--- a/src/lib/merchant_api_post_instances.c
+++ b/src/lib/merchant_api_post_instances.c
@@ -166,6 +166,7 @@ TALER_MERCHANT_instances_post (
   const struct TALER_Amount *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   TALER_MERCHANT_InstancesPostCallback cb,
   void *cb_cls)
 {
@@ -191,7 +192,8 @@ TALER_MERCHANT_instances_post (
     }
   }
   req_obj = json_pack ("{s:o, s:s, s:s, s:O, s:O"
-                       " s:o, s:I: s:o, s:o, s:o}",
+                       ",s:o, s:I: s:o, s:o, s:o"
+                       ",s:s?}",
                        "payto_uris",
                        jpayto_uris,
                        "id",
@@ -212,7 +214,9 @@ TALER_MERCHANT_instances_post (
                        "default_wire_transfer_delay",
                        GNUNET_JSON_from_time_rel (default_wire_transfer_delay),
                        "default_pay_delay",
-                       GNUNET_JSON_from_time_rel (default_pay_delay));
+                       GNUNET_JSON_from_time_rel (default_pay_delay),
+                       "auth_token",
+                       auth_token);
   if (NULL == req_obj)
   {
     GNUNET_break (0);
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 57241524..9a69f121 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -1181,6 +1181,7 @@ run (void *cls,
                                                "USD:0.5",
                                                GNUNET_TIME_UNIT_MINUTES,
                                                GNUNET_TIME_UNIT_MINUTES,
+                                               NULL,
                                                MHD_HTTP_CONFLICT),
     TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1",
                                                merchant_url,
@@ -1199,6 +1200,7 @@ run (void *cls,
                                                "EUR:0.5",
                                                GNUNET_TIME_UNIT_MINUTES,
                                                GNUNET_TIME_UNIT_MINUTES,
+                                               NULL,
                                                MHD_HTTP_NO_CONTENT),
     TALER_TESTING_cmd_merchant_get_instance2 ("instances-get-i1-2",
                                               merchant_url,
@@ -1227,6 +1229,7 @@ run (void *cls,
       "EUR:0.5",
       GNUNET_TIME_UNIT_MINUTES,
       GNUNET_TIME_UNIT_MINUTES,
+      NULL,
       MHD_HTTP_NO_CONTENT),
     TALER_TESTING_cmd_merchant_get_instance2 ("instances-get-i1-3",
                                               merchant_url,
diff --git a/src/testing/testing_api_cmd_patch_instance.c 
b/src/testing/testing_api_cmd_patch_instance.c
index 3a93b543..2248c1ac 100644
--- a/src/testing/testing_api_cmd_patch_instance.c
+++ b/src/testing/testing_api_cmd_patch_instance.c
@@ -79,6 +79,11 @@ struct PatchInstanceState
    */
   json_t *jurisdiction;
 
+  /**
+   * Authentication token to require, can be NULL.
+   */
+  const char *auth_token;
+
   /**
    * Wire fee to use.
    */
@@ -177,6 +182,7 @@ patch_instance_run (void *cls,
                                             &pis->default_max_deposit_fee,
                                             pis->default_wire_transfer_delay,
                                             pis->default_pay_delay,
+                                            pis->auth_token,
                                             &patch_instance_cb,
                                             pis);
   GNUNET_assert (NULL != pis->iph);
@@ -279,6 +285,7 @@ TALER_TESTING_cmd_merchant_patch_instance (
   const char *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   unsigned int http_status)
 {
   struct PatchInstanceState *pis;
@@ -305,6 +312,7 @@ TALER_TESTING_cmd_merchant_patch_instance (
                                          &pis->default_max_deposit_fee));
   pis->default_wire_transfer_delay = default_wire_transfer_delay;
   pis->default_pay_delay = default_pay_delay;
+  pis->auth_token = auth_token;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = pis,
diff --git a/src/testing/testing_api_cmd_post_instances.c 
b/src/testing/testing_api_cmd_post_instances.c
index 17b654f2..acd623b6 100644
--- a/src/testing/testing_api_cmd_post_instances.c
+++ b/src/testing/testing_api_cmd_post_instances.c
@@ -79,6 +79,11 @@ struct PostInstancesState
    */
   json_t *jurisdiction;
 
+  /**
+   * Authentication token to require for this instance.
+   */
+  const char *auth_token;
+
   /**
    * Wire fee to use.
    */
@@ -180,6 +185,7 @@ post_instances_run (void *cls,
                                             &pis->default_max_deposit_fee,
                                             pis->default_wire_transfer_delay,
                                             pis->default_pay_delay,
+                                            pis->auth_token,
                                             &post_instances_cb,
                                             pis);
   GNUNET_assert (NULL != pis->iph);
@@ -282,6 +288,7 @@ TALER_TESTING_cmd_merchant_post_instances2 (
   const char *default_max_deposit_fee,
   struct GNUNET_TIME_Relative default_wire_transfer_delay,
   struct GNUNET_TIME_Relative default_pay_delay,
+  const char *auth_token,
   unsigned int http_status)
 {
   struct PostInstancesState *pis;
@@ -308,6 +315,7 @@ TALER_TESTING_cmd_merchant_post_instances2 (
                                          &pis->default_max_deposit_fee));
   pis->default_wire_transfer_delay = default_wire_transfer_delay;
   pis->default_pay_delay = default_pay_delay;
+  pis->auth_token = auth_token;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = pis,
@@ -356,6 +364,7 @@ TALER_TESTING_cmd_merchant_post_instances (const char 
*label,
     default_max_fee_s,
     GNUNET_TIME_UNIT_ZERO, /* no wire transfer delay */
     GNUNET_TIME_UNIT_MINUTES,
+    NULL,
     http_status);
 }
 

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