summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-05-21 14:50:36 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2019-05-21 14:50:36 +0200
commitca0f567dcc4e9a4b6c65b2974c45a4bbcbaba414 (patch)
tree4d227ac6e34abe136f8bec71845df5bfcceaa080
parent821109d5cf29635ae00ca3533aa83405797d3223 (diff)
downloadmerchant-ca0f567dcc4e9a4b6c65b2974c45a4bbcbaba414.tar.gz
merchant-ca0f567dcc4e9a4b6c65b2974c45a4bbcbaba414.tar.bz2
merchant-ca0f567dcc4e9a4b6c65b2974c45a4bbcbaba414.zip
Resolve #5719
-rw-r--r--src/backend/taler-merchant-httpd_pay.c2
-rw-r--r--src/lib/merchant_api_pay.c4
-rw-r--r--src/lib/test_merchant_api_twisted.c76
3 files changed, 81 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 57ff4023..6f407e3a 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -2024,7 +2024,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
json_t *root;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "In handler for /pay.\n");
+ "In handler for /pay.\n");
if (NULL == *connection_cls)
{
pc = GNUNET_new (struct PayContext);
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index be70f6d4..84d86e59 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -368,6 +368,10 @@ handle_pay_finished (void *cls,
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
break;
+ case MHD_HTTP_SERVICE_UNAVAILABLE:
+ /* Exchange couldn't respond properly; the retry is left to the
+ * application */
+ break;
default:
/* unexpected response code */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/lib/test_merchant_api_twisted.c b/src/lib/test_merchant_api_twisted.c
index 0335153b..f5403bf6 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -190,6 +190,80 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
+ /**** Triggering #5719 ****/
+ struct TALER_TESTING_Command bug_5719[] = {
+
+ /**
+ * Move money to the exchange's bank account.
+ */
+ CMD_TRANSFER_TO_EXCHANGE ("5719-create-reserve",
+ "EUR:1.01"),
+ /**
+ * Make a reserve exist, according to the previous
+ * transfer.
+ */
+ CMD_EXEC_WIREWATCH ("5719-wirewatch"),
+
+ TALER_TESTING_cmd_check_bank_transfer
+ ("5719-check-transfer",
+ EXCHANGE_URL,
+ "EUR:1.01",
+ USER_ACCOUNT_NO,
+ EXCHANGE_ACCOUNT_NO),
+
+ TALER_TESTING_cmd_withdraw_amount ("5719-withdraw",
+ "5719-create-reserve",
+ "EUR:1",
+ MHD_HTTP_OK),
+
+ TALER_TESTING_cmd_status ("5719-reserve-status",
+ "5719-create-reserve",
+ "EUR:0",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_proposal
+ ("5719-create-proposal",
+ twister_merchant_url,
+ MHD_HTTP_OK,
+ "{\"max_fee\":\
+ {\"currency\":\"EUR\",\
+ \"value\":0,\
+ \"fraction\":50000000},\
+ \"order_id\":\"5719TRIGGER\",\
+ \"refund_deadline\":\"\\/Date(0)\\/\",\
+ \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+ \"fulfillment_url\": \"https://example.com/\",\
+ \"amount\":\
+ {\"currency\":\"EUR\",\
+ \"value\":1,\
+ \"fraction\":0},\
+ \"summary\": \"merchant-lib testcase\",\
+ \"products\": [ {\"description\":\"triggering bug 5719\",\
+ \"value\":\"{EUR:1}\"} ] }",
+ NULL),
+
+ /**
+ * Instruct the Twister to malform the response given by
+ * the exchange to the merchant. This way, the parser will
+ * not manage to pass the callback a valid JSON and will
+ * instead pass a NULL pointer. This should trigger the path
+ * mentioned in the bug report #5719.
+ */
+ TALER_TESTING_cmd_malform_response
+ ("5719-malform-xcg-resp",
+ PROXY_EXCHANGE_CONFIG_FILE),
+
+ TALER_TESTING_cmd_pay ("5719-deposit",
+ twister_merchant_url,
+ MHD_HTTP_SERVICE_UNAVAILABLE,
+ "5719-create-proposal",
+ "5719-withdraw",
+ "EUR:1",
+ "EUR:1.99", // no sense now
+ "EUR:0.01"), // no sense now
+ TALER_TESTING_cmd_end ()
+ };
+
+
/**** Covering /check-payment ****/
struct TALER_TESTING_Command check_payment[] = {
@@ -956,6 +1030,8 @@ run (void *cls,
TALER_TESTING_cmd_batch ("pay",
pay),
+ TALER_TESTING_cmd_batch ("bug-5719",
+ bug_5719),
/**
* End the suite. Fixme: better to have a label for this
* too, as it shows a "(null)" token on logs.