gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated: [testing] start using traits but th


From: gnunet
Subject: [taler-donau] branch master updated: [testing] start using traits but the charity id from the server is missing
Date: Thu, 07 Mar 2024 00:58:50 +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 6999614  [testing] start using traits but the charity id from the 
server is missing
6999614 is described below

commit 6999614c1ce7a80cff7a0b0b034547868424fa92
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Thu Mar 7 00:59:28 2024 +0100

    [testing] start using traits but the charity id from the server is missing
---
 src/donau/donau-httpd_post-charity.c       |  2 +-
 src/include/donau_service.h                |  2 +-
 src/include/donau_testing_lib.h            |  1 +
 src/lib/donau_api_charity_post.c           |  4 ++++
 src/testing/insert_charity2.json           |  8 -------
 src/testing/test_donau_api.c               |  3 ++-
 src/testing/testing_api_cmd_charity_get.c  | 37 +++++++++++++++++++-----------
 src/testing/testing_api_cmd_charity_post.c |  2 +-
 src/testing/testing_api_cmd_get_donau.c    | 24 +++++++++----------
 9 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/src/donau/donau-httpd_post-charity.c 
b/src/donau/donau-httpd_post-charity.c
index 3651485..8be626e 100644
--- a/src/donau/donau-httpd_post-charity.c
+++ b/src/donau/donau-httpd_post-charity.c
@@ -152,7 +152,7 @@ DH_handler_charity_post (struct DH_RequestContext *rc,
   }
   return TALER_MHD_reply_static (
     rc->connection,
-    MHD_HTTP_NO_CONTENT,
+    MHD_HTTP_CREATED,
     NULL,
     NULL,
     0);
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 5daad40..5a3502d 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -1088,7 +1088,7 @@ struct DONAU_PostCharityResponse
 
     /**
      * Information returned on success, if
-     * @e hr.http_status is #MHD_HTTP_OK
+     * @e hr.http_status is #MHD_HTTP_CREATED
      */
     struct
     {
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
index bc87953..f9cbb76 100644
--- a/src/include/donau_testing_lib.h
+++ b/src/include/donau_testing_lib.h
@@ -63,6 +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 char *charity_reference,
                                const struct DONAU_BearerToken *bearer,
                                unsigned int expected_response_code);
 
diff --git a/src/lib/donau_api_charity_post.c b/src/lib/donau_api_charity_post.c
index c542d89..8fae05b 100644
--- a/src/lib/donau_api_charity_post.c
+++ b/src/lib/donau_api_charity_post.c
@@ -90,7 +90,11 @@ handle_charity_post_finished (void *cls,
   cph->job = NULL;
   switch (response_code)
   {
+  case MHD_HTTP_CREATED:
+    break;
   case MHD_HTTP_NO_CONTENT:
+    pcresp.hr.ec = TALER_JSON_get_error_code (j);
+    pcresp.hr.hint = TALER_JSON_get_error_hint (j);
     break;
   case MHD_HTTP_FORBIDDEN:
     pcresp.hr.ec = TALER_JSON_get_error_code (j);
diff --git a/src/testing/insert_charity2.json b/src/testing/insert_charity2.json
deleted file mode 100644
index ca20a25..0000000
--- a/src/testing/insert_charity2.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "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 5559836..2039edf 100644
--- a/src/testing/test_donau_api.c
+++ b/src/testing/test_donau_api.c
@@ -92,9 +92,10 @@ run (void *cls,
                                                                          
"EUR:0", // receipts_to_date
                                                                          2024, 
// current year
                                                                          
&bearer,
-                                                                         
MHD_HTTP_NO_CONTENT),
+                                                                         
MHD_HTTP_CREATED),
       TALER_TESTING_cmd_charity_get ("get-charity-by-id",
                                                                  8,
+                                                                         
"post-charity",
                                                                          
&bearer,
                                       MHD_HTTP_OK),
          TALER_TESTING_cmd_charities_get ("get-charities",
diff --git a/src/testing/testing_api_cmd_charity_get.c 
b/src/testing/testing_api_cmd_charity_get.c
index 4e6e2f6..ac4ff23 100644
--- a/src/testing/testing_api_cmd_charity_get.c
+++ b/src/testing/testing_api_cmd_charity_get.c
@@ -59,8 +59,12 @@ struct StatusState
    */
   struct TALER_TESTING_Interpreter *is;
 
-};
+  /**
+   * Reference to charity post command.
+   */
+  const char *charity_reference;
 
+};
 
 /**
  * Check that the reserve balance and HTTP response code are
@@ -110,17 +114,23 @@ status_run (void *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;
-//       }
-//  }
+  {
+         const struct TALER_TESTING_Command *charity_post_cmd;
+         const unsigned long long *charity_id;
+
+         charity_post_cmd = TALER_TESTING_interpreter_lookup_command (is,
+                                                                               
                                  ss->charity_reference);
+
+         if (GNUNET_OK !=
+             TALER_TESTING_get_trait_charity_id (charity_post_cmd,
+                         &charity_id))
+         {
+           GNUNET_break (0);
+           TALER_TESTING_interpreter_fail (is);
+           return;
+         }
+         ss->charity_id = (uint64_t) *(charity_id);
+  }
 
   ss->cgh = DONAU_charity_get (
     TALER_TESTING_interpreter_get_context (is),
@@ -159,15 +169,16 @@ status_cleanup (void *cls,
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_charity_get (const char *label,
                                                                const uint64_t 
charity_id,
+                                                               const char 
*charity_reference,
                                                                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;
   ss->charity_id = charity_id;
+  ss->charity_reference = charity_reference;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ss,
diff --git a/src/testing/testing_api_cmd_charity_post.c 
b/src/testing/testing_api_cmd_charity_post.c
index d4b3ce2..7ee6a84 100644
--- a/src/testing/testing_api_cmd_charity_post.c
+++ b/src/testing/testing_api_cmd_charity_post.c
@@ -98,7 +98,7 @@ charity_status_cb (void *cls,
     TALER_TESTING_interpreter_fail (ss->is);
     return;
   }
-  if (MHD_HTTP_OK == gcr->hr.http_status)
+  if (ss->expected_response_code == gcr->hr.http_status)
     ss->charity_id = gcr->details.ok.charity_id;
   TALER_TESTING_interpreter_next (ss->is);
 }
diff --git a/src/testing/testing_api_cmd_get_donau.c 
b/src/testing/testing_api_cmd_get_donau.c
index 728f249..9736b85 100644
--- a/src/testing/testing_api_cmd_get_donau.c
+++ b/src/testing/testing_api_cmd_get_donau.c
@@ -226,19 +226,19 @@ static char *
 get_donau_base_url (
   const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  char *donau_url = "http://localhost:8080/";;
+  char *donau_url; // = "http://localhost:8080/";;
 
-  // if (GNUNET_OK !=
-  //     GNUNET_CONFIGURATION_get_value_string (cfg,
-  //                                            "donau",
-  //                                            "BASE_URL",
-  //                                            &donau_url))
-  // {
-  //   GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-  //                              "donau",
-  //                              "BASE_URL");
-  //   return NULL;
-  // }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "donau",
+                                             "BASE_URL",
+                                             &donau_url))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "donau",
+                               "BASE_URL");
+    return NULL;
+  }
   return donau_url;
 }
 

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