diff options
Diffstat (limited to 'src/testing/test_merchant_api.c')
-rw-r--r-- | src/testing/test_merchant_api.c | 177 |
1 files changed, 70 insertions, 107 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 74cb5cdb..6a1c41f2 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -73,32 +73,27 @@ 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; +static const char *merchant_payto; /** - * Configuration of the bank. + * Credentials for the test. */ -static struct TALER_TESTING_BankConfiguration bc; - -/** - * Configuration of the exchange. - */ -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 +101,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" @@ -133,29 +123,29 @@ static struct GNUNET_OS_Process *merchantd; /** * Payto URIs to use for testing accounts on the merchant. */ -const char *payto_uris[] = { +static 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", @@ -214,7 +204,7 @@ cmd_transfer_to_exchange (const char *label, { return TALER_TESTING_cmd_admin_add_incoming (label, amount, - &bc.exchange_auth, + &cred.ba, payer_payto); } @@ -317,6 +307,7 @@ run (void *cls, NULL, "1"), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1", + cred.cfg, merchant_url, MHD_HTTP_OK, "1", @@ -336,6 +327,7 @@ run (void *cls, 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", @@ -348,6 +340,7 @@ run (void *cls, "", "create-proposal-1"), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1x", + cred.cfg, merchant_url, MHD_HTTP_OK, "1x", @@ -375,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", @@ -488,7 +482,7 @@ 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", @@ -628,6 +622,7 @@ 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", @@ -640,6 +635,7 @@ run (void *cls, "", /* locks */ NULL), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx", + cred.cfg, merchant_url, MHD_HTTP_NOT_FOUND, "order-p3", @@ -653,6 +649,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", @@ -665,6 +662,7 @@ run (void *cls, "", NULL), TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3", + cred.cfg, merchant_url, MHD_HTTP_OK, "order-p3", @@ -681,6 +679,7 @@ run (void *cls, "1", MHD_HTTP_CONFLICT), TALER_TESTING_cmd_merchant_post_orders ("create-proposal-no-id", + cred.cfg, merchant_url, MHD_HTTP_OK, NULL, @@ -696,6 +695,7 @@ run (void *cls, }; struct TALER_TESTING_Command double_spending[] = { TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2", + cred.cfg, merchant_url, MHD_HTTP_OK, "2", @@ -753,6 +753,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", @@ -855,6 +856,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", @@ -899,6 +901,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", @@ -1028,7 +1031,7 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-tip-1-exch", "EUR:20.04", - &bc.exchange_auth, + &cred.ba, payer_payto, "create-reserve-tip-1", MHD_HTTP_OK), @@ -1154,7 +1157,7 @@ run (void *cls, MHD_HTTP_OK), TALER_TESTING_cmd_admin_add_incoming_with_ref ("create-reserve-tip-2-exch", "EUR:1.04", - &bc.exchange_auth, + &cred.ba, payer_payto, "create-reserve-tip-2", MHD_HTTP_OK), @@ -1230,6 +1233,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", @@ -1294,6 +1298,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", @@ -1629,21 +1634,19 @@ run (void *cls, 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_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, + true, + true), + TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"), TALER_TESTING_cmd_batch ("orders-id", get_private_order_id), TALER_TESTING_cmd_config ("config", @@ -1987,9 +1990,8 @@ run (void *cls, TALER_TESTING_cmd_end () }; - TALER_TESTING_run_with_fakebank (is, - commands, - bc.exchange_auth.wire_gateway_url); + TALER_TESTING_run (is, + commands); } @@ -1997,76 +1999,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_TESTING_get_testname_from_underscore (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); } |