From 1a695f06eaf4fa635f0235a28dac5dcdea5fd448 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 24 Feb 2024 17:28:29 +0100 Subject: major refactoring of taler-merchant-httpd_get-orders-ID.c --- no semantic change --- src/testing/testing_api_cmd_wallet_get_order.c | 90 +++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 8 deletions(-) (limited to 'src/testing/testing_api_cmd_wallet_get_order.c') diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index fd4a914d..d55ff0a7 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -58,6 +58,18 @@ struct WalletGetOrderState */ const char *order_reference; + /** + * Reference to a command that created a paid + * equivalent order that we expect to be referred + * to during repurchase detection, or NULL. + */ + const char *repurchase_order_ref; + + /** + * Session Id the order needs to be bound to. + */ + const char *session_id; + /** * Whether the order was paid or not. */ @@ -125,6 +137,31 @@ wallet_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 = owgr->details.payment_required.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 ( owgr->details.payment_required.taler_pay_uri, @@ -243,7 +280,7 @@ wallet_get_order_run (void *cls, order_id, h_contract, GNUNET_TIME_UNIT_ZERO, - NULL, + gos->session_id, NULL, false, &wallet_get_order_cb, @@ -274,13 +311,48 @@ wallet_get_order_cleanup (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_wallet_get_order (const char *label, - const char *merchant_url, - const char *order_reference, - bool paid, - bool refunded, - bool refund_pending, - unsigned int http_status) +TALER_TESTING_cmd_wallet_get_order ( + const char *label, + const char *merchant_url, + const char *order_reference, + bool paid, + bool refunded, + bool refund_pending, + unsigned int http_status) +{ + struct WalletGetOrderState *gos; + + gos = GNUNET_new (struct WalletGetOrderState); + gos->merchant_url = merchant_url; + gos->order_reference = order_reference; + gos->http_status = http_status; + gos->paid = paid; + gos->refunded = refunded; + gos->refund_pending = refund_pending; + { + struct TALER_TESTING_Command cmd = { + .cls = gos, + .label = label, + .run = &wallet_get_order_run, + .cleanup = &wallet_get_order_cleanup + }; + + return cmd; + } +} + + +struct TALER_TESTING_Command +TALER_TESTING_cmd_wallet_get_order2 ( + const char *label, + const char *merchant_url, + const char *order_reference, + const char *session_id, + bool paid, + bool refunded, + bool refund_pending, + const char *repurchase_order_ref, + unsigned int http_status) { struct WalletGetOrderState *gos; @@ -289,8 +361,10 @@ TALER_TESTING_cmd_wallet_get_order (const char *label, gos->order_reference = order_reference; gos->http_status = http_status; gos->paid = paid; + gos->session_id = session_id; gos->refunded = refunded; gos->refund_pending = refund_pending; + gos->repurchase_order_ref = repurchase_order_ref; { struct TALER_TESTING_Command cmd = { .cls = gos, -- cgit v1.2.3