From a9ae2171b897dfc9635e9ab72a04d65379bf2208 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 16 Jan 2020 21:57:40 +0100 Subject: reuse TALER_url_join --- src/lib/auditor_api_handle.c | 35 +++++-------------------- src/lib/auditor_api_handle.h | 12 --------- src/lib/exchange_api_handle.c | 36 ++++++-------------------- src/lib/exchange_api_handle.h | 13 ---------- src/lib/test_taler_exchange_wirewatch.c | 45 +++++++++++++++++---------------- 5 files changed, 38 insertions(+), 103 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auditor_api_handle.c b/src/lib/auditor_api_handle.c index f1df204cb..aa0489a30 100644 --- a/src/lib/auditor_api_handle.c +++ b/src/lib/auditor_api_handle.c @@ -405,34 +405,13 @@ char * MAH_path_to_url (struct TALER_AUDITOR_Handle *h, const char *path) { - return MAH_path_to_url2 (h->url, - path); -} - - -/** - * Obtain the URL to use for an API request. - * FIXME: duplicates TEAH_path_to_url2, and likely also logic in util! - * - * @param base_url base URL of the auditor (i.e. "http://auditor/") - * @param path Taler API path (i.e. "/deposit-confirmation") - * @return the full URL to use with cURL - */ -char * -MAH_path_to_url2 (const char *base_url, - const char *path) -{ - char *url; - - if ( ('/' == path[0]) && - (0 < strlen (base_url)) && - ('/' == base_url[strlen (base_url) - 1]) ) - path++; /* avoid generating URL with "//" from concat */ - GNUNET_asprintf (&url, - "%s%s", - base_url, - path); - return url; + char *ret; + GNUNET_assert ('/' == path[0]); + ret = TALER_url_join (h->url, + path + 1, + NULL); + GNUNET_assert (NULL != ret); + return ret; } diff --git a/src/lib/auditor_api_handle.h b/src/lib/auditor_api_handle.h index eac007c45..8c6d83bc3 100644 --- a/src/lib/auditor_api_handle.h +++ b/src/lib/auditor_api_handle.h @@ -56,16 +56,4 @@ MAH_path_to_url (struct TALER_AUDITOR_Handle *h, const char *path); -/** - * Obtain the URL to use for an API request. - * - * @param base_url base URL of the auditor (i.e. "http://auditor/") - * @param path Taler API path (i.e. "/deposit-confirmation") - * @return the full URL to use with cURL - */ -char * -MAH_path_to_url2 (const char *base_url, - const char *path); - - /* end of auditor_api_handle.h */ diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index c7b402b5e..c3a0598f8 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1415,34 +1415,14 @@ char * TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, const char *path) { - return TEAH_path_to_url2 (h->url, - path); -} - - -/** - * Obtain the URL to use for an API request. - * FIXME: duplicates MAH_path_to_url2, and likely also logic in util! - * - * @param base_url base URL of the exchange (i.e. "http://exchange/") - * @param path Taler API path (i.e. "/reserve/withdraw") - * @return the full URL to use with cURL - */ -char * -TEAH_path_to_url2 (const char *base_url, - const char *path) -{ - char *url; - - if ( ('/' == path[0]) && - (0 < strlen (base_url)) && - ('/' == base_url[strlen (base_url) - 1]) ) - path++; /* avoid generating URL with "//" from concat */ - GNUNET_asprintf (&url, - "%s%s", - base_url, - path); - return url; + char *ret; + + GNUNET_assert ('/' == path[0]); + ret = TALER_url_join (h->url, + path + 1, + NULL); + GNUNET_assert (NULL != ret); + return ret; } diff --git a/src/lib/exchange_api_handle.h b/src/lib/exchange_api_handle.h index a88cb70de..52b44c8bd 100644 --- a/src/lib/exchange_api_handle.h +++ b/src/lib/exchange_api_handle.h @@ -136,17 +136,4 @@ char * TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, const char *path); - -/** - * Obtain the URL to use for an API request. - * - * @param base_url base URL of the exchange (i.e. "http://exchange/") - * @param path Taler API path (i.e. "/reserve/withdraw") - * @return the full URL to use with cURL - */ -char * -TEAH_path_to_url2 (const char *base_url, - const char *path); - - /* end of exchange_api_handle.h */ diff --git a/src/lib/test_taler_exchange_wirewatch.c b/src/lib/test_taler_exchange_wirewatch.c index 39a222ae4..3a7b40097 100644 --- a/src/lib/test_taler_exchange_wirewatch.c +++ b/src/lib/test_taler_exchange_wirewatch.c @@ -50,7 +50,7 @@ static char *config_filename; static struct TALER_TESTING_Command transfer_to_exchange (const char *label, - const char *amount) + const char *amount) { return TALER_TESTING_cmd_admin_add_incoming (label, amount, @@ -59,6 +59,7 @@ transfer_to_exchange (const char *label, bc.user42_payto); } + /** * Main function that will tell the interpreter what commands to * run. @@ -72,37 +73,38 @@ run (void *cls, struct TALER_TESTING_Command all[] = { TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"), TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-empty", - config_filename), + config_filename), TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-empty", - config_filename), + config_filename), TALER_TESTING_cmd_check_bank_empty ("expect-transfers-empty-after-dry-run"), transfer_to_exchange ("run-transfer-good-to-exchange", - "EUR:5"), + "EUR:5"), TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-good-transfer", - config_filename), + config_filename), - TALER_TESTING_cmd_check_bank_admin_transfer ("clear-good-transfer-to-the-exchange", - "EUR:5", - bc.user42_payto, // debit - bc.exchange_payto, // credit - "run-transfer-good-to-exchange"), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "clear-good-transfer-to-the-exchange", + "EUR:5", + bc.user42_payto, // debit + bc.exchange_payto, // credit + "run-transfer-good-to-exchange"), TALER_TESTING_cmd_exec_aggregator ("run-aggregator-non-expired-reserve", - config_filename), + config_filename), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-1"), TALER_TESTING_cmd_sleep ("wait (5s)", - 5), + 5), TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-expired-reserve", - config_filename), + config_filename), TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1", - ec.exchange_url, - "EUR:4.99", - bc.exchange_payto, - bc.user42_payto), + ec.exchange_url, + "EUR:4.99", + bc.exchange_payto, + bc.user42_payto), TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"), - TALER_TESTING_cmd_end () + TALER_TESTING_cmd_end () }; TALER_TESTING_run_with_fakebank (is, @@ -110,15 +112,13 @@ run (void *cls, bc.bank_url); } + int main (int argc, char *const argv[]) { const char *plugin_name; char *testname; - struct GNUNET_OS_Process *proc; - struct GNUNET_CONFIGURATION_Handle *cfg; - struct GNUNET_SIGNAL_Context *shc_chld; /* these might get in the way */ unsetenv ("XDG_DATA_HOME"); @@ -157,7 +157,7 @@ main (int argc, TALER_TESTING_cleanup_files (config_filename); if (GNUNET_OK != TALER_TESTING_prepare_exchange (config_filename, - &ec)) + &ec)) { TALER_LOG_INFO ("Could not prepare the exchange\n"); return 77; @@ -175,4 +175,5 @@ main (int argc, config_filename)) ? 0 : 1; } + /* end of test_taler_exchange_wirewatch.c */ -- cgit v1.2.3