aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-04-26 11:47:34 +0200
committerChristian Blättler <blatc2@bfh.ch>2024-04-26 11:47:34 +0200
commite491838fc6143011634a0148bf03a0b7a3bca5f5 (patch)
treee32a05716012f164b5d69b34262e7df206ac46dd /src
parent169ece9db401e031681a7e9337db1f5086f78d1d (diff)
extend testing lib to support paying for orders with choices
Diffstat (limited to 'src')
-rw-r--r--src/include/taler_merchant_testing_lib.h33
-rw-r--r--src/testing/testing_api_cmd_pay_order.c54
2 files changed, 78 insertions, 9 deletions
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h
index 47d081fc..5138be31 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -984,6 +984,39 @@ TALER_TESTING_cmd_merchant_pay_order (
/**
+ * Make a "pay" test command for an order with choices.
+ *
+ * @param label command label.
+ * @param merchant_url merchant base url
+ * @param http_status expected HTTP response code.
+ * @param proposal_reference the proposal whose payment status
+ * is going to be checked.
+ * @param coin_reference reference to any command which is able
+ * to provide coins to use for paying.
+ * @param amount_with_fee amount to pay, including the deposit
+ * fee
+ * @param amount_without_fee amount to pay, no fees included.
+ * @param session_id the session id to use for the payment (can be NULL).
+ * @param choice_index index of the selected choice for the payment.
+ * @param input_reference reference to a previous pay command that issued some
+ outputs to be used as inputs to this pay request.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_pay_order_choices (
+ const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *session_id,
+ int choice_index,
+ const char *input_reference);
+
+
+/**
* Make an "order paid" test command.
*
* @param label command label
diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c
index 0b84c8a6..f748a06a 100644
--- a/src/testing/testing_api_cmd_pay_order.c
+++ b/src/testing/testing_api_cmd_pay_order.c
@@ -23,6 +23,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include <jansson.h>
#include <taler/taler_exchange_service.h>
#include <taler/taler_testing_lib.h>
#include <taler/taler_signatures.h>
@@ -107,6 +108,11 @@ struct PayState
*/
enum TALER_MerchantConfirmationAlgorithm pos_alg;
+ /**
+ * Wallet data json object. Used in the pay request if not NULL.
+ */
+ const json_t *wallet_data;
+
};
@@ -438,7 +444,7 @@ pay_run (void *cls,
ps->merchant_url,
ps->session_id,
h_proposal,
- NULL,
+ ps->wallet_data,
&ps->total_amount,
&max_fee,
&merchant_pub,
@@ -560,14 +566,16 @@ pay_traits (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_pay_order (const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *proposal_reference,
- const char *coin_reference,
- const char *amount_with_fee,
- const char *amount_without_fee,
- const char *session_id)
+TALER_TESTING_cmd_merchant_pay_order_choices (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *session_id,
+ int choice_index,
+ const char *input_reference)
{
struct PayState *ps;
@@ -579,6 +587,12 @@ TALER_TESTING_cmd_merchant_pay_order (const char *label,
ps->amount_with_fee = amount_with_fee;
ps->amount_without_fee = amount_without_fee;
ps->session_id = session_id;
+ if (0 <= choice_index)
+ {
+ ps->wallet_data = json_pack ("{s:i}",
+ "choice_index",
+ choice_index);
+ }
{
struct TALER_TESTING_Command cmd = {
.cls = ps,
@@ -593,4 +607,26 @@ TALER_TESTING_cmd_merchant_pay_order (const char *label,
}
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_pay_order (const char *label,
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *coin_reference,
+ const char *amount_with_fee,
+ const char *amount_without_fee,
+ const char *session_id)
+{
+ return TALER_TESTING_cmd_merchant_pay_order_choices (label,
+ merchant_url,
+ http_status,
+ proposal_reference,
+ coin_reference,
+ amount_with_fee,
+ amount_without_fee,
+ session_id,
+ -1);
+}
+
+
/* end of testing_api_cmd_pay_order.c */