summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_api_twisted.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_merchant_api_twisted.c')
-rw-r--r--src/testing/test_merchant_api_twisted.c195
1 files changed, 78 insertions, 117 deletions
diff --git a/src/testing/test_merchant_api_twisted.c b/src/testing/test_merchant_api_twisted.c
index 73b6905b..446e6eb3 100644
--- a/src/testing/test_merchant_api_twisted.c
+++ b/src/testing/test_merchant_api_twisted.c
@@ -1,6 +1,6 @@
/**
* This file is part of TALER
- * Copyright (C) 2014-2018 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
@@ -16,7 +16,6 @@
* License along with TALER; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>
*/
-
/**
* @file test_merchant_api_twisted.c
* @brief testcase to test exchange's HTTP API interface
@@ -63,7 +62,7 @@ static char *config_file;
#define USER_ACCOUNT_NAME "62"
-#define PAYTO_I1 "payto://x-taler-bank/localhost/3"
+#define PAYTO_I1 "payto://x-taler-bank/localhost/3?receiver-name=user3"
/**
@@ -108,12 +107,7 @@ static char *twister_merchant_url_instance_tor;
/**
* Merchant base URL.
*/
-static char *merchant_url;
-
-/**
- * Merchant process.
- */
-static struct GNUNET_OS_Process *merchantd;
+static const char *merchant_url;
/**
* Twister process that proxies the exchange.
@@ -126,11 +120,10 @@ static struct GNUNET_OS_Process *twisterexchanged;
static struct GNUNET_OS_Process *twistermerchantd;
-static char *payer_payto;
-static char *exchange_payto;
-static char *merchant_payto;
-static struct TALER_TESTING_BankConfiguration bc;
-static struct TALER_TESTING_ExchangeConfiguration ec;
+static const char *payer_payto;
+static const char *exchange_payto;
+static const char *merchant_payto;
+static struct TALER_TESTING_Credentials cred;
/**
* User name. Never checked by fakebank.
@@ -180,7 +173,7 @@ CMD_TRANSFER_TO_EXCHANGE (const char *label,
{
return TALER_TESTING_cmd_admin_add_incoming (label,
amount,
- &bc.exchange_auth,
+ &cred.ba,
payer_payto);
}
@@ -222,6 +215,7 @@ run (void *cls,
"EUR:0",
MHD_HTTP_OK),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-abort-1",
+ cred.cfg,
twister_merchant_url,
MHD_HTTP_OK,
"abort-one",
@@ -232,7 +226,7 @@ run (void *cls,
* so we'll then have the right to abort. */
TALER_TESTING_cmd_merchant_pay_order ("deposit-simple-for-abort",
twister_merchant_url,
- MHD_HTTP_NOT_ACCEPTABLE,
+ MHD_HTTP_BAD_REQUEST,
"create-proposal-abort-1",
"withdraw-coin-abort-1",
"EUR:1.01",
@@ -279,6 +273,7 @@ run (void *cls,
"EUR:1.01"),
CMD_EXEC_WIREWATCH ("wirewatch-double-spend"),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-double-spend",
+ cred.cfg,
twister_merchant_url,
MHD_HTTP_OK,
"DS-1",
@@ -286,6 +281,7 @@ run (void *cls,
GNUNET_TIME_UNIT_FOREVER_TS,
"EUR:1.0"),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-double-spend-1",
+ cred.cfg,
twister_merchant_url,
MHD_HTTP_OK,
"DS-2",
@@ -325,27 +321,29 @@ 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",
- 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,
+ NULL,
+ true,
+ true),
TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
twister_merchant_url,
"default",
- PAYTO_I1,
- "EUR",
MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_post_account (
+ "instance-create-default-account",
+ twister_merchant_url,
+ PAYTO_I1,
+ NULL, NULL,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_batch ("pay",
pay),
/* Malform the response from the exchange. */
@@ -358,7 +356,7 @@ run (void *cls,
* Make a reserve exist,
* according to the previous
* transfer.
- *///
+ */
CMD_EXEC_WIREWATCH ("wirewatch-1"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2",
"EUR:10.02",
@@ -394,6 +392,7 @@ run (void *cls,
"create-proposal-1",
NULL),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
+ cred.cfg,
merchant_url,
MHD_HTTP_OK,
"2",
@@ -402,7 +401,7 @@ run (void *cls,
"EUR:6.0"),
TALER_TESTING_cmd_merchant_pay_order ("deposit-2",
merchant_url,
- MHD_HTTP_NOT_ACCEPTABLE,
+ MHD_HTTP_BAD_REQUEST,
"create-proposal-2",
"withdraw-coin-1",
"EUR:5",
@@ -417,9 +416,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);
}
@@ -431,7 +429,8 @@ run (void *cls,
static void
purge_process (struct GNUNET_OS_Process *process)
{
- GNUNET_OS_process_kill (process, SIGINT);
+ GNUNET_OS_process_kill (process,
+ SIGINT);
GNUNET_OS_process_wait (process);
GNUNET_OS_process_destroy (process);
}
@@ -441,93 +440,55 @@ int
main (int argc,
char *const *argv)
{
- char *cipher;
- unsigned int 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_twisted-%s.conf",
- cipher);
- GNUNET_free (cipher);
- if (GNUNET_OK !=
- TALER_TESTING_prepare_fakebank (config_file,
- "exchange-account-exchange",
- &bc))
- return 77;
-
+ int ret;
- payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME);
- exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME);
- merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME);
-
- if (NULL == (merchant_url = TALER_TESTING_prepare_merchant
- (config_file)))
- return 77;
-
- if (NULL == (twister_exchange_url = TALER_TWISTER_prepare_twister
- (PROXY_EXCHANGE_config_file)))
+ {
+ char *cipher;
+
+ cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
+ GNUNET_assert (NULL != cipher);
+ GNUNET_asprintf (&config_file,
+ "test_merchant_api_twisted-%s.conf",
+ cipher);
+ GNUNET_free (cipher);
+ }
+ payer_payto =
+ "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=user";
+ exchange_payto =
+ "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
+ "?receiver-name=exchange";
+ merchant_payto =
+ "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
+ "?receiver-name=merchant";
+ merchant_url = "http://localhost:8080/";
+ if (NULL == (twister_exchange_url = TALER_TWISTER_prepare_twister (
+ PROXY_EXCHANGE_config_file)))
return 77;
- if (NULL == (twister_merchant_url = TALER_TWISTER_prepare_twister
- (PROXY_MERCHANT_config_file)))
+ if (NULL == (twister_merchant_url = TALER_TWISTER_prepare_twister (
+ PROXY_MERCHANT_config_file)))
return 77;
-
twister_merchant_url_instance_nonexistent = TALER_url_join (
twister_merchant_url, "instances/foo/", NULL);
twister_merchant_url_instance_tor = TALER_url_join (
twister_merchant_url, "instances/tor/", NULL);
-
- 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:
+ if (NULL == (twisterexchanged = TALER_TWISTER_run_twister
+ (PROXY_EXCHANGE_config_file)))
return 77;
- case GNUNET_OK:
-
- if (NULL == (merchantd = TALER_TESTING_run_merchant
- (config_file, merchant_url)))
- // 1 is fine; after all this is merchant test cases.
- return 1;
-
- if (NULL == (twisterexchanged = TALER_TWISTER_run_twister
- (PROXY_EXCHANGE_config_file)))
- return 77;
-
- if (NULL == (twistermerchantd = TALER_TWISTER_run_twister
- (PROXY_MERCHANT_config_file)))
- return 77;
-
- /* Run the exchange and schedule 'run()' */
- ret = TALER_TESTING_setup_with_exchange (&run, NULL,
- config_file);
- purge_process (merchantd);
- purge_process (twisterexchanged);
- purge_process (twistermerchantd);
- GNUNET_free (merchant_url);
- GNUNET_free (twister_exchange_url);
- GNUNET_free (twister_merchant_url);
-
- if (GNUNET_OK != ret)
- return 1;
- break;
- default:
- GNUNET_break (0);
- return 1;
- }
- return 0;
+ if (NULL == (twistermerchantd = TALER_TWISTER_run_twister
+ (PROXY_MERCHANT_config_file)))
+ return 77;
+ ret = TALER_TESTING_main (argv,
+ "INFO",
+ config_file,
+ "exchange-account-exchange",
+ TALER_TESTING_BS_FAKEBANK,
+ &cred,
+ &run,
+ NULL);
+ purge_process (twisterexchanged);
+ purge_process (twistermerchantd);
+ return ret;
}