diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-05-11 19:19:22 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-05-11 19:19:22 +0200 |
commit | 906e3035a6fc8941f3a72c13ae3908b4e7f687b1 (patch) | |
tree | 8fbcfd9f0a4249ec727f7bb69b9994ca53a9b707 | |
parent | 5463f26b493405db1010576fb489e7fd98a47724 (diff) | |
download | merchant-906e3035a6fc8941f3a72c13ae3908b4e7f687b1.tar.gz merchant-906e3035a6fc8941f3a72c13ae3908b4e7f687b1.tar.bz2 merchant-906e3035a6fc8941f3a72c13ae3908b4e7f687b1.zip |
fix #6861, maybe #6854
22 files changed, 167 insertions, 42 deletions
diff --git a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c index 2ec8193a..da56cda2 100644 --- a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c +++ b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c @@ -46,11 +46,31 @@ forget (void *cls, json_t *parent) { int *res = cls; + int ret; - if (GNUNET_OK != - TALER_JSON_contract_part_forget (parent, - object_id)) + ret = TALER_JSON_contract_part_forget (parent, + object_id); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Matching path `%s' not forgettable!\n", + object_id); *res = GNUNET_SYSERR; + } + if (GNUNET_NO == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Matching path `%s' already forgotten!\n", + object_id); + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Forgot `%s'\n", + object_id); + if (GNUNET_NO == *res) + *res = GNUNET_OK; + } } @@ -75,6 +95,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, { json_t *fields; json_t *contract_terms; + bool changed = false; if (GNUNET_OK != TMH_db->start (TMH_db->cls, @@ -146,8 +167,9 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, { size_t index; json_t *value; + json_array_foreach (fields, index, value) { - int forget_status = GNUNET_OK; + int forget_status = GNUNET_NO; int expand_status; if (! (json_is_string (value))) @@ -175,6 +197,8 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, TALER_EC_MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_NOT_FORGETTABLE, json_string_value (value)); } + if (GNUNET_OK == forget_status) + changed = true; if (GNUNET_SYSERR == expand_status) { /* One of the paths was malformed and couldn't be expanded */ @@ -189,6 +213,17 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, } } + if (! changed) + { + TMH_db->rollback (TMH_db->cls); + json_decref (contract_terms); + json_decref (fields); + return TALER_MHD_reply_static (connection, + MHD_HTTP_NO_CONTENT, + NULL, + NULL, + 0); + } qs = TMH_db->update_contract_terms (TMH_db->cls, hc->instance->settings.id, order_id, diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index aafe4742..52f12a16 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -386,7 +386,6 @@ check_wire_fee (struct PostTransfersContext *ptc, char *wire_method; wire_method = TALER_payto_get_method (ptc->payto_uri); - TMH_db->preflight (TMH_db->cls); qs = TMH_db->lookup_wire_fee (TMH_db->cls, &ptc->master_pub, wire_method, @@ -626,7 +625,6 @@ verify_exchange_claim_cb (void *cls, ptc->current_detail = ttd; /* Set the coin as "never seen" before. */ ptc->check_transfer_result = GNUNET_NO; - TMH_db->preflight (TMH_db->cls); qs = TMH_db->lookup_deposits_by_contract_and_coin ( TMH_db->cls, ptc->hc->instance->settings.id, @@ -863,7 +861,7 @@ static void download (struct PostTransfersContext *ptc) { ptc->downloaded = true; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suspending POST /private/transfers handling while working with exchange\n"); MHD_suspend_connection (ptc->connection); GNUNET_CONTAINER_DLL_insert (ptc_head, @@ -1178,6 +1176,24 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, break; } + qs = TMH_db->commit (TMH_db->cls); + switch (qs) + { + case GNUNET_DB_STATUS_SOFT_ERROR: + TMH_db->rollback (TMH_db->cls); + continue; + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + TMH_db->rollback (TMH_db->cls); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, + NULL); + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + break; + } + deposit_sums = json_array (); GNUNET_assert (NULL != deposit_sums); GNUNET_CONTAINER_multihashmap_iterate (map, diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index dc8c8456..413a863a 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -221,8 +221,9 @@ postgres_start (void *cls, check_connection (pg); postgres_preflight (pg); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting merchant DB transaction\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Starting merchant DB transaction `%s'\n", + name); if (GNUNET_OK != GNUNET_PQ_exec_statements (pg->conn, es)) @@ -256,8 +257,9 @@ postgres_start_read_committed (void *cls, check_connection (pg); postgres_preflight (pg); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting merchant DB transaction (READ COMMITTED)\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Starting merchant DB transaction %s (READ COMMITTED)\n", + name); if (GNUNET_OK != GNUNET_PQ_exec_statements (pg->conn, es)) @@ -308,8 +310,9 @@ postgres_commit (void *cls) GNUNET_PQ_query_param_end }; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Committing merchant DB transaction\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Committing merchant DB transaction %s\n", + pg->transaction_name); pg->transaction_name = NULL; return GNUNET_PQ_eval_prepared_non_select (pg->conn, "end_transaction", diff --git a/src/lib/merchant_api_delete_instance.c b/src/lib/merchant_api_delete_instance.c index d83ea467..b0458a62 100644 --- a/src/lib/merchant_api_delete_instance.c +++ b/src/lib/merchant_api_delete_instance.c @@ -96,12 +96,14 @@ handle_delete_instance_finished (void *cls, hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; + case MHD_HTTP_NOT_FOUND: + break; default: /* unexpected response code */ hr.ec = TALER_JSON_get_error_code (json); hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u/%d\n", + "Unexpected response code %u/%d for DELETE /instance/ID\n", (unsigned int) response_code, (int) hr.ec); break; diff --git a/src/lib/merchant_api_get_instances.c b/src/lib/merchant_api_get_instances.c index be8b6e5b..a8eaa608 100644 --- a/src/lib/merchant_api_get_instances.c +++ b/src/lib/merchant_api_get_instances.c @@ -205,6 +205,10 @@ handle_instances_finished (void *cls, GNUNET_JSON_parse_free (spec); break; } + case MHD_HTTP_UNAUTHORIZED: + hr.ec = TALER_JSON_get_error_code (json); + hr.hint = TALER_JSON_get_error_hint (json); + break; default: /* unexpected response code */ hr.ec = TALER_JSON_get_error_code (json); diff --git a/src/lib/merchant_api_patch_order_forget.c b/src/lib/merchant_api_patch_order_forget.c index ddb26062..69563aaf 100644 --- a/src/lib/merchant_api_patch_order_forget.c +++ b/src/lib/merchant_api_patch_order_forget.c @@ -101,6 +101,10 @@ handle_forget_finished (void *cls, hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: + /* fields were NOW forgotten */ + break; + case MHD_HTTP_NO_CONTENT: + /* fields were already forgotten before */ break; case MHD_HTTP_BAD_REQUEST: hr.ec = TALER_JSON_get_error_code (json); diff --git a/src/testing/testing_api_cmd_delete_instance.c b/src/testing/testing_api_cmd_delete_instance.c index ca2acb76..9d3bd7d5 100644 --- a/src/testing/testing_api_cmd_delete_instance.c +++ b/src/testing/testing_api_cmd_delete_instance.c @@ -100,7 +100,8 @@ delete_instance_cb (void *cls, break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %d for DELETE instance.\n", + hr->http_status); } TALER_TESTING_interpreter_next (dis->is); } diff --git a/src/testing/testing_api_cmd_delete_order.c b/src/testing/testing_api_cmd_delete_order.c index 6d97b611..d5d8b283 100644 --- a/src/testing/testing_api_cmd_delete_order.c +++ b/src/testing/testing_api_cmd_delete_order.c @@ -98,7 +98,7 @@ delete_order_cb (void *cls, default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status %d.\n", + "Unhandled HTTP status %u for DELETE order.\n", hr->http_status); } TALER_TESTING_interpreter_next (dos->is); diff --git a/src/testing/testing_api_cmd_delete_product.c b/src/testing/testing_api_cmd_delete_product.c index d5a724fe..6fed8d46 100644 --- a/src/testing/testing_api_cmd_delete_product.c +++ b/src/testing/testing_api_cmd_delete_product.c @@ -87,11 +87,18 @@ delete_product_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_OK: + case MHD_HTTP_NO_CONTENT: + break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_NOT_FOUND: + break; + case MHD_HTTP_CONFLICT: break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for DELETE product.\n", + hr->http_status); } TALER_TESTING_interpreter_next (dis->is); } diff --git a/src/testing/testing_api_cmd_delete_reserve.c b/src/testing/testing_api_cmd_delete_reserve.c index fe95277e..d98b688a 100644 --- a/src/testing/testing_api_cmd_delete_reserve.c +++ b/src/testing/testing_api_cmd_delete_reserve.c @@ -100,7 +100,8 @@ delete_reserve_cb (void *cls, break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for DELETE reserve.\n", + hr->http_status); } TALER_TESTING_interpreter_next (drs->is); } diff --git a/src/testing/testing_api_cmd_get_instance.c b/src/testing/testing_api_cmd_get_instance.c index 7b4ee094..6622b2ec 100644 --- a/src/testing/testing_api_cmd_get_instance.c +++ b/src/testing/testing_api_cmd_get_instance.c @@ -325,9 +325,14 @@ get_instance_cb (void *cls, } } break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_NOT_FOUND: + break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for GET instance ID.\n", + hr->http_status); } TALER_TESTING_interpreter_next (gis->is); } diff --git a/src/testing/testing_api_cmd_get_instances.c b/src/testing/testing_api_cmd_get_instances.c index ff900b87..0e3342e6 100644 --- a/src/testing/testing_api_cmd_get_instances.c +++ b/src/testing/testing_api_cmd_get_instances.c @@ -161,7 +161,8 @@ get_instances_cb (void *cls, break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for GET /instances.\n", + hr->http_status); } TALER_TESTING_interpreter_next (gis->is); } diff --git a/src/testing/testing_api_cmd_lock_product.c b/src/testing/testing_api_cmd_lock_product.c index a61f1bd4..abb5920c 100644 --- a/src/testing/testing_api_cmd_lock_product.c +++ b/src/testing/testing_api_cmd_lock_product.c @@ -102,12 +102,18 @@ lock_product_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_OK: + case MHD_HTTP_NO_CONTENT: + break; + case MHD_HTTP_FORBIDDEN: + break; + case MHD_HTTP_NOT_FOUND: + break; + case MHD_HTTP_GONE: break; - // FIXME: add other legitimate states here... default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for lock product.\n", + hr->http_status); } TALER_TESTING_interpreter_next (pis->is); } diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c index c08dd56e..ed8b966b 100644 --- a/src/testing/testing_api_cmd_merchant_get_order.c +++ b/src/testing/testing_api_cmd_merchant_get_order.c @@ -118,7 +118,8 @@ apply_forget (void *cls, json_t *parent) { int *res = cls; - if (GNUNET_OK != + + if (GNUNET_SYSERR == TALER_JSON_contract_part_forget (parent, object_id)) *res = GNUNET_SYSERR; diff --git a/src/testing/testing_api_cmd_patch_instance.c b/src/testing/testing_api_cmd_patch_instance.c index a7a82ef7..3d4b93d1 100644 --- a/src/testing/testing_api_cmd_patch_instance.c +++ b/src/testing/testing_api_cmd_patch_instance.c @@ -139,10 +139,15 @@ patch_instance_cb (void *cls, { case MHD_HTTP_NO_CONTENT: break; - // FIXME: add other legitimate states here... + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_NOT_FOUND: + break; + case MHD_HTTP_CONFLICT: + break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status %u.\n", + "Unhandled HTTP status %u for PATCH instance.\n", hr->http_status); } TALER_TESTING_interpreter_next (pis->is); diff --git a/src/testing/testing_api_cmd_patch_product.c b/src/testing/testing_api_cmd_patch_product.c index 6e4613df..ed64d8f3 100644 --- a/src/testing/testing_api_cmd_patch_product.c +++ b/src/testing/testing_api_cmd_patch_product.c @@ -137,12 +137,20 @@ patch_product_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_OK: + case MHD_HTTP_NO_CONTENT: + break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_FORBIDDEN: + break; + case MHD_HTTP_NOT_FOUND: + break; + case MHD_HTTP_CONFLICT: break; - // FIXME: add other legitimate states here... default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for PATCH /products/ID.\n", + hr->http_status); } TALER_TESTING_interpreter_next (pis->is); } diff --git a/src/testing/testing_api_cmd_post_instances.c b/src/testing/testing_api_cmd_post_instances.c index 7eb2e7fa..8961d4e0 100644 --- a/src/testing/testing_api_cmd_post_instances.c +++ b/src/testing/testing_api_cmd_post_instances.c @@ -144,13 +144,18 @@ post_instances_cb (void *cls, { case MHD_HTTP_NO_CONTENT: break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_FORBIDDEN: + break; + case MHD_HTTP_NOT_FOUND: + break; case MHD_HTTP_CONFLICT: break; - // FIXME: add other legitimate states here... default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status %u.\n", + "Unhandled HTTP status %u for POST instances.\n", hr->http_status); } TALER_TESTING_interpreter_next (pis->is); diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c index 4cbb17b0..5b9e533f 100644 --- a/src/testing/testing_api_cmd_post_orders.c +++ b/src/testing/testing_api_cmd_post_orders.c @@ -677,7 +677,6 @@ make_order_json (const char *order_id, "$.dummy_array[*].item", &mark_forgettable, NULL)); - *order = json_dumps (contract_terms, 0); json_decref (contract_terms); } diff --git a/src/testing/testing_api_cmd_post_products.c b/src/testing/testing_api_cmd_post_products.c index 1a358a7e..5d1abb48 100644 --- a/src/testing/testing_api_cmd_post_products.c +++ b/src/testing/testing_api_cmd_post_products.c @@ -134,13 +134,19 @@ post_products_cb (void *cls, { case MHD_HTTP_NO_CONTENT: break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_FORBIDDEN: + break; + case MHD_HTTP_NOT_FOUND: + break; case MHD_HTTP_CONFLICT: break; - // FIXME: add other legitimate states here... default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for POST /products.\n", + hr->http_status); } TALER_TESTING_interpreter_next (pis->is); } diff --git a/src/testing/testing_api_cmd_post_reserves.c b/src/testing/testing_api_cmd_post_reserves.c index 4f18dbde..31866384 100644 --- a/src/testing/testing_api_cmd_post_reserves.c +++ b/src/testing/testing_api_cmd_post_reserves.c @@ -104,17 +104,18 @@ post_reserves_cb (void *cls, } switch (hr->http_status) { - case MHD_HTTP_NO_CONTENT: + case MHD_HTTP_OK: break; - case MHD_HTTP_CONFLICT: + case MHD_HTTP_ACCEPTED: break; - case MHD_HTTP_OK: + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_NOT_FOUND: break; - // FIXME: add other legitimate states here... default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status (%d).\n", + "Unhandled HTTP status %u for POST /reserves.\n", hr->http_status); } prs->reserve_pub = *reserve_pub; diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c index 1fa9dfc0..72b6f132 100644 --- a/src/testing/testing_api_cmd_post_transfers.c +++ b/src/testing/testing_api_cmd_post_transfers.c @@ -298,10 +298,16 @@ transfers_cb (void *cls, #endif break; } + case MHD_HTTP_ACCEPTED: + break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_NOT_FOUND: + break; default: GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status %d.\n", + "Unhandled HTTP status %u for POST /transfers.\n", hr->http_status); } TALER_TESTING_interpreter_next (pts->is); diff --git a/src/testing/testing_api_cmd_refund_order.c b/src/testing/testing_api_cmd_refund_order.c index 309c33a8..fd06f887 100644 --- a/src/testing/testing_api_cmd_refund_order.c +++ b/src/testing/testing_api_cmd_refund_order.c @@ -154,9 +154,18 @@ refund_cb (void *cls, TALER_MERCHANT_parse_refund_uri_free (&rud); } break; + case MHD_HTTP_UNAUTHORIZED: + break; + case MHD_HTTP_FORBIDDEN: + break; + case MHD_HTTP_NOT_FOUND: + break; + case MHD_HTTP_CONFLICT: + break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unhandled HTTP status.\n"); + "Unhandled HTTP status %u for refund order.\n", + hr->http_status); } TALER_TESTING_interpreter_next (ris->is); } |