summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-05-21 15:17:45 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-05-21 15:17:45 +0200
commitd194cdb5bb0dbde9daeec75895520269a3ab3c00 (patch)
tree695dcf5912ee2c9a8f9254a3e2602ffcaf985f06 /src/lib
parent11c2eb216866721083e4764d09628e1b0092e0a7 (diff)
downloadmerchant-d194cdb5bb0dbde9daeec75895520269a3ab3c00.tar.gz
merchant-d194cdb5bb0dbde9daeec75895520269a3ab3c00.tar.bz2
merchant-d194cdb5bb0dbde9daeec75895520269a3ab3c00.zip
Issuing a refund lookup with a non existent order id.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/merchant_api_refund.c28
-rw-r--r--src/lib/test_merchant_api_new.c12
-rw-r--r--src/lib/testing_api_cmd_refund.c15
3 files changed, 42 insertions, 13 deletions
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index 812176f9..0dbd52fd 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -285,12 +285,13 @@ handle_refund_lookup_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Backend didn't even return from GET /refund\n");
return;
+
case MHD_HTTP_OK:
+ case MHD_HTTP_NOT_FOUND:
rlo->cb (rlo->cb_cls,
- MHD_HTTP_OK,
+ response_code,
TALER_EC_NONE,
json);
- TALER_MERCHANT_refund_lookup_cancel (rlo);
break;
default:
/**
@@ -298,15 +299,24 @@ handle_refund_lookup_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);
+ if (-1 == json_unpack ((json_t *) json,
+ "{s:s, s:I, s:s}",
+ "error", &error,
+ "code", &code))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed GET /refund, error: %s, code: %d\n",
+ error,
+ code);
+ break;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed GET /refund, error: %s, code: %d\n",
- error,
- code);
+ "Failed /refund lookup, backend did not give"
+ " a valid error object, HTTP code was %lu\n",
+ response_code);
}
+
+ TALER_MERCHANT_refund_lookup_cancel (rlo);
}
diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c
index d598b37f..83e565b9 100644
--- a/src/lib/test_merchant_api_new.c
+++ b/src/lib/test_merchant_api_new.c
@@ -470,7 +470,17 @@ run (void *cls,
is->ctx,
"refund-increase-1",
"deposit-simple",
- "1"),
+ "1",
+ MHD_HTTP_OK),
+
+ /* Trying to pick up a non existent refund. */
+ TALER_TESTING_cmd_refund_lookup ("refund-lookup-non-existent",
+ merchant_url,
+ is->ctx,
+ "refund-increase-1",
+ "deposit-simple",
+ "non-existend-id",
+ MHD_HTTP_NOT_FOUND),
/* Test /refund on a contract that was never paid. */
diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c
index 2abc89a0..7dc5683c 100644
--- a/src/lib/testing_api_cmd_refund.c
+++ b/src/lib/testing_api_cmd_refund.c
@@ -65,6 +65,8 @@ struct RefundLookupState
const char *increase_reference;
+ unsigned int http_code;
+
struct TALER_TESTING_Interpreter *is;
};
@@ -211,13 +213,18 @@ refund_lookup_cb (void *cls,
const json_t *arr;
rls->rlo = NULL;
- if (MHD_HTTP_OK != http_status)
+ if (rls->http_code != http_status)
TALER_TESTING_FAIL (rls->is);
map = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
arr = json_object_get (obj, "refund_permissions");
if (NULL == arr)
- TALER_TESTING_FAIL (rls->is);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Tolerating a refund permission not found\n");
+ TALER_TESTING_interpreter_next (rls->is);
+ return;
+ }
json_array_foreach (arr, index, elem)
{
@@ -436,7 +443,8 @@ TALER_TESTING_cmd_refund_lookup
struct GNUNET_CURL_Context *ctx,
const char *increase_reference,
const char *pay_reference,
- const char *order_id)
+ const char *order_id,
+ unsigned int http_code)
{
struct RefundLookupState *rls;
struct TALER_TESTING_Command cmd;
@@ -447,6 +455,7 @@ TALER_TESTING_cmd_refund_lookup
rls->order_id = order_id;
rls->pay_reference = pay_reference;
rls->increase_reference = increase_reference;
+ rls->http_code = http_code;
cmd.cls = rls;
cmd.label = label;