commit e7e9b56abd9db5c0735ac48c1fac4b880f91e9dc
parent cee5a44b58077dbc4c95b11d4151fb0a9d19f5cd
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Sun, 13 Apr 2025 17:01:11 +0200
adding donau order creation and claim test
Diffstat:
3 files changed, 124 insertions(+), 3 deletions(-)
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
@@ -639,6 +639,32 @@ TALER_TESTING_cmd_merchant_post_orders_choices (
/**
+ * Create an order with a choices array with output choice for donau.
+ *
+ * @param label command label
+ * @param cfg configuration to use
+ * @param merchant_url base URL of the merchant serving
+ * the proposal request.
+ * @param http_status expected HTTP status.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @return the command
+ */
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_donau (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount);
+
+/**
* Define a "GET /orders" CMD.
*
* @param label command label.
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
@@ -1849,9 +1849,24 @@ run (void *cls,
merchant_url,
1,
MHD_HTTP_OK),
- //FIXME: Add the order payment for the donau
- //FIXME: Probably the order payment must be
- // checked against the received donation_receipts
+ //FIXME_2: Add check for the donau charity instance info being corrected
+ // with info from the donau
+ //FIXME: Add the order payment for the donau(choices tax-receipt)
+ //TALER_TESTING_cmd_merchant_post_orders_choices (act post_orders_donau)
+ TALER_TESTING_cmd_merchant_post_orders_donau (
+ "create-donau-order",
+ cred.cfg,
+ merchant_url,
+ MHD_HTTP_OK,
+ "donau",
+ GNUNET_TIME_UNIT_ZERO_TS,
+ GNUNET_TIME_UNIT_FOREVER_TS,
+ "EUR:10.0"),
+ //FIXME: Add the claiming phase
+ //TALER_TESTING_cmd_merchant_claim_order
+ //FIXME: Most probably we need to merge the functionality of the
+ //TALER_TESTING_cmd_merchant_pay_order and TALER_TESTING_cmd_issue_receipts from DONAU
+ //Most probably we only need to copy the part of creation of the BUDIs
TALER_TESTING_cmd_merchant_delete_donau_instance(
"delete-donau-instance",
merchant_url,
diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c
@@ -978,3 +978,83 @@ TALER_TESTING_cmd_merchant_post_orders_choices (
return cmd;
}
}
+
+
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_orders_donau (
+ const char *label,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *order_id,
+ struct GNUNET_TIME_Timestamp refund_deadline,
+ struct GNUNET_TIME_Timestamp pay_deadline,
+ const char *amount)
+{
+ struct OrdersState *ps;
+ struct TALER_Amount brutto;
+ json_t *choice;
+ json_t *choices;
+ json_t *inputs;
+ json_t *outputs;
+
+ ps = GNUNET_new (struct OrdersState);
+ ps->cfg = cfg;
+ make_order_json (order_id,
+ refund_deadline,
+ pay_deadline,
+ NULL,
+ &ps->order_terms);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (amount,
+ &brutto));
+
+ outputs = json_array ();
+ GNUNET_assert (NULL != outputs);
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ outputs,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("type",
+ "tax-receipt")
+ )));
+ choice
+ = GNUNET_JSON_PACK (
+ TALER_JSON_pack_amount ("amount",
+ &brutto),
+ GNUNET_JSON_pack_array_steal ("outputs",
+ outputs));
+ choices = json_array ();
+ GNUNET_assert (NULL != choices);
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ choices,
+ choice));
+ GNUNET_assert (0 ==
+ json_object_set_new (ps->order_terms,
+ "choices",
+ choices)
+ );
+ GNUNET_assert (0 ==
+ json_object_set_new (ps->order_terms,
+ "version",
+ json_integer (1))
+ );
+
+
+ ps->http_status = http_status;
+ ps->expected_order_id = order_id;
+ ps->merchant_url = merchant_url;
+ ps->with_claim = true;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = ps,
+ .label = label,
+ .run = &orders_run3,
+ .cleanup = &orders_cleanup,
+ .traits = &orders_traits
+ };
+
+ return cmd;
+ }
+}