commit 8b18850523c9a2303c348b2ede777f012f610fda
parent 9a651aeea9cf20233a9488e45ddd11bba5f3ea68
Author: priscilla <priscilla.huang@efrei.net>
Date: Wed, 1 Feb 2023 04:46:35 -0500
update from the file testing
Diffstat:
6 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-webhooks-ID.c b/src/backend/taler-merchant-httpd_private-get-webhooks-ID.c
@@ -72,10 +72,12 @@ TMH_private_get_webhooks_ID (const struct TMH_RequestHandler *rh,
wb.url),
GNUNET_JSON_pack_string ("http_method",
wb.http_method),
- GNUNET_JSON_pack_string ("header_template",
- wb.header_template),
- GNUNET_JSON_pack_string ("body_template",
- wb.body_template));
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("header_template",
+ wb.header_template)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("body_template",
+ wb.body_template)));
GNUNET_free (wb.event_type);
GNUNET_free (wb.url);
GNUNET_free (wb.http_method);
diff --git a/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c b/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c
@@ -116,11 +116,14 @@ TMH_private_patch_webhooks_ID (const struct TMH_RequestHandler *rh,
(const char **) &wb.url),
GNUNET_JSON_spec_string ("http_method",
(const char **) &wb.http_method),
- GNUNET_JSON_spec_string ("header_template",
- (const char **) &wb.header_template),
- GNUNET_JSON_spec_string ("body_template",
- (const char **) &wb.body_template),
-
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("header_template",
+ (const char **) &wb.header_template),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("body_template",
+ (const char **) &wb.body_template),
+ NULL),
GNUNET_JSON_spec_end ()
};
diff --git a/src/backend/taler-merchant-webhook.c b/src/backend/taler-merchant-webhook.c
@@ -170,7 +170,8 @@ handle_webhook_response (void *cls,
qs = db_plugin->delete_pending_webhook (db_plugin->cls,
w->webhook_pending_serial);
- if ((GNUNET_DB_STATUS_HARD_ERROR == qs) ||(GNUNET_DB_STATUS_SOFT_ERROR==qs))
+ /* GNUNET_DB_STATUS_SOFT_ERROR seems impossible */
+ if ((GNUNET_DB_STATUS_HARD_ERROR == qs) ||(GNUNET_DB_STATUS_ONE_RESULT==qs))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed!\n");
@@ -203,7 +204,9 @@ handle_webhook_response (void *cls,
qs = db_plugin->update_pending_webhook (db_plugin->cls,
w->webhook_pending_serial,
GNUNET_TIME_relative_to_absolute (next_attempt));
- if ((GNUNET_DB_STATUS_HARD_ERROR == qs) ||(GNUNET_DB_STATUS_SOFT_ERROR==qs))
+
+ /* GNUNET_DB_STATUS_SOFT_ERROR seems impossible */
+ if ((GNUNET_DB_STATUS_HARD_ERROR == qs) ||(GNUNET_DB_STATUS_ONE_RESULT==qs))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed!\n");
diff --git a/src/testing/testing_api_cmd_get_webhook.c b/src/testing/testing_api_cmd_get_webhook.c
@@ -114,7 +114,7 @@ get_webhook_cb (void *cls,
TALER_TESTING_get_trait_event_type (webhook_cmd,
&expected_event_type))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (event_type,
+ if (0 != strcmp (event_type,
*expected_event_type))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -162,8 +162,11 @@ get_webhook_cb (void *cls,
TALER_TESTING_get_trait_header_template (webhook_cmd,
&expected_header_template))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (header_template,
- *expected_header_template))
+ if ( ( (NULL == header_template) && (NULL != *expected_header_template)) ||
+ ( (NULL != header_template) && (NULL == expected_header_template)) ||
+ ( (NULL != header_template) &&
+ (0 != strcmp (header_template,
+ *expected_header_template)) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"header template does not match\n");
@@ -178,8 +181,11 @@ get_webhook_cb (void *cls,
TALER_TESTING_get_trait_body_template (webhook_cmd,
&expected_body_template))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (body_template,
- *expected_body_template))
+ if ( ( (NULL == body_template) && (NULL != *expected_body_template)) ||
+ ( (NULL != body_template) && (NULL == expected_body_template)) ||
+ ( (NULL != body_template) &&
+ (0 != strcmp (body_template,
+ *expected_body_template)) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"body template does not match\n");
diff --git a/src/testing/testing_api_cmd_patch_webhook.c b/src/testing/testing_api_cmd_patch_webhook.c
@@ -239,8 +239,8 @@ TALER_TESTING_cmd_merchant_patch_webhook (
pis->event_type = event_type;
pis->url = url;
pis->http_method = http_method;
- pis->header_template = header_template;
- pis->body_template = body_template;
+ pis->header_template = (NULL == header_template) ? NULL : header_template;
+ pis->body_template = (NULL == body_template) ? NULL : body_template;
{
struct TALER_TESTING_Command cmd = {
.cls = pis,
diff --git a/src/testing/testing_api_cmd_post_webhooks.c b/src/testing/testing_api_cmd_post_webhooks.c
@@ -240,8 +240,8 @@ TALER_TESTING_cmd_merchant_post_webhooks2 (
wis->event_type = event_type;
wis->url = url;
wis->http_method = http_method;
- wis->header_template = header_template;
- wis->body_template = body_template;
+ wis->header_template = (NULL==header_template) ? NULL : header_template;
+ wis->body_template = (NULL==body_template) ? NULL : body_template;
{
struct TALER_TESTING_Command cmd = {
.cls = wis,