diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/merchant_api_refund.c | 27 | ||||
-rw-r--r-- | src/lib/test_merchant_api_new.c | 34 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund.c | 2 |
3 files changed, 55 insertions, 8 deletions
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c index 2f02735b..e3a09d6f 100644 --- a/src/lib/merchant_api_refund.c +++ b/src/lib/merchant_api_refund.c @@ -121,9 +121,13 @@ handle_refund_increase_finished (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Backend didn't even return from POST /refund\n"); return; + + /* Tolerate Bad Request here in order to let + * test cases move along. */ case MHD_HTTP_OK: + case MHD_HTTP_BAD_REQUEST: rio->cb (rio->cb_cls, - MHD_HTTP_OK, + response_code, TALER_EC_NONE, json); break; @@ -133,13 +137,22 @@ handle_refund_increase_finished (void *cls, * NOTE that json must be a Taler-specific error object (FIXME, * need a link to error objects at docs) */ - json_unpack ((json_t *) json, - "{s:s, s:I, s:s}", - "error", &error, - "code", &code, - "hint", &hint); + if (-1 == json_unpack + ((json_t *) json, + "{s:s, s:I, s:s}", + "error", &error, + "code", &code, + "hint", &hint)) + + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "/refund failed (HTTP code: %lu), backend did " + "not give a valid error object\n", response_code); + break; + } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed POST /refund, error: %s, code: %d, hint: %s\n", + "/refund, error: %s, code: %d, hint: %s\n", error, code, hint); diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c index e78c57cd..2c8b9534 100644 --- a/src/lib/test_merchant_api_new.c +++ b/src/lib/test_merchant_api_new.c @@ -472,6 +472,40 @@ run (void *cls, "deposit-simple", "1"), + /* Test /refund on a contract that was never paid. */ + + TALER_TESTING_cmd_proposal + ("create-proposal-not-to-be-paid", + merchant_url, + is->ctx, + MHD_HTTP_OK, + "{\"max_fee\":\ + {\"currency\":\"EUR\",\ + \"value\":0,\ + \"fraction\":50000000},\ + \"order_id\":\"1-unpaid\",\ + \"refund_deadline\":\"\\/Date(0)\\/\",\ + \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ + \"amount\":\ + {\"currency\":\"EUR\",\ + \"value\":5,\ + \"fraction\":0},\ + \"summary\": \"useful product\",\ + \"fulfillment_url\": \"https://example.com/\",\ + \"products\": [ {\"description\":\"ice cream\",\ + \"value\":\"{EUR:5}\"} ] }", + NULL), + + TALER_TESTING_cmd_refund_increase + ("refund-increase-unpaid-proposal", + merchant_url, + is->ctx, + "refund test", + "1-unpaid", + "EUR:0.1", + "EUR:0.01", + MHD_HTTP_BAD_REQUEST), + /* Test tipping. */ TALER_TESTING_cmd_fakebank_transfer_with_instance ("create-reserve-tip-1", diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c index 22025108..2abc89a0 100644 --- a/src/lib/testing_api_cmd_refund.c +++ b/src/lib/testing_api_cmd_refund.c @@ -129,7 +129,7 @@ refund_increase_cb (void *cls, struct RefundIncreaseState *ris = cls; ris->rio = NULL; - if (MHD_HTTP_OK != http_status) + if (ris->http_code != http_status) TALER_TESTING_FAIL (ris->is); TALER_TESTING_interpreter_next (ris->is); |