diff options
Diffstat (limited to 'src/testing/test_merchant_api.c')
-rw-r--r-- | src/testing/test_merchant_api.c | 1410 |
1 files changed, 773 insertions, 637 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index a04bbe57..3f9136bc 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -24,6 +24,7 @@ * @author Marcello Stanisci */ #include "platform.h" +#include <gnunet/gnunet_time_lib.h> #include <taler/taler_util.h> #include <taler/taler_signatures.h> #include <taler/taler_exchange_service.h> @@ -66,39 +67,30 @@ static char *config_file; */ #define EXCHANGE_URL "http://localhost:8081/" -static const char *pickup_amounts_1[] = {"EUR:5", NULL}; - -static const char *pickup_amounts_2[] = {"EUR:0.01", NULL}; - /** * Payto URI of the customer (payer). */ -static char *payer_payto; +static const char *payer_payto; /** * Payto URI of the exchange (escrow account). */ -static char *exchange_payto; +static const char *exchange_payto; /** * Payto URI of the merchant (receiver). */ -static char *merchant_payto; - -/** - * Configuration of the bank. - */ -static struct TALER_TESTING_BankConfiguration bc; +static const char *merchant_payto; /** - * Configuration of the exchange. + * Credentials for the test. */ -static struct TALER_TESTING_ExchangeConfiguration ec; +static struct TALER_TESTING_Credentials cred; /** * Merchant base URL. */ -static char *merchant_url; +static const char *merchant_url; /** * Merchant instance "i1a" base URL. @@ -106,11 +98,6 @@ static char *merchant_url; static char *merchant_url_i1a; /** - * Merchant process. - */ -static struct GNUNET_OS_Process *merchantd; - -/** * Account number of the exchange at the bank. */ #define EXCHANGE_ACCOUNT_NAME "2" @@ -130,38 +117,41 @@ static struct GNUNET_OS_Process *merchantd; */ #define MERCHANT_ACCOUNT_NAME "3" -/** - * Payto URIs to use for testing accounts on the merchant. - */ -const char *payto_uris[] = { - PAYTO_I1, - "payto://iban/CH9300762011623852957?receiver-name=Test" - /* Just for testing account inactivation. */ -}; - -const char *order_1_transfers[] = { +static const char *order_1_transfers[] = { "post-transfer-1", NULL }; -const char *order_1_forgets_1[] = { +static const char *order_1_forgets_1[] = { "forget-1", NULL }; -const char *order_1_forgets_2[] = { +static const char *order_1_forgets_2[] = { "forget-1", "forget-order-array-elem", NULL }; -const char *order_1_forgets_3[] = { +static const char *order_1_forgets_3[] = { "forget-1", "forget-order-array-elem", "forget-order-array-wc", NULL }; +/** + * Execute the taler-merchant-webhook command with + * our configuration file. + * + * @param label label to use for the command. + */ +static struct TALER_TESTING_Command +cmd_webhook (const char *label) +{ + return TALER_TESTING_cmd_webhook (label, config_file); +} + /** * Execute the taler-exchange-wirewatch command with @@ -202,7 +192,7 @@ cmd_transfer_to_exchange (const char *label, { return TALER_TESTING_cmd_admin_add_incoming (label, amount, - &bc.exchange_auth, + &cred.ba, payer_payto); } @@ -221,15 +211,28 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_instances ("instance-create-default", merchant_url, "default", - PAYTO_I1, - "EUR", MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_account ( + "instance-create-default-account", + merchant_url, + PAYTO_I1, + NULL, NULL, + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_kyc_get ("instance-create-kyc-0", merchant_url, NULL, NULL, EXCHANGE_URL, - MHD_HTTP_NO_CONTENT), + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), + TALER_TESTING_cmd_merchant_post_orders_no_claim ( + "create-proposal-bad-currency", + merchant_url, + MHD_HTTP_BAD_REQUEST, + "4", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "CHF:5.0"), TALER_TESTING_cmd_merchant_post_orders_no_claim ("create-proposal-4", merchant_url, MHD_HTTP_OK, @@ -304,9 +307,10 @@ run (void *cls, NULL, "1"), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1", + cred.cfg, merchant_url, MHD_HTTP_OK, - "1", /* order ID */ + "1", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, true, @@ -315,10 +319,18 @@ run (void *cls, "", "", NULL), + TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-pay-w1", + merchant_url, + "webhook-pay-1", + "pay", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_testserver ("launch-http-server-for-webhooks", + 12345), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1-idem", + cred.cfg, merchant_url, MHD_HTTP_OK, - "1", /* order ID */ + "1", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, true, @@ -328,9 +340,10 @@ run (void *cls, "", "create-proposal-1"), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1x", + cred.cfg, merchant_url, MHD_HTTP_OK, - "1x", /* order ID */ + "1x", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, true, @@ -355,6 +368,7 @@ run (void *cls, "create-proposal-1x", NULL), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1-pre-exists", + cred.cfg, merchant_url, MHD_HTTP_CONFLICT, "1", @@ -414,6 +428,13 @@ run (void *cls, MHD_HTTP_OK, NULL, "poll-order-wallet-start-1"), + /* Check for webhook */ + cmd_webhook ("pending-webhooks-pay-w1"), + /* Check webhook did anything: have a command that inspects traits of the testserver + and check if the traits have the right values set! */ + TALER_TESTING_cmd_checkserver ("check-http-server-for-webhooks", + "launch-http-server-for-webhooks", + 0), /* Here we expect to run into a timeout, as we do not pay this one */ TALER_TESTING_cmd_wallet_poll_order_conclude2 ("poll-order-1x-conclude", MHD_HTTP_PAYMENT_REQUIRED, @@ -424,7 +445,7 @@ run (void *cls, merchant_url, "deposit-simple", "session-1", - MHD_HTTP_NO_CONTENT), + MHD_HTTP_OK), TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1-2", merchant_url, "create-proposal-1", @@ -432,7 +453,7 @@ run (void *cls, false, false, MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1-2", + TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1-2a", merchant_url, "create-proposal-1", TALER_MERCHANT_OSC_PAID, @@ -461,23 +482,25 @@ run (void *cls, exchange_payto, merchant_payto), TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1", - &bc.exchange_auth, + &cred.ba, PAYTO_I1, merchant_url, "EUR:4.98", - MHD_HTTP_OK, + MHD_HTTP_NO_CONTENT, "deposit-simple", NULL), + TALER_TESTING_cmd_run_tme ("run taler-merchant-exchange-1", + config_file), TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad", merchant_url, PAYTO_I1, "EUR:4.98", - NULL /* random WTID */, - /* non-routable IP address, - so we are sure to not get - any reply */ + NULL, + /*non-routable IP address + so we are sure to not get + any reply*/ "http://192.0.2.1/404/", - MHD_HTTP_GATEWAY_TIMEOUT), + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1", merchant_url, PAYTO_I1, @@ -489,19 +512,19 @@ run (void *cls, merchant_url, "post-transfer-bad", MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2", + TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2b", merchant_url, "create-proposal-1", TALER_MERCHANT_OSC_PAID, true, - order_1_transfers, + order_1_transfers, /* "post-transfer-1" */ false, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_forget_order ("forget-1", merchant_url, - MHD_HTTP_OK, + MHD_HTTP_NO_CONTENT, "create-proposal-1", NULL, "$.dummy_obj", @@ -532,7 +555,7 @@ run (void *cls, NULL), TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-elem", merchant_url, - MHD_HTTP_OK, + MHD_HTTP_NO_CONTENT, "create-proposal-1", NULL, "$.dummy_array[0].item", @@ -549,7 +572,7 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-wc", merchant_url, - MHD_HTTP_OK, + MHD_HTTP_NO_CONTENT, "create-proposal-1", NULL, "$.dummy_array[*].item", @@ -577,6 +600,20 @@ run (void *cls, "a product", "EUR:1", MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_products2 ("post-products-p4", + merchant_url, + "product-4age", + "an age-restricted product", + NULL, + "unit", + "EUR:1", + "", /* image */ + NULL, + 4, + 16 /* minimum age */, + NULL, + GNUNET_TIME_UNIT_FOREVER_TS, + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_patch_product ("patch-products-p3", merchant_url, "product-3", @@ -599,18 +636,20 @@ run (void *cls, 2, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-wm-nx", + cred.cfg, merchant_url, MHD_HTTP_NOT_FOUND, "order-p3", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, - true, /* claim token */ + true, "EUR:5.0", "unsupported-wire-method", "product-3/2", "", /* locks */ - NULL /* duplicate_of */), + NULL), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx", + cred.cfg, merchant_url, MHD_HTTP_NOT_FOUND, "order-p3", @@ -624,6 +663,7 @@ run (void *cls, NULL), TALER_TESTING_cmd_merchant_post_orders2 ( "create-proposal-p3-not-enough-stock", + cred.cfg, merchant_url, MHD_HTTP_GONE, "order-p3", @@ -636,6 +676,7 @@ run (void *cls, "", NULL), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3", + cred.cfg, merchant_url, MHD_HTTP_OK, "order-p3", @@ -647,23 +688,47 @@ run (void *cls, "product-3/3", "lock-product-p3", NULL), + TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p4-age", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "order-p4-age", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + false, + "EUR:5.0", + "x-taler-bank", + "product-4age", + "", /* locks */ + NULL), + TALER_TESTING_cmd_merchant_get_order4 ("get-order-merchant-p4-age", + merchant_url, + "create-proposal-p4-age", + TALER_MERCHANT_OSC_CLAIMED, + 16, + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_delete_order ("delete-order-paid", merchant_url, "1", MHD_HTTP_CONFLICT), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-no-id", + cred.cfg, merchant_url, MHD_HTTP_OK, NULL, GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, "EUR:5.0"), + TALER_TESTING_cmd_merchant_delete_webhook ("post-webhooks-pay-w1", + merchant_url, + "webhook-pay-1", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"), TALER_TESTING_cmd_end () }; - struct TALER_TESTING_Command double_spending[] = { TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2", + cred.cfg, merchant_url, MHD_HTTP_OK, "2", @@ -721,6 +786,7 @@ run (void *cls, "EUR:0", MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1r", + cred.cfg, merchant_url, MHD_HTTP_OK, "1r", @@ -823,6 +889,7 @@ run (void *cls, /* Test /refund on a contract that was never paid. */ TALER_TESTING_cmd_merchant_post_orders ("create-proposal-not-to-be-paid", + cred.cfg, merchant_url, MHD_HTTP_OK, "1-unpaid", @@ -867,6 +934,7 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_orders ( "create-proposal-unincreased-refund", + cred.cfg, merchant_url, MHD_HTTP_OK, "unincreased-proposal", @@ -897,9 +965,13 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1a", merchant_url, "i1a", - PAYTO_I1, - "EUR", MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_account ( + "instance-create-i1a-account", + merchant_url_i1a, + PAYTO_I1, + NULL, NULL, + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1", merchant_url_i1a, "nx-product", @@ -987,183 +1059,6 @@ run (void *cls, TALER_TESTING_cmd_end () }; - struct TALER_TESTING_Command tip[] = { - TALER_TESTING_cmd_merchant_post_reserves ("create-reserve-tip-1", - merchant_url, - "EUR:20.04", - EXCHANGE_URL, - "x-taler-bank", - MHD_HTTP_OK), - TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-tip-1-exch", - "EUR:20.04", - &bc.exchange_auth, - payer_payto, - "create-reserve-tip-1", - MHD_HTTP_OK), - /* We need to wait until the merchant re-tries fetching the - reserve from the exchange. */ - cmd_exec_wirewatch ("wirewatch-3"), - TALER_TESTING_cmd_sleep ("tip-sleep", 3), - TALER_TESTING_cmd_tip_authorize ("authorize-tip-1", - merchant_url, - EXCHANGE_URL, - MHD_HTTP_OK, - "tip 1", - "EUR:5.01"), - TALER_TESTING_cmd_tip_authorize_from_reserve ("authorize-tip-2", - merchant_url, - EXCHANGE_URL, - "create-reserve-tip-1-exch", - MHD_HTTP_OK, - "tip 2", - "EUR:5.01"), - TALER_TESTING_cmd_wallet_get_tip ("get-tip-1", - merchant_url, - "authorize-tip-1", - MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_get_tip ("merchant-get-tip-1", - merchant_url, - "authorize-tip-1", - MHD_HTTP_OK), - TALER_TESTING_cmd_get_tips ("get-tips-1", - merchant_url, - MHD_HTTP_OK, - "authorize-tip-2", - "authorize-tip-1", - NULL), - TALER_TESTING_cmd_get_tips2 ("get-tips-1-asc", - merchant_url, - 0, - 20, - MHD_HTTP_OK, - "authorize-tip-1", - "authorize-tip-2", - NULL), - TALER_TESTING_cmd_get_tips2 ("get-tips-1-asc-offset", - merchant_url, - 1, - 20, - MHD_HTTP_OK, - "authorize-tip-2", - NULL), - TALER_TESTING_cmd_merchant_get_reserves ("get-reserves-1", - merchant_url, - MHD_HTTP_OK, - "create-reserve-tip-1-exch", - NULL), - TALER_TESTING_cmd_merchant_get_reserve ("get-reserve-1", - merchant_url, - MHD_HTTP_OK, - "create-reserve-tip-1-exch"), - TALER_TESTING_cmd_merchant_get_reserve_with_tips ("get-reserve-2", - merchant_url, - MHD_HTTP_OK, - "create-reserve-tip-1-exch", - "authorize-tip-1", - "authorize-tip-2", - NULL), - TALER_TESTING_cmd_tip_pickup ("pickup-tip-1", - merchant_url, - MHD_HTTP_OK, - "authorize-tip-1", - pickup_amounts_1), - 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_MERCHANT_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", - MHD_HTTP_OK, - "pickup-tip-1", - "pickup-tip-4", - NULL), - - /* 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_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_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_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", - MHD_HTTP_OK), - 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 4", - "EUR:5.01", - TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS), - TALER_TESTING_cmd_tip_authorize_fake ("fake-tip-authorization"), - TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-non-existent-id", - merchant_url, - MHD_HTTP_NOT_FOUND, - "fake-tip-authorization", - pickup_amounts_1, - TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN), - TALER_TESTING_cmd_merchant_get_reserves ("get-reserves-2", - merchant_url, - MHD_HTTP_OK, - "create-reserve-tip-1", - "create-reserve-tip-2", - NULL), - 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), - TALER_TESTING_cmd_end () - }; - struct TALER_TESTING_Command pay_again[] = { cmd_transfer_to_exchange ("create-reserve-20", "EUR:20.04"), @@ -1198,6 +1093,7 @@ run (void *cls, "EUR:0", MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10", + cred.cfg, merchant_url, MHD_HTTP_OK, "10", @@ -1262,6 +1158,7 @@ run (void *cls, "EUR:0", MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-11", + cred.cfg, merchant_url, MHD_HTTP_OK, "11", @@ -1270,7 +1167,7 @@ run (void *cls, "EUR:10.0"), TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-good", merchant_url, - MHD_HTTP_NOT_ACCEPTABLE, + MHD_HTTP_BAD_REQUEST, "create-proposal-11", "withdraw-coin-11a", "EUR:5", @@ -1294,6 +1191,38 @@ run (void *cls, }; struct TALER_TESTING_Command templates[] = { + cmd_transfer_to_exchange ("create-reserve-20x", + "EUR:20.04"), + cmd_exec_wirewatch ("wirewatch-20x"), + TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-20x", + "EUR:20.04", + payer_payto, + exchange_payto, + "create-reserve-20x"), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xa", + "create-reserve-20x", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xb", + "create-reserve-20x", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xc", + "create-reserve-20x", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xd", + "create-reserve-20x", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_status ("withdraw-status-20x", + "create-reserve-20x", + "EUR:0", + MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_templates ("get-templates-empty", merchant_url, MHD_HTTP_OK, @@ -1333,11 +1262,11 @@ run (void *cls, merchant_url, "template-2", "another template", - "data:image/jpeg;base64,RAWDATA", + NULL, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("minimum_age", 0), - GNUNET_JSON_pack_time_rel ("pay_duration", - GNUNET_TIME_UNIT_MINUTES)), + GNUNET_JSON_pack_uint64 ("minimum_age", 0), + GNUNET_JSON_pack_time_rel ("pay_duration", + GNUNET_TIME_UNIT_MINUTES)), MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_get_template ("get-template-t2", merchant_url, @@ -1349,16 +1278,25 @@ run (void *cls, "template-nx", MHD_HTTP_NOT_FOUND, NULL), + TALER_TESTING_cmd_merchant_post_otp_devices ( + "post-otp-device", + merchant_url, + "otp-dev", + "my OTP device", + "FEE4P2J", + TALER_MCA_WITH_PRICE, + 0, + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_patch_template ( "patch-templates-t3-nx", merchant_url, "template-3", "updated template", - "data:image/jpeg;base64,RAWDATA", + "otp-dev", GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("minimum_age", 0), - GNUNET_JSON_pack_time_rel ("pay_duration", - GNUNET_TIME_UNIT_MINUTES)), + GNUNET_JSON_pack_uint64 ("minimum_age", 0), + GNUNET_JSON_pack_time_rel ("pay_duration", + GNUNET_TIME_UNIT_MINUTES)), MHD_HTTP_NOT_FOUND), TALER_TESTING_cmd_merchant_post_templates2 ( "post-templates-t3-amount", @@ -1367,47 +1305,75 @@ run (void *cls, "a different template with an amount", NULL, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ("minimum_age", 0), - GNUNET_JSON_pack_time_rel ("pay_duration", - GNUNET_TIME_UNIT_MINUTES), - GNUNET_JSON_pack_string ("amount", - "EUR:4")), + GNUNET_JSON_pack_uint64 ("minimum_age", 0), + GNUNET_JSON_pack_time_rel ("pay_duration", + GNUNET_TIME_UNIT_MINUTES), + GNUNET_JSON_pack_string ("amount", + "EUR:4")), MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_using_templates ( "using-templates-t1", "post-templates-t1", + NULL, merchant_url, + "1", "summary-1", - "EUR:10", + "EUR:9.98", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_using_templates ( "using-templates-t1-amount-missing", "post-templates-t1", + NULL, merchant_url, + "2", "summary-1", NULL, + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_CONFLICT), TALER_TESTING_cmd_merchant_post_using_templates ( "using-templates-t1-summary-missing", "post-templates-t1", + NULL, merchant_url, + "3", NULL, "EUR:10", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_CONFLICT), TALER_TESTING_cmd_merchant_post_using_templates ( "using-templates-t1-amount-conflict", "post-templates-t3-amount", + NULL, merchant_url, + "4", "summary-1", "EUR:10", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_CONFLICT), TALER_TESTING_cmd_merchant_post_using_templates ( "using-templates-t1-amount-duplicate", "post-templates-t3-amount", + NULL, merchant_url, + "4", "summary-1", "EUR:4", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_merchant_pay_order ("pay-100", + merchant_url, + MHD_HTTP_OK, + "using-templates-t1", + "withdraw-coin-xa;withdraw-coin-xb", + "EUR:4.99", + "EUR:4.99", + NULL), TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty", merchant_url, "t1", @@ -1419,10 +1385,56 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_using_templates ( "post-templates-t1-deleted", "post-templates-t1", + NULL, merchant_url, + "0", "summary-1", "EUR:5", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_post_otp_devices ( + "post-otp-device", + merchant_url, + "otp-dev-2", + "my OTP device", + "secret", + TALER_MCA_WITH_PRICE, + 0, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_templates2 ( + "post-templates-with-pos-key", + merchant_url, + "template-key", + "a different template with POS KEY", + "otp-dev-2", + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("minimum_age", 0), + GNUNET_JSON_pack_time_rel ("pay_duration", + GNUNET_TIME_UNIT_MINUTES)), + MHD_HTTP_NO_CONTENT), + + TALER_TESTING_cmd_merchant_post_using_templates ( + "using-templates-pos-key", + "post-templates-with-pos-key", + "post-otp-device", + merchant_url, + "1", + "summary-1-pos", + "EUR:9.98", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_pay_order ("pay-with-pos", + merchant_url, + MHD_HTTP_OK, + "using-templates-pos-key", + "withdraw-coin-xc;withdraw-coin-xd", + "EUR:4.99", + "EUR:4.99", + NULL), + + TALER_TESTING_cmd_end () }; @@ -1465,7 +1477,7 @@ run (void *cls, merchant_url, "webhook-2", "Refund2", - "https://example.com", + "http://localhost:38188/", "POST", "Authorization:WHWOXZXPLL", "Amount", @@ -1499,108 +1511,264 @@ run (void *cls, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_end () }; + struct TALER_TESTING_Command repurchase[] = { + cmd_transfer_to_exchange ( + "create-reserve-30x", + "EUR:30.06"), + cmd_exec_wirewatch ( + "wirewatch-30x"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check_bank_transfer-30x", + "EUR:30.06", + payer_payto, + exchange_payto, + "create-reserve-30x"), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-rep", + "create-reserve-30x", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_orders3 ( + "post-order-repurchase-original", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "repurchase-original", + GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES), + GNUNET_TIME_UNIT_FOREVER_TS, + "https://fulfillment.example.com/", + "EUR:1.0"), + TALER_TESTING_cmd_merchant_pay_order ( + "repurchase-pay-first", + merchant_url, + MHD_HTTP_OK, + "post-order-repurchase-original", + "withdraw-coin-rep", + "EUR:1.00", + "EUR:0.99", + "repurchase-session"), + TALER_TESTING_cmd_wallet_get_order ( + "repurchase-wallet-check-primary-order", + merchant_url, + "post-order-repurchase-original", + true, + false, + false, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_order3 ( + "repurchase-check-primary-payment", + merchant_url, + "post-order-repurchase-original", + TALER_MERCHANT_OSC_PAID, + "repurchase-session", + NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_order3 ( + "repurchase-check-primary-payment-bad-binding", + merchant_url, + "post-order-repurchase-original", + TALER_MERCHANT_OSC_CLAIMED, /* someone else has it! */ + "wrong-session", + NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_orders3 ( + "post-order-repurchase-secondary", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "repurchase-secondary", + GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES), + GNUNET_TIME_UNIT_FOREVER_TS, + "https://fulfillment.example.com/", + "EUR:1.0"), + TALER_TESTING_cmd_merchant_get_order3 ( + "repurchase-check-secondary-payment", + merchant_url, + "post-order-repurchase-secondary", + TALER_MERCHANT_OSC_UNPAID, + "repurchase-session", + NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_order3 ( + "repurchase-check-secondary-payment", + merchant_url, + "post-order-repurchase-secondary", + TALER_MERCHANT_OSC_UNPAID, + "repurchase-session", + "post-order-repurchase-original", + MHD_HTTP_OK), + TALER_TESTING_cmd_wallet_get_order2 ( + "repurchase-wallet-check-order-secondary", + merchant_url, + "post-order-repurchase-secondary", + "repurchase-session", + false, + false, + false, + "post-order-repurchase-original", + MHD_HTTP_PAYMENT_REQUIRED), + TALER_TESTING_cmd_wallet_get_order2 ( + "repurchase-wallet-check-order-secondary-bad-session", + merchant_url, + "post-order-repurchase-secondary", + "wrong-session", + false, + false, + false, + NULL, + MHD_HTTP_PAYMENT_REQUIRED), + TALER_TESTING_cmd_merchant_order_refund ( + "refund-repurchased", + merchant_url, + "refund repurchase", + "repurchase-original", + "EUR:1.0", + MHD_HTTP_OK), + TALER_TESTING_cmd_wallet_get_order2 ( + "repurchase-wallet-check-primary-order-refunded-no-session", + merchant_url, + "post-order-repurchase-original", + NULL, + true, + true, + true, + "post-order-repurchase-original", + MHD_HTTP_OK), + TALER_TESTING_cmd_wallet_get_order2 ( + "repurchase-wallet-check-primary-order-refunded", + merchant_url, + "post-order-repurchase-original", + "repurchase-session", + true, + true, + true, + "post-order-repurchase-original", + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_order3 ( + "repurchase-check-refunded", + merchant_url, + "post-order-repurchase-secondary", + TALER_MERCHANT_OSC_CLAIMED, + "repurchase-session", + NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_end () + }; + + struct TALER_TESTING_Command tokens[] = { + /** + * Move money to the exchange's bank account. + */ + cmd_transfer_to_exchange ("create-reserve-tokens", + "EUR:10.02"), + /** + * Make a reserve exist, according to the previous transfer. + */ + cmd_exec_wirewatch ("wirewatch-1"), + TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-tokens", + "EUR:10.02", + payer_payto, + exchange_payto, + "create-reserve-tokens"), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", + "create-reserve-tokens", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", + "create-reserve-tokens", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_tokenfamilies ("create-tokenfamily", + merchant_url, + MHD_HTTP_NO_CONTENT, + "subscription-1", + "Subscription", + "A subscription.", + NULL, + GNUNET_TIME_timestamp_get (), + GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_YEARS), + GNUNET_TIME_UNIT_MONTHS, + "subscription"), + TALER_TESTING_cmd_merchant_post_orders_choices ("create-order-with-choices", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "create-tokenfamily", + "5-choices", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:5.0"), + + TALER_TESTING_cmd_end () + }; struct TALER_TESTING_Command commands[] = { /* general setup */ - TALER_TESTING_cmd_auditor_add ("add-auditor-OK", - MHD_HTTP_NO_CONTENT, - false), - TALER_TESTING_cmd_wire_add ("add-wire-account", - "payto://x-taler-bank/localhost/2?receiver-name=2", - MHD_HTTP_NO_CONTENT, - false), - TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", - config_file), - TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees", - config_file, - "EUR:0.01", - "EUR:0.01"), - TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1), - TALER_TESTING_cmd_batch ("orders-id", - get_private_order_id), - TALER_TESTING_cmd_config ("config", - merchant_url, - MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_get_instances ("instances-empty", - merchant_url, - MHD_HTTP_OK, - NULL), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-default-setup", - merchant_url, - "default", - PAYTO_I1, - "EUR", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1", - merchant_url, - "i1", - PAYTO_I1, - "EUR", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_instances ("instances-get-i1", - merchant_url, - MHD_HTTP_OK, - "instance-create-i1", - "instance-create-default-setup", - NULL), - TALER_TESTING_cmd_merchant_get_instance ("instances-get-i1", - merchant_url, - "i1", - MHD_HTTP_OK, - "instance-create-i1"), - TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1-bad-currency", - merchant_url, - "i1", - 2, - payto_uris, - "bob-the-merchant", - json_pack ("{s:s}", - "street", - "bobstreet"), - json_pack ("{s:s}", - "street", - "bobjuryst"), - "USD:0.1", - 4, - "USD:0.5", - GNUNET_TIME_UNIT_MINUTES, - GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_BAD_REQUEST), - TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-i1", - merchant_url, - "i1", - 2, - payto_uris, - "bob-the-merchant", - json_pack ("{s:s}", - "street", - "bobstreet"), - json_pack ("{s:s}", - "street", - "bobjuryst"), - "EUR:0.1", - 4, - "EUR:0.5", - GNUNET_TIME_UNIT_MINUTES, - GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_instance2 ("instances-get-i1-2", - merchant_url, - "i1", - MHD_HTTP_OK, - "instance-patch-i1", - payto_uris, - 2, - NULL, - 0), + TALER_TESTING_cmd_run_fakebank ( + "run-fakebank", + cred.cfg, + "exchange-account-exchange"), + TALER_TESTING_cmd_system_start ( + "start-taler", + config_file, + "-ema", + "-u", "exchange-account-exchange", + NULL), + TALER_TESTING_cmd_get_exchange ( + "get-exchange", + cred.cfg, + NULL, + true, + true), + TALER_TESTING_cmd_batch ( + "orders-id", + get_private_order_id), + TALER_TESTING_cmd_config ( + "config", + merchant_url, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_instances ( + "instances-empty", + merchant_url, + MHD_HTTP_OK, + NULL), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-default-setup", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_account ( + "instance-create-default-account", + merchant_url, + PAYTO_I1, + NULL, NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-i1", + merchant_url, + "i1", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_get_instances ( + "instances-get-i1", + merchant_url, + MHD_HTTP_OK, + "instance-create-i1", + "instance-create-default-setup", + NULL), + TALER_TESTING_cmd_merchant_get_instance ( + "instances-get-i1", + merchant_url, + "i1", + MHD_HTTP_OK, + "instance-create-i1"), TALER_TESTING_cmd_merchant_patch_instance ( - "instance-patch-i1-inactivate-account", + "instance-patch-i1", merchant_url, "i1", - 1, - payto_uris, "bob-the-merchant", json_pack ("{s:s}", "street", @@ -1608,235 +1776,240 @@ run (void *cls, json_pack ("{s:s}", "street", "bobjuryst"), - "EUR:0.1", - 4, - "EUR:0.5", + true, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES, MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_instance2 ("instances-get-i1-3", - merchant_url, - "i1", - MHD_HTTP_OK, - "instance-patch-i1-inactivate-account", - payto_uris, - 1, - &payto_uris[1], - 1), - TALER_TESTING_cmd_merchant_get_instance ("instances-get-i2-nx", - merchant_url, - "i2", - MHD_HTTP_NOT_FOUND, - NULL), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-bad-currency", - merchant_url, - "i2", - PAYTO_I1, - "USD", - MHD_HTTP_BAD_REQUEST), - TALER_TESTING_cmd_merchant_post_instances2 ("instance-create-ACL", - merchant_url, - "i-acl", - 0, NULL, - "controlled instance", - json_pack ("{s:s}", "city", - "shopcity"), - json_pack ("{s:s}", "city", - "lawyercity"), - "EUR:0.1", - 42, - "EUR:0.2", - GNUNET_TIME_UNIT_MINUTES, - GNUNET_TIME_UNIT_MINUTES, - // FIXME: change this back once - // we have a update auth test CMD - // RFC_8959_PREFIX "EXAMPLE", - NULL, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_patch_instance ("instance-patch-ACL", - merchant_url, - "i-acl", - 1, - payto_uris, - "controlled instance", - json_pack ("{s:s}", - "street", - "bobstreet"), - json_pack ("{s:s}", - "street", - "bobjuryst"), - "EUR:0.1", - 4, - "EUR:0.5", - GNUNET_TIME_UNIT_MINUTES, - GNUNET_TIME_UNIT_MINUTES, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-i2", - merchant_url, - "i2", - PAYTO_I1, - "EUR", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-i2-idem", - merchant_url, - "i2", - PAYTO_I1, - "EUR", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-i2-non-idem", - merchant_url, - "i2", - "payto://other-method/?receiver-name=X", - "EUR", - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_merchant_delete_instance ("instance-delete-i2", - merchant_url, - "i2", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_instance ("instances-get-i2-post-deletion", - merchant_url, - "i2", - MHD_HTTP_NOT_FOUND, - NULL), - TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-then-purge-i2", - merchant_url, - "i2", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_purge_instance ("instance-purge-i1", - merchant_url, - "i1", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_delete_instance ("instance-purge-then-delete-i1", - merchant_url, - "i1", - MHD_HTTP_NOT_FOUND), - TALER_TESTING_cmd_merchant_purge_instance ("instance-purge-i-acl-middle", - merchant_url, - "i-acl", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_purge_instance ("instance-purge-default-middle", - merchant_url, - "default", - MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_get_instance ( + "instances-get-i1-2", + merchant_url, + "i1", + MHD_HTTP_OK, + "instance-patch-i1"), + TALER_TESTING_cmd_merchant_get_instance ( + "instances-get-i2-nx", + merchant_url, + "i2", + MHD_HTTP_NOT_FOUND, + NULL), + TALER_TESTING_cmd_merchant_post_instances2 ( + "instance-create-ACL", + merchant_url, + "i-acl", + "controlled instance", + json_pack ("{s:s}", "city", + "shopcity"), + json_pack ("{s:s}", "city", + "lawyercity"), + true, + GNUNET_TIME_UNIT_MINUTES, + GNUNET_TIME_UNIT_MINUTES, + // FIXME: change this back once + // we have a update auth test CMD + // RFC_8959_PREFIX "EXAMPLE", + NULL, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_patch_instance ( + "instance-patch-ACL", + merchant_url, + "i-acl", + "controlled instance", + json_pack ("{s:s}", + "street", + "bobstreet"), + json_pack ("{s:s}", + "street", + "bobjuryst"), + true, + GNUNET_TIME_UNIT_MINUTES, + GNUNET_TIME_UNIT_MINUTES, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-i2", + merchant_url, + "i2", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-i2-idem", + merchant_url, + "i2", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_delete_instance ( + "instance-delete-i2", + merchant_url, + "i2", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_get_instance ( + "instances-get-i2-post-deletion", + merchant_url, + "i2", + MHD_HTTP_NOT_FOUND, + NULL), + TALER_TESTING_cmd_merchant_purge_instance ( + "instance-delete-then-purge-i2", + merchant_url, + "i2", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_purge_instance ( + "instance-purge-i1", + merchant_url, + "i1", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_delete_instance ( + "instance-purge-then-delete-i1", + merchant_url, + "i1", + MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_purge_instance ( + "instance-purge-i-acl-middle", + merchant_url, + "i-acl", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_purge_instance ( + "instance-purge-default-middle", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_instances ( "instance-create-default-after-purge", merchant_url, "default", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_account ( + "instance-create-default-account-after-purge", + merchant_url, PAYTO_I1, - "EUR", + NULL, NULL, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_products ( + "get-products-empty", + merchant_url, + MHD_HTTP_OK, + NULL), + TALER_TESTING_cmd_merchant_post_products ( + "post-products-p1", + merchant_url, + "product-1", + "a product", + "EUR:1", MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_products ("get-products-empty", - merchant_url, - MHD_HTTP_OK, - NULL), - TALER_TESTING_cmd_merchant_post_products ("post-products-p1", - merchant_url, - "product-1", - "a product", - "EUR:1", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_products ("post-products-p1-idem", - merchant_url, - "product-1", - "a product", - "EUR:1", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_post_products ("post-products-p1-non-idem", - merchant_url, - "product-1", - "a different product", - "EUR:1", - MHD_HTTP_CONFLICT), - TALER_TESTING_cmd_merchant_get_products ("get-products-p1", - merchant_url, - MHD_HTTP_OK, - "post-products-p1", - NULL), - TALER_TESTING_cmd_merchant_get_product ("get-product-p1", - merchant_url, - "product-1", - MHD_HTTP_OK, - "post-products-p1"), - TALER_TESTING_cmd_merchant_post_products ("post-products-p2", - merchant_url, - "product-2", - "a product", - "EUR:1", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_patch_product ("patch-products-p2", - merchant_url, - "product-2", - "another product", - json_pack ("{s:s}", "en", "text"), - "kg", - "EUR:1", - "data:image/jpeg;base64,RAWDATA", - json_array (), - 40, - 0, - json_pack ("{s:s}", - "street", - "pstreet"), - GNUNET_TIME_relative_to_timestamp ( - GNUNET_TIME_UNIT_MINUTES), - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_get_product ("get-product-p2", - merchant_url, - "product-2", - MHD_HTTP_OK, - "patch-products-p2"), - TALER_TESTING_cmd_merchant_get_product ("get-product-nx", - merchant_url, - "product-nx", - MHD_HTTP_NOT_FOUND, - NULL), - TALER_TESTING_cmd_merchant_patch_product ("patch-products-p3-nx", - merchant_url, - "product-3", - "nx updated product", - json_pack ("{s:s}", "en", "text"), - "kg", - "EUR:1", - "data:image/jpeg;base64,RAWDATA", - json_array (), - 40, - 0, - json_pack ("{s:s}", - "street", - "pstreet"), - GNUNET_TIME_relative_to_timestamp ( - GNUNET_TIME_UNIT_MINUTES), - MHD_HTTP_NOT_FOUND), - TALER_TESTING_cmd_merchant_delete_product ("get-products-empty", - merchant_url, - "p1", - MHD_HTTP_NOT_FOUND), - TALER_TESTING_cmd_merchant_delete_product ("get-products-empty", - merchant_url, - "product-1", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_lock_product ("lock-product-p2", - merchant_url, - "product-2", - GNUNET_TIME_UNIT_MINUTES, - 2, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_lock_product ("lock-product-nx", - merchant_url, - "product-nx", - GNUNET_TIME_UNIT_MINUTES, - 2, - MHD_HTTP_NOT_FOUND), - TALER_TESTING_cmd_merchant_lock_product ("lock-product-too-much", - merchant_url, - "product-2", - GNUNET_TIME_UNIT_MINUTES, - 39, - MHD_HTTP_GONE), - TALER_TESTING_cmd_merchant_delete_product ("delete-product-locked", - merchant_url, - "product-2", - MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_merchant_post_products ( + "post-products-p1-idem", + merchant_url, + "product-1", + "a product", + "EUR:1", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_products ( + "post-products-p1-non-idem", + merchant_url, + "product-1", + "a different product", + "EUR:1", + MHD_HTTP_CONFLICT), + TALER_TESTING_cmd_merchant_get_products ( + "get-products-p1", + merchant_url, + MHD_HTTP_OK, + "post-products-p1", + NULL), + TALER_TESTING_cmd_merchant_get_product ( + "get-product-p1", + merchant_url, + "product-1", + MHD_HTTP_OK, + "post-products-p1"), + TALER_TESTING_cmd_merchant_post_products ( + "post-products-p2", + merchant_url, + "product-2", + "a product", + "EUR:1", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_patch_product ( + "patch-products-p2", + merchant_url, + "product-2", + "another product", + json_pack ("{s:s}", "en", "text"), + "kg", + "EUR:1", + "data:image/jpeg;base64,RAWDATA", + json_array (), + 40, + 0, + json_pack ("{s:s}", + "street", + "pstreet"), + GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_UNIT_MINUTES), + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_get_product ( + "get-product-p2", + merchant_url, + "product-2", + MHD_HTTP_OK, + "patch-products-p2"), + TALER_TESTING_cmd_merchant_get_product ( + "get-product-nx", + merchant_url, + "product-nx", + MHD_HTTP_NOT_FOUND, + NULL), + TALER_TESTING_cmd_merchant_patch_product ( + "patch-products-p3-nx", + merchant_url, + "product-3", + "nx updated product", + json_pack ("{s:s}", "en", "text"), + "kg", + "EUR:1", + "data:image/jpeg;base64,RAWDATA", + json_array (), + 40, + 0, + json_pack ("{s:s}", + "street", + "pstreet"), + GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_UNIT_MINUTES), + MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_delete_product ( + "get-products-empty", + merchant_url, + "p1", + MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_delete_product ( + "get-products-empty", + merchant_url, + "product-1", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_lock_product ( + "lock-product-p2", + merchant_url, + "product-2", + GNUNET_TIME_UNIT_MINUTES, + 2, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_lock_product ( + "lock-product-nx", + merchant_url, + "product-nx", + GNUNET_TIME_UNIT_MINUTES, + 2, + MHD_HTTP_NOT_FOUND), + TALER_TESTING_cmd_merchant_lock_product ( + "lock-product-too-much", + merchant_url, + "product-2", + GNUNET_TIME_UNIT_MINUTES, + 39, + MHD_HTTP_GONE), + TALER_TESTING_cmd_merchant_delete_product ( + "delete-product-locked", + merchant_url, + "product-2", + MHD_HTTP_CONFLICT), TALER_TESTING_cmd_batch ("pay", pay), TALER_TESTING_cmd_batch ("double-spending", @@ -1847,23 +2020,24 @@ run (void *cls, pay_abort), TALER_TESTING_cmd_batch ("refund", refund), - TALER_TESTING_cmd_batch ("tip", - tip), - TALER_TESTING_cmd_batch ("auth", - auth), TALER_TESTING_cmd_batch ("templates", templates), TALER_TESTING_cmd_batch ("webhooks", webhooks), + TALER_TESTING_cmd_batch ("auth", + auth), + TALER_TESTING_cmd_batch ("repurchase", + repurchase), + TALER_TESTING_cmd_batch ("tokens", + tokens), /** * End the suite. */ TALER_TESTING_cmd_end () }; - TALER_TESTING_run_with_fakebank (is, - commands, - bc.exchange_auth.wire_gateway_url); + TALER_TESTING_run (is, + commands); } @@ -1871,75 +2045,37 @@ int main (int argc, char *const *argv) { - char *cipher; - enum GNUNET_GenericReturnValue ret; - - /* These environment variables get in the way... */ - unsetenv ("XDG_DATA_HOME"); - unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup (argv[0], - "INFO", - NULL); - cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]); - GNUNET_assert (NULL != cipher); - GNUNET_asprintf (&config_file, - "test_merchant_api-%s.conf", - cipher); - GNUNET_free (cipher); - if (GNUNET_OK != - TALER_TESTING_prepare_fakebank (config_file, - "exchange-account-exchange", - &bc)) - return 77; + { + char *cipher; + cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]); + GNUNET_assert (NULL != cipher); + GNUNET_asprintf (&config_file, + "test_merchant_api-%s.conf", + cipher); + GNUNET_free (cipher); + } payer_payto = - ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=" - USER_ACCOUNT_NAME); + "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=" + USER_ACCOUNT_NAME; exchange_payto = - ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME "?receiver-name=" - EXCHANGE_ACCOUNT_NAME); + "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME "?receiver-name=" + EXCHANGE_ACCOUNT_NAME; merchant_payto = - ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME "?receiver-name=" - MERCHANT_ACCOUNT_NAME); - - if (NULL == - (merchant_url = TALER_TESTING_prepare_merchant (config_file))) - return 77; + "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME "?receiver-name=" + MERCHANT_ACCOUNT_NAME; + merchant_url = "http://localhost:8080/"; GNUNET_asprintf (&merchant_url_i1a, "%sinstances/i1a/", merchant_url); - TALER_TESTING_cleanup_files (config_file); - switch (TALER_TESTING_prepare_exchange (config_file, - GNUNET_YES, - &ec)) - { - case GNUNET_SYSERR: - GNUNET_break (0); - return 1; - case GNUNET_NO: - return 77; - case GNUNET_OK: - if (NULL == (merchantd = - TALER_TESTING_run_merchant (config_file, - merchant_url))) - return 1; - - ret = TALER_TESTING_setup_with_exchange (&run, - NULL, - config_file); - - GNUNET_OS_process_kill (merchantd, SIGTERM); - GNUNET_OS_process_wait (merchantd); - GNUNET_OS_process_destroy (merchantd); - GNUNET_free (merchant_url); - if (GNUNET_OK != ret) - return 1; - break; - default: - GNUNET_break (0); - return 1; - } - return 0; + return TALER_TESTING_main (argv, + "INFO", + config_file, + "exchange-account-exchange", + TALER_TESTING_BS_FAKEBANK, + &cred, + &run, + NULL); } |