summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-httpd.c2
-rw-r--r--src/include/taler_merchant_testing_lib.h24
-rw-r--r--src/lib/merchant_api_post_transfers.c6
-rw-r--r--src/testing/test_merchant_api.c12
-rw-r--r--src/testing/testing_api_cmd_post_transfers.c79
5 files changed, 122 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 701b8acd..e9572ecb 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1406,7 +1406,7 @@ url_handler (void *cls,
},
/* DELETE /transfers/$ID: */
{
- .url_prefix = "/transfers",
+ .url_prefix = "/transfers/",
.method = MHD_HTTP_METHOD_DELETE,
.allow_deleted_instance = true,
.handler = &TMH_private_delete_transfers_ID,
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index 51dbb856..73a1be05 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -997,6 +997,30 @@ TALER_TESTING_cmd_merchant_post_transfer (
/**
+ * Define a POST /transfers CMD. Details like the WTID and
+ * other required parameters are explicitly provided.
+ *
+ * @param label command label.
+ * @param merchant_url base URL of the backend
+ * @param payto_uri URL of the exchange's bank account
+ * @param credit_amount amount credited
+ * @param wtid wire transfer ID to use, NULL to pick one at random
+ * @param exchange_url URL of the exchange to use
+ * @param http_code expected HTTP response code
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_transfer2 (
+ const char *label,
+ const char *merchant_url,
+ const char *payto_uri,
+ const char *credit_amount,
+ const char *wtid,
+ const char *exchange_url,
+ unsigned int http_code);
+
+
+/**
* We have discovered the @a serial for a POST transfer
* command. Store it (for the bank row trait).
*
diff --git a/src/lib/merchant_api_post_transfers.c b/src/lib/merchant_api_post_transfers.c
index e78cb36d..3a775b90 100644
--- a/src/lib/merchant_api_post_transfers.c
+++ b/src/lib/merchant_api_post_transfers.c
@@ -209,6 +209,12 @@ handle_post_transfers_finished (void *cls,
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
+ case MHD_HTTP_GATEWAY_TIMEOUT:
+ /* Server had an internal issue; we should retry, but this API
+ leaves this to the application */
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
+ break;
default:
/* unexpected response code */
GNUNET_break_op (0);
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 797d2005..17573ec2 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -440,12 +440,24 @@ run (void *cls,
MHD_HTTP_OK,
"deposit-simple",
NULL),
+ TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad",
+ merchant_url,
+ PAYTO_I1,
+ "EUR:4.98",
+ NULL /* random WTID */,
+ "http://localhost/404/",
+ MHD_HTTP_GATEWAY_TIMEOUT),
TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1",
merchant_url,
PAYTO_I1,
MHD_HTTP_OK,
"post-transfer-1",
+ "post-transfer-bad",
NULL),
+ TALER_TESTING_cmd_merchant_delete_transfer ("delete-transfer-1",
+ merchant_url,
+ "post-transfer-bad",
+ MHD_HTTP_NO_CONTENT),
TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2",
merchant_url,
"create-proposal-1",
diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c
index e78af34e..35c425a3 100644
--- a/src/testing/testing_api_cmd_post_transfers.c
+++ b/src/testing/testing_api_cmd_post_transfers.c
@@ -310,6 +310,8 @@ transfers_cb (void *cls,
break;
case MHD_HTTP_NOT_FOUND:
break;
+ case MHD_HTTP_GATEWAY_TIMEOUT:
+ break;
default:
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -356,6 +358,34 @@ post_transfers_traits (void *cls,
/**
+ * Run the "POST /transfers" CMD. First, get the bank history to find
+ * the wtid.
+ *
+ * @param cls closure.
+ * @param cmd command being run now.
+ * @param is interpreter state.
+ */
+static void
+post_transfers_run2 (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct PostTransfersState *pts = cls;
+
+ pts->is = is;
+ pts->pth = TALER_MERCHANT_transfers_post (pts->is->ctx,
+ pts->merchant_url,
+ &pts->credit_amount,
+ &pts->wtid,
+ pts->credit_account,
+ pts->exchange_url,
+ &transfers_cb,
+ pts);
+ GNUNET_assert (NULL != pts->pth);
+}
+
+
+/**
* Callbacks of this type are used to serve the result of asking
* the bank for the debit transaction history.
*
@@ -407,6 +437,7 @@ debit_cb (
pts->exchange_url,
&transfers_cb,
pts);
+ GNUNET_assert (NULL != pts->pth);
return GNUNET_OK;
}
if (MHD_HTTP_OK != http_status)
@@ -544,6 +575,54 @@ TALER_TESTING_cmd_merchant_post_transfer (
}
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_transfer2 (
+ const char *label,
+ const char *merchant_url,
+ const char *payto_uri,
+ const char *credit_amount,
+ const char *wtid,
+ const char *exchange_url,
+ unsigned int http_code)
+{
+ struct PostTransfersState *pts;
+
+ pts = GNUNET_new (struct PostTransfersState);
+ pts->merchant_url = merchant_url;
+ pts->credit_account = GNUNET_strdup (payto_uri);
+ pts->exchange_url = GNUNET_strdup (exchange_url);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (credit_amount,
+ &pts->credit_amount));
+ if (NULL == wtid)
+ {
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &pts->wtid,
+ sizeof (pts->wtid));
+ }
+ else
+ {
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_STRINGS_string_to_data (wtid,
+ strlen (wtid),
+ &pts->wtid,
+ sizeof (pts->wtid)));
+ }
+ pts->http_status = http_code;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = pts,
+ .label = label,
+ .run = &post_transfers_run2,
+ .cleanup = &post_transfers_cleanup,
+ .traits = &post_transfers_traits
+ };
+
+ return cmd;
+ }
+}
+
+
void
TALER_TESTING_cmd_merchant_post_transfer_set_serial (
struct TALER_TESTING_Command *cmd,