gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: [testing][lib] make bearer token co


From: gnunet
Subject: [taler-donau] branch master updated: [testing][lib] make bearer token const & finish charity post
Date: Wed, 06 Mar 2024 18:37:31 +0100

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

lukas-matyja pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new 5cf2adf  [testing][lib] make bearer token const & finish charity post
5cf2adf is described below

commit 5cf2adf773da81ef517d519ddf5b645732d8ddfc
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Wed Mar 6 18:38:11 2024 +0100

    [testing][lib] make bearer token const & finish charity post
---
 src/include/donau_service.h                  | 10 +++++-----
 src/include/donau_testing_lib.h              | 19 ++++++++++---------
 src/lib/donau_api_charities_get.c            |  2 +-
 src/lib/donau_api_charity_delete.c           |  2 +-
 src/lib/donau_api_charity_get.c              |  2 +-
 src/lib/donau_api_charity_post.c             |  6 +++---
 src/testing/insert_charity2.json             |  8 ++++++++
 src/testing/test_donau_api.c                 | 19 +++++++++----------
 src/testing/testing_api_cmd_charities_get.c  |  6 ++++--
 src/testing/testing_api_cmd_charity_delete.c |  6 +++---
 src/testing/testing_api_cmd_charity_get.c    | 16 ++++++++++++++--
 src/testing/testing_api_cmd_charity_post.c   |  8 ++++----
 12 files changed, 63 insertions(+), 41 deletions(-)

diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index cfba4f4..5daad40 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -880,7 +880,7 @@ struct DONAU_CharitiesGetHandle *
 DONAU_charities_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_GetCharitiesResponseCallback cb,
   void *cb_cls);
 
@@ -1009,7 +1009,7 @@ DONAU_charity_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls);
 
@@ -1141,7 +1141,7 @@ DONAU_charity_post (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   struct DONAU_CharityRequest *charity_req,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_PostCharityResponseCallback cb,
   void *cb_cls);
 
@@ -1213,7 +1213,7 @@ DONAU_charity_patch (
   const char *url,
   const uint64_t id,
   const struct DONAU_CharityRequest *charity_req,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_PatchCharityResponseCallback cb,
   void *cb_cls);
 
@@ -1285,7 +1285,7 @@ DONAU_charity_delete (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_DeleteCharityResponseCallback cb,
   void *cb_cls);
 
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
index 12ea840..bc87953 100644
--- a/src/include/donau_testing_lib.h
+++ b/src/include/donau_testing_lib.h
@@ -28,6 +28,7 @@
 #ifndef DONAU_TESTING_LIB_H
 #define DONAU_TESTING_LIB_H
 
+#include <stdint.h>
 #include <taler/taler_testing_lib.h>
 #include "donau_service.h"
 
@@ -62,7 +63,7 @@ TALER_TESTING_cmd_get_donau (
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_get (const char *label,
                                const uint64_t charity_id,
-                               const struct DONAU_BearerToken bearer,
+                               const struct DONAU_BearerToken *bearer,
                                unsigned int expected_response_code);
 
 /**
@@ -76,19 +77,18 @@ TALER_TESTING_cmd_charity_get (const char *label,
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_post (const char *label,
-                                char charity_pub[256 / 8],
-                                char *name,
-                                char *url,
-                                char *max_per_year,
-                                char *receipts_to_date,
+                                const char *name,
+                                const char *url,
+                                const char *max_per_year,
+                                const char *receipts_to_date,
                                 uint64_t current_year,
-                                const struct DONAU_BearerToken bearer,
+                                const struct DONAU_BearerToken *bearer,
                                 unsigned int expected_response_code);
 
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_delete (const char *label,
                                   const uint64_t charity_id,
-                                  const struct DONAU_BearerToken bearer,
+                                  const struct DONAU_BearerToken *bearer,
                                   unsigned int expected_response_code);
 
 /**
@@ -100,6 +100,7 @@ TALER_TESTING_cmd_charity_delete (const char *label,
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charities_get (const char *label,
+                                 const struct DONAU_BearerToken *bearer,
                                  unsigned int expected_response_code);
 
 /**
@@ -144,7 +145,7 @@ TALER_TESTING_get_donau_url (
         op (charity_pub, const struct DONAU_CharityPublicKeyP)        \
         op (charity_id, const unsigned long long)        \
         op (donau_url, const char)                                             
   \
-        op (donau_keys, struct  DONAU_Keys)
+        op (donau_keys, struct DONAU_Keys)
 
 
 /**
diff --git a/src/lib/donau_api_charities_get.c 
b/src/lib/donau_api_charities_get.c
index 96e7e15..b75efb3 100644
--- a/src/lib/donau_api_charities_get.c
+++ b/src/lib/donau_api_charities_get.c
@@ -199,7 +199,7 @@ struct DONAU_CharitiesGetHandle *
 DONAU_charities_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
-  const struct DONAU_BearerToken bearer, // TODO: check authorization
+  const struct DONAU_BearerToken *bearer, // TODO: check authorization
   DONAU_GetCharitiesResponseCallback cb,
   void *cb_cls)
 {
diff --git a/src/lib/donau_api_charity_delete.c 
b/src/lib/donau_api_charity_delete.c
index ae9f633..367a0c1 100644
--- a/src/lib/donau_api_charity_delete.c
+++ b/src/lib/donau_api_charity_delete.c
@@ -151,7 +151,7 @@ DONAU_charity_delete (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_DeleteCharityResponseCallback cb,
   void *cb_cls)
 {
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charity_get.c
index 006c8e5..fd9c7d6 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charity_get.c
@@ -197,7 +197,7 @@ DONAU_charity_get (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   const uint64_t id,
-  const struct DONAU_BearerToken bearer, // TODO: check authorization
+  const struct DONAU_BearerToken *bearer, // TODO: check authorization
   DONAU_GetCharityResponseCallback cb,
   void *cb_cls)
 {
diff --git a/src/lib/donau_api_charity_post.c b/src/lib/donau_api_charity_post.c
index 49bb5a3..c542d89 100644
--- a/src/lib/donau_api_charity_post.c
+++ b/src/lib/donau_api_charity_post.c
@@ -131,7 +131,7 @@ DONAU_charity_post (
   struct GNUNET_CURL_Context *ctx,
   const char *url,
   struct DONAU_CharityRequest *charity_req, // make it const
-  const struct DONAU_BearerToken bearer,
+  const struct DONAU_BearerToken *bearer,
   DONAU_PostCharityResponseCallback cb,
   void *cb_cls)
 {
@@ -162,9 +162,9 @@ DONAU_charity_post (
   body = GNUNET_JSON_PACK (
              GNUNET_JSON_pack_data_auto ("charity_pub",
                                          &charity_req->charity_pub),
-             GNUNET_JSON_pack_string ("url",
+             GNUNET_JSON_pack_string ("charity_url",
                                                                 
charity_req->charity_url),
-             GNUNET_JSON_pack_string ("name",
+             GNUNET_JSON_pack_string ("charity_name",
                                                           charity_req->name),
              TALER_JSON_pack_amount ("max_per_year",
                                      &charity_req->max_per_year),
diff --git a/src/testing/insert_charity2.json b/src/testing/insert_charity2.json
new file mode 100644
index 0000000..ca20a25
--- /dev/null
+++ b/src/testing/insert_charity2.json
@@ -0,0 +1,8 @@
+{
+  "charity_pub": "ZT1SK8C3B1RZBN19TF8GJ1AJNF4GVP9MH64R9E1K6RMTMYYY17Z0",
+  "charity_name": "example",
+  "charity_url": "example.com",
+  "max_per_year": "EUR:10",
+  "receipts_to_date":"EUR:0",
+  "current_year": 2024
+}
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
index c944c19..5559836 100644
--- a/src/testing/test_donau_api.c
+++ b/src/testing/test_donau_api.c
@@ -64,8 +64,9 @@ static void
 run (void *cls,
      struct TALER_TESTING_Interpreter *is)
 {
-       struct DONAU_BearerToken bearer;
-       bearer.token = NULL;
+       const struct DONAU_BearerToken bearer = {
+                       .token = NULL
+       };
 //     struct DONAU_CharityRequest charity_req = {
 //       .charity_pub = 
{{"EBETNXT9ZF606FRF3WD5N6G2XVD5QHDP2PTQD4GSX4VEN2YYG2C0"}},
 //       .name = "example",
@@ -85,26 +86,24 @@ run (void *cls,
 //                                      true,
 //                                      true),
          TALER_TESTING_cmd_charity_post ("post-charity",
-                                                                         
"EBETNXT9ZF606FRF3WD5N6G2XVD5QHDP2PTQD4GSX4VEN2YYG2C0",
                                                                          
"example",
                                                                          
"example.com",
                                                                          
"EUR:10", // max_per_year
                                                                          
"EUR:0", // receipts_to_date
                                                                          2024, 
// current year
-                                                                         
bearer,
+                                                                         
&bearer,
                                                                          
MHD_HTTP_NO_CONTENT),
       TALER_TESTING_cmd_charity_get ("get-charity-by-id",
-                                                                 5,
-                                                                         
bearer,
+                                                                 8,
+                                                                         
&bearer,
                                       MHD_HTTP_OK),
          TALER_TESTING_cmd_charities_get ("get-charities",
+                                                                         
&bearer,
                                                                          
MHD_HTTP_OK),
 //       TALER_TESTING_cmd_charity_delete("delete-charity",
-//                                                                       5,
-//                                                                       
bearer,
+//                                                                       8,
+//                                                                       
&bearer,
 //                                                                       
MHD_HTTP_NO_CONTENT),
-
-         //TODO: test POST charity, DELETE charity
       /* End the suite. */
       TALER_TESTING_cmd_end ()
     };
diff --git a/src/testing/testing_api_cmd_charities_get.c 
b/src/testing/testing_api_cmd_charities_get.c
index 78e2bea..d4aa1f7 100644
--- a/src/testing/testing_api_cmd_charities_get.c
+++ b/src/testing/testing_api_cmd_charities_get.c
@@ -41,7 +41,7 @@ struct StatusState
   /**
    * The bearer token for authorization.
    */
-  struct DONAU_BearerToken bearer;
+  const struct DONAU_BearerToken *bearer;
 
   /**
    * Expected HTTP response code.
@@ -138,12 +138,14 @@ status_cleanup (void *cls,
 
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charities_get (const char *label,
-                                unsigned int expected_response_code)
+                                                                const struct 
DONAU_BearerToken *bearer,
+                                 unsigned int expected_response_code)
 {
   struct StatusState *ss;
 
   ss = GNUNET_new (struct StatusState);
   ss->expected_response_code = expected_response_code;
+  ss->bearer = bearer;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ss,
diff --git a/src/testing/testing_api_cmd_charity_delete.c 
b/src/testing/testing_api_cmd_charity_delete.c
index 4d59b0b..229d6e2 100644
--- a/src/testing/testing_api_cmd_charity_delete.c
+++ b/src/testing/testing_api_cmd_charity_delete.c
@@ -41,7 +41,7 @@ struct StatusState
   /**
    * The bearer token for authorization.
    */
-  struct DONAU_BearerToken bearer;
+  const struct DONAU_BearerToken *bearer;
 
   /**
    * The ID of the requested charity.
@@ -146,8 +146,8 @@ status_cleanup (void *cls,
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_delete (const char *label,
                                                                const uint64_t 
charity_id,
-                                                               const struct 
DONAU_BearerToken bearer,
-                                unsigned int expected_response_code)
+                                                               const struct 
DONAU_BearerToken *bearer,
+                unsigned int expected_response_code)
 {
   struct StatusState *ss;
 
diff --git a/src/testing/testing_api_cmd_charity_get.c 
b/src/testing/testing_api_cmd_charity_get.c
index 7ea3183..4e6e2f6 100644
--- a/src/testing/testing_api_cmd_charity_get.c
+++ b/src/testing/testing_api_cmd_charity_get.c
@@ -42,7 +42,7 @@ struct StatusState
   /**
    * The bearer token for authorization.
    */
-  struct DONAU_BearerToken bearer;
+  const struct DONAU_BearerToken *bearer;
 
   /**
    * The ID of the requested charity.
@@ -109,6 +109,18 @@ status_run (void *cls,
   struct StatusState *ss = cls;
 
   ss->is = is;
+  /* Get charity id from trait */
+//  {
+//       const unsigned long long *charity_id;
+//       if (GNUNET_OK !=
+//           TALER_TESTING_get_trait_charity_id (cmd,
+//                       &charity_id))
+//       {
+//         GNUNET_break (0);
+//         TALER_TESTING_interpreter_fail (is);
+//         return;
+//       }
+//  }
 
   ss->cgh = DONAU_charity_get (
     TALER_TESTING_interpreter_get_context (is),
@@ -147,7 +159,7 @@ status_cleanup (void *cls,
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_get (const char *label,
                                                                const uint64_t 
charity_id,
-                                                               const struct 
DONAU_BearerToken bearer,
+                                                               const struct 
DONAU_BearerToken *bearer,
                                 unsigned int expected_response_code)
 {
   struct StatusState *ss;
diff --git a/src/testing/testing_api_cmd_charity_post.c 
b/src/testing/testing_api_cmd_charity_post.c
index 70d6dc2..d4b3ce2 100644
--- a/src/testing/testing_api_cmd_charity_post.c
+++ b/src/testing/testing_api_cmd_charity_post.c
@@ -51,7 +51,7 @@ struct StatusState
   /**
    * The bearer token for authorization.
    */
-  struct DONAU_BearerToken bearer;
+  const struct DONAU_BearerToken *bearer;
 
   /**
    * Expected HTTP response code.
@@ -138,7 +138,7 @@ status_run (void *cls,
  * @param cmd the command which is being cleaned up.
  */
 static void
-status_cleanup (void *cls,
+cleanup (void *cls,
                 const struct TALER_TESTING_Command *cmd)
 {
   struct StatusState *ss = cls;
@@ -227,13 +227,13 @@ TALER_TESTING_cmd_charity_post (const char *label,
   }
   ss->charity_req.current_year = current_year;
   ss->expected_response_code = expected_response_code;
-  ss->bearer = *bearer;
+  ss->bearer = bearer;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ss,
       .label = label,
       .run = &status_run,
-      .cleanup = &status_cleanup,
+      .cleanup = &cleanup,
       .traits = &charity_post_traits
     };
 

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