summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_merchant_api.c')
-rw-r--r--src/testing/test_merchant_api.c207
1 files changed, 85 insertions, 122 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index ff705a36..8663b2e3 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -51,6 +51,10 @@
static const char *pickup_amounts_1[] = {"EUR:5", NULL};
+static const char *pickup_amounts_2[] = {"EUR:0.01", NULL};
+
+static const char *pickup_refs[] = {"pickup-tip-1", "pickup-tip-4", NULL};
+
/**
* Payto URI of the customer (payer).
*/
@@ -654,12 +658,13 @@ run (void *cls,
MHD_HTTP_OK,
"tip 1",
"EUR:5.01"),
- TALER_TESTING_cmd_tip_authorize ("authorize-tip-2",
- merchant_url,
- EXCHANGE_URL,
- MHD_HTTP_OK,
- "tip 2",
- "EUR:5.01"),
+ TALER_TESTING_cmd_tip_authorize_from_reserve ("authorize-tip-2",
+ merchant_url,
+ EXCHANGE_URL,
+ "create-reserve-tip-1",
+ MHD_HTTP_OK,
+ "tip 2",
+ "EUR:5.01"),
TALER_TESTING_cmd_wallet_get_tip ("get-tip-1",
merchant_url,
"authorize-tip-1",
@@ -683,136 +688,94 @@ run (void *cls,
MHD_HTTP_OK,
"authorize-tip-1",
pickup_amounts_1),
- TALER_TESTING_cmd_merchant_delete_reserve ("delete-reserve-tip-1",
- merchant_url,
- "create-reserve-tip-1",
- MHD_HTTP_NO_CONTENT),
- TALER_TESTING_cmd_merchant_purge_reserve ("delete-reserve-tip-2",
- merchant_url,
- "create-reserve-tip-1",
- MHD_HTTP_NO_CONTENT),
- TALER_TESTING_cmd_merchant_purge_reserve ("delete-reserve-tip-3",
- merchant_url,
- "create-reserve-tip-1",
- MHD_HTTP_NOT_FOUND),
-#if 0
- /* Test tipping. */
- TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-tip-1",
- "EUR:20.04",
- &bc.exchange_auth,
- payer_payto,
- "tip",
- CONFIG_FILE),
- cmd_exec_wirewatch ("wirewatch-3"),
- TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-tip-1",
- "EUR:20.04",
- payer_payto,
- exchange_payto,
- "create-reserve-tip-1"),
- TALER_TESTING_cmd_tip_authorize ("authorize-tip-1",
- merchant_url_internal ("tip"),
- EXCHANGE_URL,
- MHD_HTTP_OK,
- "tip 1",
- "EUR:5.01"),
- TALER_TESTING_cmd_tip_authorize ("authorize-tip-2",
- merchant_url_internal ("tip"),
- EXCHANGE_URL,
- MHD_HTTP_OK,
- "tip 2",
- "EUR:5.01"),
+ TALER_TESTING_cmd_wallet_get_tip2 ("query-tip-2",
+ merchant_url,
+ "authorize-tip-1",
+ "EUR:0.01",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_tip_pickup ("pickup-tip-2",
+ merchant_url,
+ MHD_HTTP_OK,
+ "authorize-tip-2",
+ pickup_amounts_1),
+
+ TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-tip-3-too-much",
+ merchant_url,
+ MHD_HTTP_BAD_REQUEST,
+ "authorize-tip-1",
+ pickup_amounts_1,
+ TALER_EC_TIP_PICKUP_AMOUNT_EXCEEDS_TIP_REMAINING),
+
+ TALER_TESTING_cmd_tip_pickup ("pickup-tip-4",
+ merchant_url,
+ MHD_HTTP_OK,
+ "authorize-tip-1",
+ pickup_amounts_2),
+ TALER_TESTING_cmd_merchant_get_tip_with_pickups ("merchant-get-tip-2",
+ merchant_url,
+ "authorize-tip-1",
+ pickup_refs,
+ MHD_HTTP_OK),
+
/* This command tests the authorization of tip
* against a reserve that does not exist. This is
* implemented by passing a "tip instance" that
* specifies a reserve key that was never used to
* actually create a reserve. *///
- TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-null",
- merchant_url_internal ("nulltip"),
- EXCHANGE_URL,
- MHD_HTTP_SERVICE_UNAVAILABLE,
- "tip 2",
- "EUR:5.01",
- TALER_EC_TIP_QUERY_RESERVE_UNKNOWN_TO_EXCHANGE),
- TALER_TESTING_cmd_tip_query ("query-tip-1",
- merchant_url_internal ("tip"),
- MHD_HTTP_OK),
- TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-2",
- merchant_url_internal ("tip"),
- MHD_HTTP_OK,
- "EUR:0.0", // picked
- "EUR:10.02", // authorized
- "EUR:20.04"),// available
- TALER_TESTING_cmd_tip_pickup ("pickup-tip-1",
- merchant_url_external ("tip"),
- MHD_HTTP_OK,
- "authorize-tip-1",
- pickup_amounts_1),
- TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-3",
- merchant_url_internal ("tip"),
- MHD_HTTP_OK,
- "EUR:5.01", // picked
- NULL, // authorized
- "EUR:15.03"),// available
- TALER_TESTING_cmd_tip_pickup ("pickup-tip-2",
- merchant_url_external ("tip"),
- MHD_HTTP_OK,
- "authorize-tip-2",
- pickup_amounts_1),
- TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-4",
- merchant_url_internal ("tip"),
- MHD_HTTP_OK,
- "EUR:10.02", // pick
- "EUR:10.02", // authorized
- "EUR:10.02"), // available
- TALER_TESTING_cmd_admin_add_incoming_with_instance (
- "create-reserve-insufficient-funds",
- "EUR:1.01",
- &bc.exchange_auth,
- payer_payto,
- "dtip",
- CONFIG_FILE),
- TALER_TESTING_cmd_check_bank_admin_transfer (
- "check_bank_transfer-insufficient-tip-funds",
- "EUR:1.01",
- payer_payto,
- exchange_payto,
- "create-reserve-insufficient-funds"),
- cmd_exec_wirewatch ("wirewatch-insufficient-tip-funds"),
- TALER_TESTING_cmd_tip_authorize_with_ec (
- "authorize-tip-3-insufficient-funds",
- merchant_url_internal ("dtip"),
+ TALER_TESTING_cmd_merchant_post_reserves_fake ("create-reserve-tip-2-fake"),
+ TALER_TESTING_cmd_tip_authorize_from_reserve_with_ec ("authorize-tip-null",
+ merchant_url,
+ EXCHANGE_URL,
+ "create-reserve-tip-2-fake",
+ MHD_HTTP_NOT_FOUND,
+ "tip 3",
+ "EUR:5.01",
+ TALER_EC_TIP_AUTHORIZE_DB_RESERVE_NOT_FOUND),
+
+ // Test reserve with insufficient funds
+ TALER_TESTING_cmd_merchant_post_reserves ("create-reserve-tip-2",
+ merchant_url,
+ "EUR:1.04",
+ EXCHANGE_URL,
+ "x-taler-bank",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-tip-2-exch",
+ "EUR:1.04",
+ &bc.exchange_auth,
+ payer_payto,
+ "create-reserve-tip-2"),
+ cmd_exec_wirewatch ("wirewatch-4"),
+ TALER_TESTING_cmd_tip_authorize_from_reserve_with_ec (
+ "authorize-tip-insufficient-funds",
+ merchant_url,
EXCHANGE_URL,
+ "create-reserve-tip-2",
MHD_HTTP_PRECONDITION_FAILED,
- "tip 3",
- "EUR:2.02",
+ "tip 4",
+ "EUR:5.01",
TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS),
- TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-4-unknown-instance",
- merchant_url_internal ("unknown"),
- EXCHANGE_URL,
- MHD_HTTP_NOT_FOUND,
- "tip 4",
- "EUR:5.01",
- TALER_EC_INSTANCE_UNKNOWN),
- TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-5-notip-instance",
- merchant_url,
- EXCHANGE_URL,
- MHD_HTTP_PRECONDITION_FAILED,
- "tip 5",
- "EUR:5.01",
- TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP),
- TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-tip-3-too-much",
- merchant_url_external ("tip"),
- MHD_HTTP_CONFLICT,
- "authorize-tip-1",
- pickup_amounts_1,
- TALER_EC_TIP_PICKUP_NO_FUNDS),
+
TALER_TESTING_cmd_tip_authorize_fake ("fake-tip-authorization"),
TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-non-existent-id",
- merchant_url_external ("tip"),
+ merchant_url,
MHD_HTTP_NOT_FOUND,
"fake-tip-authorization",
pickup_amounts_1,
TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN),
+
+ TALER_TESTING_cmd_merchant_delete_reserve ("delete-reserve-tip-1",
+ merchant_url,
+ "create-reserve-tip-1",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_purge_reserve ("delete-reserve-tip-2",
+ merchant_url,
+ "create-reserve-tip-1",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_purge_reserve ("delete-reserve-tip-3",
+ merchant_url,
+ "create-reserve-tip-1",
+ MHD_HTTP_NOT_FOUND),
+#if 0
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-tip-1",
merchant_url_internal ("tip"),
MHD_HTTP_OK,