summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_merchant_get_order.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-02-24 13:13:31 +0100
committerChristian Grothoff <christian@grothoff.org>2024-02-24 13:13:31 +0100
commita84dbc0e60adbc27f4f98a024c469dd51df8f817 (patch)
treed72418611e5e675ccdf0b7f3f996c6190200701e /src/testing/testing_api_cmd_merchant_get_order.c
parentbfb86da296a788d4b96ac55fd9b06c58e34cd98e (diff)
downloadmerchant-a84dbc0e60adbc27f4f98a024c469dd51df8f817.tar.gz
merchant-a84dbc0e60adbc27f4f98a024c469dd51df8f817.tar.bz2
merchant-a84dbc0e60adbc27f4f98a024c469dd51df8f817.zip
add (working) test for repurchase detection
Diffstat (limited to 'src/testing/testing_api_cmd_merchant_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c127
1 files changed, 99 insertions, 28 deletions
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index f30c43ad..1b235c93 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -94,6 +94,23 @@ struct MerchantGetOrderState
unsigned int forgets_length;
/**
+ * Set to a session ID, if we should pass one as part
+ * of the request.
+ */
+ const char *session_id;
+
+ /**
+ * Set if we expect to be referred to another equivalent order which was
+ * already paid by the wallet under this @e session_id.
+ */
+ const char *repurchase_order_ref;
+
+ /**
+ * True if we should pass the 'allow_refunded_for_repurchase' flag.
+ */
+ bool allow_refunded_for_repurchase;
+
+ /**
* Whether the order was refunded or not.
*/
bool refunded;
@@ -413,6 +430,31 @@ merchant_get_order_cb (
const char *order_id;
const struct TALER_ClaimTokenP *claim_token;
+ if (NULL != gos->repurchase_order_ref)
+ {
+ const struct TALER_TESTING_Command *rep_cmd;
+ const char *rep_id;
+ const char *ri;
+
+ rep_cmd = TALER_TESTING_interpreter_lookup_command (
+ gos->is,
+ gos->repurchase_order_ref);
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_order_id (rep_cmd,
+ &rep_id))
+ {
+ TALER_TESTING_FAIL (gos->is);
+ }
+ ri = osr->details.ok.details.unpaid.already_paid_order_id;
+ if ( (NULL == ri) ||
+ (0 !=
+ strcmp (ri,
+ rep_id)) )
+ {
+ TALER_TESTING_FAIL (gos->is);
+ }
+ }
+
if (GNUNET_OK !=
TALER_MERCHANT_parse_pay_uri (
osr->details.ok.details.unpaid.taler_pay_uri,
@@ -535,7 +577,7 @@ merchant_get_order_run (void *cls,
TALER_TESTING_interpreter_get_context (is),
gos->merchant_url,
order_id,
- NULL,
+ gos->session_id,
GNUNET_TIME_UNIT_ZERO,
&merchant_get_order_cb,
gos);
@@ -574,13 +616,14 @@ merchant_get_order_cleanup (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_order (const char *label,
- const char *merchant_url,
- const char *order_reference,
- enum TALER_MERCHANT_OrderStatusCode osc,
- bool refunded,
- unsigned int http_status,
- ...)
+TALER_TESTING_cmd_merchant_get_order (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ bool refunded,
+ unsigned int http_status,
+ ...)
{
struct MerchantGetOrderState *gos;
@@ -618,16 +661,17 @@ TALER_TESTING_cmd_merchant_get_order (const char *label,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_get_order2 (const char *label,
- const char *merchant_url,
- const char *order_reference,
- enum TALER_MERCHANT_OrderStatusCode osc,
- bool wired,
- const char **transfers,
- bool refunded,
- const char **refunds,
- const char **forgets,
- unsigned int http_status)
+TALER_TESTING_cmd_merchant_get_order2 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ bool wired,
+ const char **transfers,
+ bool refunded,
+ const char **refunds,
+ const char **forgets,
+ unsigned int http_status)
{
struct MerchantGetOrderState *gos;
@@ -678,6 +722,38 @@ TALER_TESTING_cmd_merchant_get_order2 (const char *label,
}
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_get_order3 (
+ const char *label,
+ const char *merchant_url,
+ const char *order_reference,
+ enum TALER_MERCHANT_OrderStatusCode osc,
+ const char *session_id,
+ const char *repurchase_order_ref,
+ unsigned int expected_http_status)
+{
+ struct MerchantGetOrderState *gos;
+
+ gos = GNUNET_new (struct MerchantGetOrderState);
+ gos->merchant_url = merchant_url;
+ gos->order_reference = order_reference;
+ gos->osc = osc;
+ gos->session_id = session_id;
+ gos->repurchase_order_ref = repurchase_order_ref;
+ gos->http_status = expected_http_status;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gos,
+ .label = label,
+ .run = &merchant_get_order_run,
+ .cleanup = &merchant_get_order_cleanup
+ };
+
+ return cmd;
+ }
+}
+
+
struct MerchantPollOrderConcludeState
{
/**
@@ -892,14 +968,12 @@ merchant_poll_order_start_cleanup (void *cls,
}
-/**
- * Start a long poll for GET /private/orders/$ORDER_ID.
- */
struct TALER_TESTING_Command
-TALER_TESTING_cmd_poll_order_start (const char *label,
- const char *merchant_url,
- const char *order_id,
- struct GNUNET_TIME_Relative timeout)
+TALER_TESTING_cmd_poll_order_start (
+ const char *label,
+ const char *merchant_url,
+ const char *order_id,
+ struct GNUNET_TIME_Relative timeout)
{
struct MerchantPollOrderStartState *pos;
@@ -987,9 +1061,6 @@ merchant_poll_order_conclude_cleanup (void *cls,
}
-/**
- * Complete a long poll for GET /private/orders/$ORDER_ID.
- */
struct TALER_TESTING_Command
TALER_TESTING_cmd_poll_order_conclude (const char *label,
unsigned int http_status,