diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-11 21:27:34 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-11 21:43:15 +0100 |
commit | 54fc83ee6b910d482948c6ec8185df7aab1b0cb1 (patch) | |
tree | 10c04cad1392659a9ccef469271f866e393ebb48 /src/auditor-lib | |
parent | 57ab9f9fdba607fcc3817adf58f37c5390f8d220 (diff) |
fix cyclic dependency by combining exchange-lib and auditor-lib directories
Diffstat (limited to 'src/auditor-lib')
25 files changed, 0 insertions, 3678 deletions
diff --git a/src/auditor-lib/Makefile.am b/src/auditor-lib/Makefile.am deleted file mode 100644 index 7d16d95b4..000000000 --- a/src/auditor-lib/Makefile.am +++ /dev/null @@ -1,90 +0,0 @@ -# This Makefile.am is in the public domain -AM_CPPFLAGS = -I$(top_srcdir)/src/include - -if USE_COVERAGE - AM_CFLAGS = --coverage -O0 - XLIB = -lgcov -endif - -lib_LTLIBRARIES = \ - libtalerauditor.la \ - libtalerauditortesting.la - -libtalerauditor_la_LDFLAGS = \ - -version-info 0:0:0 \ - -no-undefined -libtalerauditor_la_SOURCES = \ - curl_defaults.c \ - auditor_api_handle.c auditor_api_handle.h \ - auditor_api_deposit_confirmation.c \ - auditor_api_exchanges.c -libtalerauditor_la_LIBADD = \ - $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - -lgnunetcurl \ - -lgnunetjson \ - -lgnunetutil \ - -ljansson \ - $(XLIB) - -if HAVE_LIBCURL -libtalerauditor_la_LIBADD += -lcurl -else -if HAVE_LIBGNURL -libtalerauditor_la_LIBADD += -lgnurl -endif -endif - - -libtalerauditortesting_la_LDFLAGS = \ - -version-info 0:0:0 \ - -no-undefined -libtalerauditortesting_la_SOURCES = \ - testing_auditor_api_helpers.c \ - testing_auditor_api_cmd_deposit_confirmation.c \ - testing_auditor_api_cmd_exchanges.c \ - testing_auditor_api_cmd_exec_auditor.c \ - testing_auditor_api_cmd_exec_auditor_dbinit.c \ - testing_auditor_api_cmd_exec_wire_auditor.c -libtalerauditortesting_la_LIBADD = \ - libtalerauditor.la \ - $(top_builddir)/src/exchange-lib/libtalerexchange.la \ - $(top_builddir)/src/exchange-lib/libtalertesting.la \ - $(top_builddir)/src/wire/libtalerwire.la \ - $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - -lgnunetcurl \ - -lgnunetjson \ - -lgnunetutil \ - -ljansson \ - $(XLIB) - - -check_PROGRAMS = \ - test_auditor_api - -AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; - -TESTS = \ - $(check_PROGRAMS) - -test_auditor_api_SOURCES = \ - test_auditor_api.c -test_auditor_api_LDADD = \ - libtalerauditortesting.la \ - libtalerauditor.la \ - $(top_builddir)/src/exchange-lib/libtalertesting.la \ - $(top_builddir)/src/exchange-lib/libtalerexchange.la \ - $(LIBGCRYPT_LIBS) \ - $(top_builddir)/src/bank-lib/libtalerfakebank.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ - $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - -lgnunetcurl \ - -lgnunetutil \ - -ljansson - - -EXTRA_DIST = \ - test_auditor_api.conf \ - test_auditor_api_expire_reserve_now.conf diff --git a/src/auditor-lib/auditor_api_deposit_confirmation.c b/src/auditor-lib/auditor_api_deposit_confirmation.c deleted file mode 100644 index 736f326dd..000000000 --- a/src/auditor-lib/auditor_api_deposit_confirmation.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/auditor_api_deposit_confirmation.c - * @brief Implementation of the /deposit request of the auditor's HTTP API - * @author Christian Grothoff - */ -#include "platform.h" -#include <jansson.h> -#include <microhttpd.h> /* just for HTTP status codes */ -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" -#include "taler_auditor_service.h" -#include "auditor_api_handle.h" -#include "taler_signatures.h" -#include "curl_defaults.h" - - -/** - * @brief A DepositConfirmation Handle - */ -struct TALER_AUDITOR_DepositConfirmationHandle -{ - - /** - * The connection to auditor this request handle will use - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * The url for this request. - */ - char *url; - - /** - * JSON encoding of the request to POST. - */ - char *json_enc; - - /** - * Handle for the request. - */ - struct GNUNET_CURL_Job *job; - - /** - * Function to call with the result. - */ - TALER_AUDITOR_DepositConfirmationResultCallback cb; - - /** - * Closure for @a cb. - */ - void *cb_cls; - -}; - - -/** - * Function called when we're done processing the - * HTTP /deposit-confirmation request. - * - * @param cls the `struct TALER_AUDITOR_DepositConfirmationHandle` - * @param response_code HTTP response code, 0 on error - * @param djson parsed JSON result, NULL on error - */ -static void -handle_deposit_confirmation_finished (void *cls, - long response_code, - const void *djson) -{ - const json_t *json = djson; - struct TALER_AUDITOR_DepositConfirmationHandle *dh = cls; - - dh->job = NULL; - switch (response_code) - { - case 0: - break; - case MHD_HTTP_OK: - break; - case MHD_HTTP_BAD_REQUEST: - /* This should never happen, either us or the auditor is buggy - (or API version conflict); just pass JSON reply to the application */ - break; - case MHD_HTTP_UNAUTHORIZED: - /* Nothing really to verify, auditor says one of the signatures is - invalid; as we checked them, this should never happen, we - should pass the JSON reply to the application */ - break; - case MHD_HTTP_NOT_FOUND: - /* Nothing really to verify, this should never - happen, we should pass the JSON reply to the application */ - break; - case MHD_HTTP_INTERNAL_SERVER_ERROR: - /* Server had an internal issue; we should retry, but this API - leaves this to the application */ - break; - default: - /* unexpected response code */ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u\n", - (unsigned int) response_code); - GNUNET_break (0); - response_code = 0; - break; - } - dh->cb (dh->cb_cls, - response_code, - TALER_JSON_get_error_code (json), - json); - TALER_AUDITOR_deposit_confirmation_cancel (dh); -} - - -/** - * Verify signature information about the deposit-confirmation. - * - * @param h_wire hash of merchant wire details - * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor) - * @param timestamp timestamp when the contract was finalized, must not be too far in the future - * @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline - * @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant - * @param coin_pub coin’s public key - * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) - * @param exchange_sig the signature made with purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT - * @param exchange_pub the public key of the exchange that matches @a exchange_sig - * @param master_pub master public key of the exchange - * @param ep_start when does @a exchange_pub validity start - * @param ep_expire when does @a exchange_pub usage end - * @param ep_end when does @a exchange_pub legal validity end - * @param master_sig master signature affirming validity of @a exchange_pub - * @return #GNUNET_OK if signatures are OK, #GNUNET_SYSERR if not - */ -static int -verify_signatures (const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute ep_start, - struct GNUNET_TIME_Absolute ep_expire, - struct GNUNET_TIME_Absolute ep_end, - const struct TALER_MasterSignatureP *master_sig) -{ - struct TALER_DepositConfirmationPS dc; - struct TALER_ExchangeSigningKeyValidityPS sv; - - dc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT); - dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)); - dc.h_contract_terms = *h_contract_terms; - dc.h_wire = *h_wire; - dc.timestamp = GNUNET_TIME_absolute_hton (timestamp); - dc.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); - TALER_amount_hton (&dc.amount_without_fee, - amount_without_fee); - dc.coin_pub = *coin_pub; - dc.merchant = *merchant_pub; - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT, - &dc.purpose, - &exchange_sig->eddsa_signature, - &exchange_pub->eddsa_pub)) - { - GNUNET_break_op (0); - TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request!\n"); - { - TALER_LOG_DEBUG ("... amount_without_fee was %s\n", - TALER_amount2s (amount_without_fee)); - } - - return GNUNET_SYSERR; - } - sv.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - sv.purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)); - sv.master_public_key = *master_pub; - sv.start = GNUNET_TIME_absolute_hton (ep_start); - sv.expire = GNUNET_TIME_absolute_hton (ep_expire); - sv.end = GNUNET_TIME_absolute_hton (ep_end); - sv.signkey_pub = *exchange_pub; - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY, - &sv.purpose, - &master_sig->eddsa_signature, - &master_pub->eddsa_pub)) - { - GNUNET_break (0); - TALER_LOG_WARNING ("Invalid signature on exchange signing key!\n"); - return GNUNET_SYSERR; - } - if (0 == GNUNET_TIME_absolute_get_remaining (ep_end).rel_value_us) - { - GNUNET_break (0); - TALER_LOG_WARNING ("Exchange signing key is no longer valid!\n"); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/** - * Submit a deposit-confirmation permission to the auditor and get the - * auditor's response. Note that while we return the response - * verbatim to the caller for further processing, we do already verify - * that the response is well-formed. If the auditor's reply is not - * well-formed, we return an HTTP status code of zero to @a cb. - * - * We also verify that the @a exchange_sig is valid for this deposit-confirmation - * request, and that the @a master_sig is a valid signature for @a - * exchange_pub. Also, the @a auditor must be ready to operate (i.e. have - * finished processing the /version reply). If either check fails, we do - * NOT initiate the transaction with the auditor and instead return NULL. - * - * @param auditor the auditor handle; the auditor must be ready to operate - * @param h_wire hash of merchant wire details - * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor) - * @param timestamp timestamp when the contract was finalized, must not be too far in the future - * @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline - * @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant - * @param coin_pub coin’s public key - * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) - * @param exchange_sig the signature made with purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT - * @param exchange_pub the public key of the exchange that matches @a exchange_sig - * @param master_pub master public key of the exchange - * @param ep_start when does @a exchange_pub validity start - * @param ep_expire when does @a exchange_pub usage end - * @param ep_end when does @a exchange_pub legal validity end - * @param master_sig master signature affirming validity of @a exchange_pub - * @param cb the callback to call when a reply for this request is available - * @param cb_cls closure for the above callback - * @return a handle for this request; NULL if the inputs are invalid (i.e. - * signatures fail to verify). In this case, the callback is not called. - */ -struct TALER_AUDITOR_DepositConfirmationHandle * -TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute ep_start, - struct GNUNET_TIME_Absolute ep_expire, - struct GNUNET_TIME_Absolute ep_end, - const struct TALER_MasterSignatureP *master_sig, - TALER_AUDITOR_DepositConfirmationResultCallback cb, - void *cb_cls) -{ - struct TALER_AUDITOR_DepositConfirmationHandle *dh; - struct GNUNET_CURL_Context *ctx; - json_t *deposit_confirmation_obj; - CURL *eh; - - (void) GNUNET_TIME_round_abs (×tamp); - (void) GNUNET_TIME_round_abs (&refund_deadline); - (void) GNUNET_TIME_round_abs (&ep_start); - (void) GNUNET_TIME_round_abs (&ep_expire); - (void) GNUNET_TIME_round_abs (&ep_end); - GNUNET_assert (GNUNET_YES == - MAH_handle_is_ready (auditor)); - if (GNUNET_OK != - verify_signatures (h_wire, - h_contract_terms, - timestamp, - refund_deadline, - amount_without_fee, - coin_pub, - merchant_pub, - exchange_pub, - exchange_sig, - master_pub, - ep_start, - ep_expire, - ep_end, - master_sig)) - { - GNUNET_break_op (0); - return NULL; - } - - deposit_confirmation_obj - = json_pack ("{s:o, s:o," /* H_wire, h_contract_terms */ - " s:o, s:o," /* timestamp, refund_deadline */ - " s:o, s:o," /* amount_without_fees, coin_pub */ - " s:o, s:o," /* merchant_pub, exchange_sig */ - " s:o, s:o," /* master_pub, ep_start */ - " s:o, s:o," /* ep_expire, ep_end */ - " s:o}", /* master_sig */ - "H_wire", GNUNET_JSON_from_data_auto (&h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), - "amount_without_fee", TALER_JSON_from_amount (amount_without_fee), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig), - "master_pub", GNUNET_JSON_from_data_auto (master_pub), - "ep_start", GNUNET_JSON_from_time_abs (ep_start), - "ep_expire", GNUNET_JSON_from_time_abs (ep_expire), - "ep_end", GNUNET_JSON_from_time_abs (ep_end), - "master_sig", GNUNET_JSON_from_data_auto (master_sig)); - if (NULL == deposit_confirmation_obj) - { - GNUNET_break (0); - return NULL; - } - - dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle); - dh->auditor = auditor; - dh->cb = cb; - dh->cb_cls = cb_cls; - dh->url = MAH_path_to_url (auditor, "/deposit-confirmation"); - - eh = TAL_curl_easy_get (dh->url); - GNUNET_assert (NULL != (dh->json_enc = - json_dumps (deposit_confirmation_obj, - JSON_COMPACT))); - json_decref (deposit_confirmation_obj); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "URL for deposit-confirmation: `%s'\n", - dh->url); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDS, - dh->json_enc)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_POSTFIELDSIZE, - strlen (dh->json_enc))); - ctx = MAH_handle_to_context (auditor); - dh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_YES, - &handle_deposit_confirmation_finished, - dh); - return dh; -} - - -/** - * Cancel a deposit-confirmation permission request. This function cannot be used - * on a request handle if a response is already served for it. - * - * @param deposit-confirmation the deposit-confirmation permission request handle - */ -void -TALER_AUDITOR_deposit_confirmation_cancel (struct TALER_AUDITOR_DepositConfirmationHandle *deposit_confirmation) -{ - if (NULL != deposit_confirmation->job) - { - GNUNET_CURL_job_cancel (deposit_confirmation->job); - deposit_confirmation->job = NULL; - } - GNUNET_free (deposit_confirmation->url); - GNUNET_free (deposit_confirmation->json_enc); - GNUNET_free (deposit_confirmation); -} - - -/* end of auditor_api_deposit_confirmation.c */ diff --git a/src/auditor-lib/auditor_api_exchanges.c b/src/auditor-lib/auditor_api_exchanges.c deleted file mode 100644 index 2ddd2e5bf..000000000 --- a/src/auditor-lib/auditor_api_exchanges.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/auditor_api_exchanges.c - * @brief Implementation of the /exchanges request of the auditor's HTTP API - * @author Christian Grothoff - */ -#include "platform.h" -#include <jansson.h> -#include <microhttpd.h> /* just for HTTP status codes */ -#include <gnunet/gnunet_util_lib.h> -#include <gnunet/gnunet_json_lib.h> -#include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" -#include "taler_auditor_service.h" -#include "auditor_api_handle.h" -#include "taler_signatures.h" -#include "curl_defaults.h" - -/** - * How many exchanges do we allow a single auditor to - * audit at most? - */ -#define MAX_EXCHANGES 1024 - - -/** - * @brief A ListExchanges Handle - */ -struct TALER_AUDITOR_ListExchangesHandle -{ - - /** - * The connection to auditor this request handle will use - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * The url for this request. - */ - char *url; - - /** - * Handle for the request. - */ - struct GNUNET_CURL_Job *job; - - /** - * Function to call with the result. - */ - TALER_AUDITOR_ListExchangesResultCallback cb; - - /** - * Closure for @a cb. - */ - void *cb_cls; - -}; - - -/** - * Function called when we're done processing the - * HTTP /deposit-confirmation request. - * - * @param cls the `struct TALER_AUDITOR_ListExchangesHandle` - * @param response_code HTTP response code, 0 on error - * @param djson parsed JSON result, NULL on error - */ -static void -handle_exchanges_finished (void *cls, - long response_code, - const void *djson) -{ - const json_t *json = djson; - const json_t *ja; - unsigned int ja_len; - struct TALER_AUDITOR_ListExchangesHandle *leh = cls; - - leh->job = NULL; - switch (response_code) - { - case 0: - break; - case MHD_HTTP_OK: - ja = json_object_get (json, - "exchanges"); - if ( (NULL == ja) || - (! json_is_array (ja)) ) - { - GNUNET_break (0); - response_code = 0; - break; - } - - ja_len = json_array_size (ja); - if (ja_len > MAX_EXCHANGES) - { - GNUNET_break (0); - response_code = 0; - break; - } - { - struct TALER_AUDITOR_ExchangeInfo ei[ja_len]; - int ok; - - ok = GNUNET_YES; - for (unsigned int i=0;i<ja_len;i++) - { - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("master_pub", &ei[i].master_pub), - GNUNET_JSON_spec_string ("exchange_url", &ei[i].exchange_url), - GNUNET_JSON_spec_end() - }; - - if (GNUNET_OK != - GNUNET_JSON_parse (json_array_get (ja, - i), - spec, - NULL, NULL)) - { - GNUNET_break_op (0); - ok = GNUNET_NO; - break; - } - } - if (GNUNET_YES != ok) - break; - leh->cb (leh->cb_cls, - response_code, - TALER_EC_NONE, - ja_len, - ei, - json); - leh->cb = NULL; - } - break; - case MHD_HTTP_BAD_REQUEST: - /* This should never happen, either us or the auditor is buggy - (or API version conflict); just pass JSON reply to the application */ - break; - case MHD_HTTP_NOT_FOUND: - /* Nothing really to verify, this should never - happen, we should pass the JSON reply to the application */ - break; - case MHD_HTTP_INTERNAL_SERVER_ERROR: - /* Server had an internal issue; we should retry, but this API - leaves this to the application */ - break; - default: - /* unexpected response code */ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u\n", - (unsigned int) response_code); - GNUNET_break (0); - response_code = 0; - break; - } - if (NULL != leh->cb) - leh->cb (leh->cb_cls, - response_code, - TALER_JSON_get_error_code (json), - 0, - NULL, - json); - TALER_AUDITOR_list_exchanges_cancel (leh); -} - - -/** - * Submit an /exchanges request to the auditor and get the - * auditor's response. If the auditor's reply is not - * well-formed, we return an HTTP status code of zero to @a cb. - * - * @param auditor the auditor handle; the auditor must be ready to operate - * @param cb the callback to call when a reply for this request is available - * @param cb_cls closure for the above callback - * @return a handle for this request; NULL if the inputs are invalid (i.e. - * signatures fail to verify). In this case, the callback is not called. - */ -struct TALER_AUDITOR_ListExchangesHandle * -TALER_AUDITOR_list_exchanges (struct TALER_AUDITOR_Handle *auditor, - TALER_AUDITOR_ListExchangesResultCallback cb, - void *cb_cls) -{ - struct TALER_AUDITOR_ListExchangesHandle *leh; - struct GNUNET_CURL_Context *ctx; - CURL *eh; - - GNUNET_assert (GNUNET_YES == - MAH_handle_is_ready (auditor)); - - leh = GNUNET_new (struct TALER_AUDITOR_ListExchangesHandle); - leh->auditor = auditor; - leh->cb = cb; - leh->cb_cls = cb_cls; - leh->url = MAH_path_to_url (auditor, "/exchanges"); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "URL for list-exchanges: `%s'\n", - leh->url); - eh = TAL_curl_easy_get (leh->url); - ctx = MAH_handle_to_context (auditor); - leh->job = GNUNET_CURL_job_add (ctx, - eh, - GNUNET_NO, - &handle_exchanges_finished, - leh); - return leh; -} - - -/** - * Cancel a deposit-confirmation permission request. This function cannot be used - * on a request handle if a response is already served for it. - * - * @param deposit-confirmation the deposit-confirmation permission request handle - */ -void -TALER_AUDITOR_list_exchanges_cancel (struct TALER_AUDITOR_ListExchangesHandle *leh) -{ - if (NULL != leh->job) - { - GNUNET_CURL_job_cancel (leh->job); - leh->job = NULL; - } - GNUNET_free (leh->url); - GNUNET_free (leh); -} - - -/* end of auditor_api_exchanges.c */ diff --git a/src/auditor-lib/auditor_api_handle.c b/src/auditor-lib/auditor_api_handle.c deleted file mode 100644 index 26eca74e6..000000000 --- a/src/auditor-lib/auditor_api_handle.c +++ /dev/null @@ -1,527 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/auditor_api_handle.c - * @brief Implementation of the "handle" component of the auditor's HTTP API - * @author Sree Harsha Totakura <sreeharsha@totakura.in> - * @author Christian Grothoff - */ -#include "platform.h" -#include <microhttpd.h> -#include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" -#include "taler_auditor_service.h" -#include "taler_signatures.h" -#include "auditor_api_handle.h" -#include "curl_defaults.h" -#include "backoff.h" - -/** - * Which revision of the Taler auditor protocol is implemented - * by this library? Used to determine compatibility. - */ -#define TALER_PROTOCOL_CURRENT 0 - -/** - * How many revisions back are we compatible to? - */ -#define TALER_PROTOCOL_AGE 0 - - -/** - * Log error related to CURL operations. - * - * @param type log level - * @param function which function failed to run - * @param code what was the curl error code - */ -#define CURL_STRERROR(type, function, code) \ - GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ - function, __FILE__, __LINE__, curl_easy_strerror (code)); - -/** - * Stages of initialization for the `struct TALER_AUDITOR_Handle` - */ -enum AuditorHandleState -{ - /** - * Just allocated. - */ - MHS_INIT = 0, - - /** - * Obtained the auditor's versioning data and version. - */ - MHS_VERSION = 1, - - /** - * Failed to initialize (fatal). - */ - MHS_FAILED = 2 -}; - - -/** - * Data for the request to get the /version of a auditor. - */ -struct VersionRequest; - - -/** - * Handle to the auditor - */ -struct TALER_AUDITOR_Handle -{ - /** - * The context of this handle - */ - struct GNUNET_CURL_Context *ctx; - - /** - * The URL of the auditor (i.e. "http://auditor.taler.net/") - */ - char *url; - - /** - * Function to call with the auditor's certification data, - * NULL if this has already been done. - */ - TALER_AUDITOR_VersionCallback version_cb; - - /** - * Closure to pass to @e version_cb. - */ - void *version_cb_cls; - - /** - * Data for the request to get the /version of a auditor, - * NULL once we are past stage #MHS_INIT. - */ - struct VersionRequest *vr; - - /** - * Task for retrying /version request. - */ - struct GNUNET_SCHEDULER_Task *retry_task; - - /** - * /version data of the auditor, only valid if - * @e handshake_complete is past stage #MHS_VERSION. - */ - struct TALER_AUDITOR_VersionInformation vi; - - /** - * Retry /version frequency. - */ - struct GNUNET_TIME_Relative retry_delay; - - /** - * Stage of the auditor's initialization routines. - */ - enum AuditorHandleState state; - -}; - - -/* ***************** Internal /version fetching ************* */ - -/** - * Data for the request to get the /version of a auditor. - */ -struct VersionRequest -{ - /** - * The connection to auditor this request handle will use - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * The url for this handle - */ - char *url; - - /** - * Entry for this request with the `struct GNUNET_CURL_Context`. - */ - struct GNUNET_CURL_Job *job; - -}; - - -/** - * Release memory occupied by a version request. - * Note that this does not cancel the request - * itself. - * - * @param vr request to free - */ -static void -free_version_request (struct VersionRequest *vr) -{ - GNUNET_free (vr->url); - GNUNET_free (vr); -} - - -/** - * Free version data object. - * - * @param vi data to free (pointer itself excluded) - */ -static void -free_version_info (struct TALER_AUDITOR_VersionInformation *vi) -{ - GNUNET_free_non_null (vi->version); - vi->version = NULL; -} - - -/** - * Decode the JSON in @a resp_obj from the /version response and store the data - * in the @a key_data. - * - * @param[in] resp_obj JSON object to parse - * @param check_sig #GNUNET_YES if we should check the signature - * @param[out] vi where to store the results we decoded - * @param[out] vc where to store version compatibility data - * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (malformed JSON) - */ -static int -decode_version_json (const json_t *resp_obj, - int check_sig, - struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility *vc) -{ - unsigned int age; - unsigned int revision; - unsigned int current; - const char *ver; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("version", - &ver), - GNUNET_JSON_spec_fixed_auto ("master_public_key", - &vi->auditor_pub), - GNUNET_JSON_spec_end() - }; - - if (JSON_OBJECT != json_typeof (resp_obj)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - /* check the version */ - if (GNUNET_OK != - GNUNET_JSON_parse (resp_obj, - spec, - NULL, NULL)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - if (3 != sscanf (vi->version, - "%u:%u:%u", - ¤t, - &revision, - &age)) - { - GNUNET_break_op (0); - free_version_info (vi); - return GNUNET_SYSERR; - } - vi->version = GNUNET_strdup (ver); - *vc = TALER_AUDITOR_VC_MATCH; - if (TALER_PROTOCOL_CURRENT < current) - { - *vc |= TALER_AUDITOR_VC_NEWER; - if (TALER_PROTOCOL_CURRENT < current - age) - *vc |= TALER_AUDITOR_VC_INCOMPATIBLE; - } - if (TALER_PROTOCOL_CURRENT > current) - { - *vc |= TALER_AUDITOR_VC_OLDER; - if (TALER_PROTOCOL_CURRENT - TALER_PROTOCOL_AGE > current) - *vc |= TALER_AUDITOR_VC_INCOMPATIBLE; - } - return GNUNET_OK; -} - - -/** - * Initiate download of /version from the auditor. - * - * @param cls auditor where to download /version from - */ -static void -request_version (void *cls); - - -/** - * Callback used when downloading the reply to a /version request - * is complete. - * - * @param cls the `struct VersionRequest` - * @param response_code HTTP response code, 0 on error - * @param resp_obj parsed JSON result, NULL on error - */ -static void -version_completed_cb (void *cls, - long response_code, - const void *gresp_obj) -{ - const json_t *resp_obj = gresp_obj; - struct VersionRequest *vr = cls; - struct TALER_AUDITOR_Handle *auditor = vr->auditor; - enum TALER_AUDITOR_VersionCompatibility vc; - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Received version from URL `%s' with status %ld.\n", - vr->url, - response_code); - vc = TALER_AUDITOR_VC_PROTOCOL_ERROR; - switch (response_code) - { - case 0: - case MHD_HTTP_INTERNAL_SERVER_ERROR: - free_version_request (vr); - auditor->vr = NULL; - GNUNET_assert (NULL == auditor->retry_task); - auditor->retry_delay = AUDITOR_LIB_BACKOFF (auditor->retry_delay); - auditor->retry_task = GNUNET_SCHEDULER_add_delayed (auditor->retry_delay, - &request_version, - auditor); - return; - case MHD_HTTP_OK: - if (NULL == resp_obj) - { - response_code = 0; - break; - } - if (GNUNET_OK != - decode_version_json (resp_obj, - GNUNET_YES, - &auditor->vi, - &vc)) - { - response_code = 0; - break; - } - auditor->retry_delay = GNUNET_TIME_UNIT_ZERO; - break; - default: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u\n", - (unsigned int) response_code); - break; - } - if (MHD_HTTP_OK != response_code) - { - auditor->vr = NULL; - free_version_request (vr); - auditor->state = MHS_FAILED; - free_version_info (&auditor->vi); - /* notify application that we failed */ - auditor->version_cb (auditor->version_cb_cls, - NULL, - vc); - return; - } - - auditor->vr = NULL; - free_version_request (vr); - auditor->state = MHS_VERSION; - /* notify application about the key information */ - auditor->version_cb (auditor->version_cb_cls, - &auditor->vi, - vc); -} - - -/* ********************* library internal API ********* */ - - -/** - * Get the context of a auditor. - * - * @param h the auditor handle to query - * @return ctx context to execute jobs in - */ -struct GNUNET_CURL_Context * -MAH_handle_to_context (struct TALER_AUDITOR_Handle *h) -{ - return h->ctx; -} - - -/** - * Check if the handle is ready to process requests. - * - * @param h the auditor handle to query - * @return #GNUNET_YES if we are ready, #GNUNET_NO if not - */ -int -MAH_handle_is_ready (struct TALER_AUDITOR_Handle *h) -{ - return (MHS_VERSION == h->state) ? GNUNET_YES : GNUNET_NO; -} - - -/** - * Obtain the URL to use for an API request. - * - * @param h handle for the auditor - * @param path Taler API path (i.e. "/deposit-confirmation") - * @return the full URL to use with cURL - */ -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. - * - * @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; -} - - -/* ********************* public API ******************* */ - - -/** - * Initialise a connection to the auditor. Will connect to the - * auditor and obtain information about the auditor's master public - * key and the auditor's auditor. The respective information will - * be passed to the @a version_cb once available, and all future - * interactions with the auditor will be checked to be signed - * (where appropriate) by the respective master key. - * - * @param ctx the context - * @param url HTTP base URL for the auditor - * @param version_cb function to call with the auditor's version information - * @param version_cb_cls closure for @a version_cb - * @return the auditor handle; NULL upon error - */ -struct TALER_AUDITOR_Handle * -TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx, - const char *url, - TALER_AUDITOR_VersionCallback version_cb, - void *version_cb_cls) -{ - struct TALER_AUDITOR_Handle *auditor; - - auditor = GNUNET_new (struct TALER_AUDITOR_Handle); - auditor->ctx = ctx; - auditor->url = GNUNET_strdup (url); - auditor->version_cb = version_cb; - auditor->version_cb_cls = version_cb_cls; - auditor->retry_task = GNUNET_SCHEDULER_add_now (&request_version, - auditor); - return auditor; -} - - -/** - * Initiate download of /version from the auditor. - * - * @param cls auditor where to download /version from - */ -static void -request_version (void *cls) -{ - struct TALER_AUDITOR_Handle *auditor = cls; - struct VersionRequest *vr; - CURL *eh; - - auditor->retry_task = NULL; - GNUNET_assert (NULL == auditor->vr); - vr = GNUNET_new (struct VersionRequest); - vr->auditor = auditor; - vr->url = MAH_path_to_url (auditor, - "/version"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Requesting version with URL `%s'.\n", - vr->url); - eh = TAL_curl_easy_get (vr->url); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_VERBOSE, - 0)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_TIMEOUT, - (long) 300)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_HEADERDATA, - vr)); - vr->job = GNUNET_CURL_job_add (auditor->ctx, - eh, - GNUNET_NO, - &version_completed_cb, - vr); - auditor->vr = vr; -} - - -/** - * Disconnect from the auditor - * - * @param auditor the auditor handle - */ -void -TALER_AUDITOR_disconnect (struct TALER_AUDITOR_Handle *auditor) -{ - if (NULL != auditor->vr) - { - GNUNET_CURL_job_cancel (auditor->vr->job); - free_version_request (auditor->vr); - auditor->vr = NULL; - } - free_version_info (&auditor->vi); - if (NULL != auditor->retry_task) - { - GNUNET_SCHEDULER_cancel (auditor->retry_task); - auditor->retry_task = NULL; - } - GNUNET_free (auditor->url); - GNUNET_free (auditor); -} - - -/* end of auditor_api_handle.c */ diff --git a/src/auditor-lib/auditor_api_handle.h b/src/auditor-lib/auditor_api_handle.h deleted file mode 100644 index c3c73f5c3..000000000 --- a/src/auditor-lib/auditor_api_handle.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/auditor_api_handle.h - * @brief Internal interface to the handle part of the auditor's HTTP API - * @author Christian Grothoff - */ -#include "platform.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_auditor_service.h" - - -/** - * Get the context of a auditor. - * - * @param h the auditor handle to query - * @return ctx context to execute jobs in - */ -struct GNUNET_CURL_Context * -MAH_handle_to_context (struct TALER_AUDITOR_Handle *h); - - -/** - * Check if the handle is ready to process requests. - * - * @param h the auditor handle to query - * @return #GNUNET_YES if we are ready, #GNUNET_NO if not - */ -int -MAH_handle_is_ready (struct TALER_AUDITOR_Handle *h); - - -/** - * Obtain the URL to use for an API request. - * - * @param h the auditor handle to query - * @param path Taler API path (i.e. "/deposit-confirmation") - * @return the full URL to use with cURL - */ -char * -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/auditor-lib/backoff.h b/src/auditor-lib/backoff.h deleted file mode 100644 index 523a6b9eb..000000000 --- a/src/auditor-lib/backoff.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/backoff.h - * @brief backoff computation for the auditor lib - * @author Florian Dold - */ - - -#ifndef _TALER_BACKOFF_H -#define _TALER_BACKOFF_H - -#include "platform.h" -#include <gnunet/gnunet_time_lib.h> - -/** - * Random exponential backoff used in the auditor lib. - */ -#define AUDITOR_LIB_BACKOFF(r) GNUNET_TIME_randomized_backoff ( \ - (r), \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)); - -#endif diff --git a/src/auditor-lib/curl_defaults.c b/src/auditor-lib/curl_defaults.c deleted file mode 100644 index 7dadc950e..000000000 --- a/src/auditor-lib/curl_defaults.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/curl_defaults.c - * @brief curl easy handle defaults - * @author Florian Dold - */ - -#include "curl_defaults.h" - - -/** - * Get a curl handle with the right defaults - * for the exchange lib. In the future, we might manage a pool of connections here. - * - * @param url URL to query - */ -CURL * -TAL_curl_easy_get (const char *url) -{ - CURL *eh; - - eh = curl_easy_init (); - - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_URL, - url)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_ENCODING, - "deflate")); -#ifdef CURLOPT_TCP_FASTOPEN - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_TCP_FASTOPEN, - 1L)); -#endif - { - /* Unfortunately libcurl needs chunk to be alive until after - curl_easy_perform. To avoid manual cleanup, we keep - one static list here. */ - static struct curl_slist *chunk = NULL; - if (NULL == chunk) - { - /* With POST requests, we do not want to wait for the - "100 Continue" response, as our request bodies are usually - small and directy sending them saves us a round trip. - - Clearing the expect header like this disables libcurl's - default processing of the header. - - Disabling this header is safe for other HTTP methods, thus - we don't distinguish further before setting it. */ - chunk = curl_slist_append (chunk, "Expect:"); - } - GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_HTTPHEADER, chunk)); - } - - return eh; -} diff --git a/src/auditor-lib/curl_defaults.h b/src/auditor-lib/curl_defaults.h deleted file mode 100644 index 3be5816bf..000000000 --- a/src/auditor-lib/curl_defaults.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/curl_defaults.h - * @brief curl easy handle defaults - * @author Florian Dold - */ - -#ifndef _TALER_CURL_DEFAULTS_H -#define _TALER_CURL_DEFAULTS_H - - -#include "platform.h" -#include <gnunet/gnunet_curl_lib.h> - - -/** - * Get a curl handle with the right defaults - * for the auditor lib. In the future, we might manage a pool of connections here. - * - * @param url URL to query - */ -CURL * -TAL_curl_easy_get (const char *url); - -#endif /* _TALER_CURL_DEFAULTS_H */ diff --git a/src/auditor-lib/test_auditor_api.c b/src/auditor-lib/test_auditor_api.c deleted file mode 100644 index cddd21197..000000000 --- a/src/auditor-lib/test_auditor_api.c +++ /dev/null @@ -1,549 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 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 - published by the Free Software Foundation; either version 3, or - (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/test_auditor_api.c - * @brief testcase to test auditor's HTTP API interface - * @author Christian Grothoff - * @author Marcello Stanisci - */ -#include "platform.h" -#include "taler_util.h" -#include "taler_signatures.h" -#include "taler_exchange_service.h" -#include "taler_auditor_service.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_util_lib.h> -#include <microhttpd.h> -#include "taler_bank_service.h" -#include "taler_fakebank_lib.h" -#include "taler_testing_lib.h" -#include "taler_testing_auditor_lib.h" - -/** - * Configuration file we use. One (big) configuration is used - * for the various components for this test. - */ -#define CONFIG_FILE "test_auditor_api.conf" - -#define CONFIG_FILE_EXPIRE_RESERVE_NOW "test_auditor_api_expire_reserve_now.conf" - -/** - * URL of the fakebank. Obtained from CONFIG_FILE's - * "exchange-wire-test:BANK_URI" option. - */ -static char *fakebank_url; - -/** - * Auditor base URL as it appears in the configuration. Note - * that it might differ from the one where the exchange actually - * listens from. - */ -static char *auditor_url; - -/** - * Exchange base URL as it appears in the configuration. Note - * that it might differ from the one where the exchange actually - * listens from. - */ -static char *exchange_url; - -/** - * Account number of the exchange at the bank. - */ -#define EXCHANGE_ACCOUNT_NO 2 - -/** - * Account number of some user. - */ -#define USER_ACCOUNT_NO 42 - -/** - * User name. Never checked by fakebank. - */ -#define USER_LOGIN_NAME "user42" - -/** - * User password. Never checked by fakebank. - */ -#define USER_LOGIN_PASS "pass42" - -/** - * Execute the taler-exchange-wirewatch command with - * our configuration file. - * - * @param label label to use for the command. - */ -#define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE) - -/** - * Execute the taler-exchange-aggregator command with - * our configuration file. - * - * @param label label to use for the command. - */ -#define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label, CONFIG_FILE) - -/** - * Run wire transfer of funds from some user's account to the - * exchange. - * - * @param label label to use for the command. - * @param amount amount to transfer, i.e. "EUR:1" - */ -#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ - USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url) - -/** - * Run wire transfer of funds from some user's account to the - * exchange. - * - * @param label label to use for the command. - * @param amount amount to transfer, i.e. "EUR:1" - */ -#define CMD_TRANSFER_TO_EXCHANGE_SUBJECT(label,amount,subject) \ - TALER_TESTING_cmd_fakebank_transfer_with_subject \ - (label, amount, fakebank_url, USER_ACCOUNT_NO, \ - EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ - subject, exchange_url) - -/** - * Run the taler-auditor. - * - * @param label label to use for the command. - */ -#define CMD_RUN_AUDITOR(label) \ - TALER_TESTING_cmd_exec_auditor (label, CONFIG_FILE) - -/** - * Run the taler-wire-auditor. - * - * @param label label to use for the command. - */ -#define CMD_RUN_WIRE_AUDITOR(label) \ - TALER_TESTING_cmd_exec_wire_auditor (label, CONFIG_FILE) - - -/** - * Main function that will tell the interpreter what commands to - * run. - * - * @param cls closure - */ -static void -run (void *cls, - struct TALER_TESTING_Interpreter *is) -{ - /** - * Test withdraw. - */ - struct TALER_TESTING_Command withdraw[] = { - /** - * Move money to the exchange's bank account. - */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", - "EUR:5.01"), - /** - * Make a reserve exist, according to the previous transfer. - */ - CMD_EXEC_WIREWATCH ("wirewatch-1"), - /** - * Withdraw EUR:5. - */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", - "create-reserve-1", - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command spend[] = { - /** - * Spend the coin. - */ - TALER_TESTING_cmd_deposit ("deposit-simple", - "withdraw-coin-1", - 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command refresh[] = { - /** - * Fill reserve with EUR:5, 1ct is for fees. NOTE: the old - * test-suite gave a account number of _424_ to the user at - * this step; to type less, here the _42_ number is reused. - * Does this change the tests semantics? - */ - CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-1", - "EUR:5.01"), - /** - * Make previous command effective. - */ - CMD_EXEC_WIREWATCH ("wirewatch-2"), - /** - * Withdraw EUR:5. - */ - TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", - "refresh-create-reserve-1", - "EUR:5", - MHD_HTTP_OK), - /** - * Try to partially spend (deposit) 1 EUR of the 5 EUR coin (in - * full) Merchant receives EUR:0.99 due to 1 ct deposit fee. - */ - TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - "refresh-withdraw-coin-1", - 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:1", - MHD_HTTP_OK), - /** - * Melt the rest of the coin's value (EUR:4.00 = 3x EUR:1.03 + 7x - * EUR:0.13) */ - TALER_TESTING_cmd_refresh_melt_double ("refresh-melt-1", - "EUR:4", - "refresh-withdraw-coin-1", - MHD_HTTP_OK), - /** - * Complete (successful) melt operation, and withdraw the coins - */ - TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - "refresh-melt-1", - MHD_HTTP_OK), - /** - * Try to spend a refreshed EUR:0.1 coin - */ - TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", - "refresh-reveal-1", - 3, - TALER_TESTING_make_wire_details (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.1", - MHD_HTTP_OK), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command track[] = { - /** - * Run transfers. Note that _actual_ aggregation will NOT - * happen here, as each deposit operation is run with a - * fresh merchant public key! NOTE: this comment comes - * "verbatim" from the old test-suite, and IMO does not explain - * a lot! - */ - CMD_EXEC_AGGREGATOR ("run-aggregator"), - - /** - * Check all the transfers took place. - */ - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-499c", exchange_url, - "EUR:4.98", 2, 42), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-99c1", exchange_url, - "EUR:0.98", 2, 42), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-99c", exchange_url, - "EUR:0.08", 2, 43), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-aai-1", exchange_url, - "EUR:5.01", 42, 2), - TALER_TESTING_cmd_check_bank_transfer - ("check_bank_transfer-aai-2", exchange_url, - "EUR:5.01", 42, 2), - - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), - TALER_TESTING_cmd_end () - }; - - /** - * This block checks whether a wire deadline - * very far in the future does NOT get aggregated now. - */ - struct TALER_TESTING_Command unaggregation[] = { - TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-a"), - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregated", - "EUR:5.01"), - CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"), - /* "consume" reserve creation transfer. */ - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-unaggregated", - exchange_url, - "EUR:5.01", - 42, - 2), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", - "create-reserve-unaggregated", - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("deposit-unaggregated", - "withdraw-coin-unaggregated", - 0, - TALER_TESTING_make_wire_details - (43, - fakebank_url), - "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_YEARS, - 3000), - "EUR:5", - MHD_HTTP_OK), - CMD_EXEC_AGGREGATOR ("aggregation-attempt"), - TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-b"), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command refund[] = { - /** - * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config. - */ - CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1", - "EUR:5.01"), - /** - * Run wire-watch to trigger the reserve creation. - */ - CMD_EXEC_WIREWATCH ("wirewatch-3"), - /** - * Withdraw a 5 EUR coin, at fee of 1 ct - */ - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", - "create-reserve-r1", - "EUR:5", - MHD_HTTP_OK), - /** - * Spend 5 EUR of the 5 EUR coin (in full). Merchant would - * receive EUR:4.99 due to 1 ct deposit fee. - */ - TALER_TESTING_cmd_deposit ("deposit-refund-1", - "withdraw-coin-r1", - 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_MINUTES, - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_refund ("refund-ok", - MHD_HTTP_OK, - "EUR:5", - "EUR:0.01", - "deposit-refund-1"), - /** - * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone - * due to refund) (merchant would receive EUR:4.98 due to - * 1 ct deposit fee) */ - TALER_TESTING_cmd_deposit ("deposit-refund-2", - "withdraw-coin-r1", - 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:4.99", - MHD_HTTP_OK), - /** - * Run transfers. This will do the transfer as refund deadline was - * 0. - */ - CMD_EXEC_AGGREGATOR ("run-aggregator-3"), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command payback[] = { - /** - * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per - * config. - */ - CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-1", - "EUR:5.01"), - /** - * Run wire-watch to trigger the reserve creation. - */ - CMD_EXEC_WIREWATCH ("wirewatch-4"), - /** - * Withdraw a 5 EUR coin, at fee of 1 ct - */ - TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-1", - "payback-create-reserve-1", - "EUR:5", - MHD_HTTP_OK), - TALER_TESTING_cmd_revoke ("revoke-1", - MHD_HTTP_OK, - "payback-withdraw-coin-1", - CONFIG_FILE), - TALER_TESTING_cmd_payback ("payback-1", - MHD_HTTP_OK, - "payback-withdraw-coin-1", - "EUR:5"), - /** - * Re-withdraw from this reserve - */ - TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2", - "payback-create-reserve-1", - "EUR:1", - MHD_HTTP_OK), - /** - * These commands should close the reserve because the aggregator - * is given a config file that ovverrides the reserve expiration - * time (making it now-ish) - */ - CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", - "EUR:5.01"), - TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation", - CONFIG_FILE_EXPIRE_RESERVE_NOW), - TALER_TESTING_cmd_exec_aggregator ("close-reserves", - CONFIG_FILE_EXPIRE_RESERVE_NOW), - /** - * Fill reserve with EUR:2.02, as withdraw fee is 1 ct per - * config, then withdraw two coin, partially spend one, and - * then have the rest paid back. Check deposit of other coin - * fails. (Do not use EUR:5 here as the EUR:5 coin was - * revoked and we did not bother to create a new one...) - */ - CMD_TRANSFER_TO_EXCHANGE ("payback-create-reserve-2", - "EUR:2.02"), - /** - * Make previous command effective. - */ - CMD_EXEC_WIREWATCH ("wirewatch-5"), - /** - * Withdraw a 1 EUR coin, at fee of 1 ct - */ - TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2a", - "payback-create-reserve-2", - "EUR:1", - MHD_HTTP_OK), - /** - * Withdraw a 1 EUR coin, at fee of 1 ct - */ - TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2b", - "payback-create-reserve-2", - "EUR:1", - MHD_HTTP_OK), - TALER_TESTING_cmd_deposit ("payback-deposit-partial", - "payback-withdraw-coin-2a", - 0, - TALER_TESTING_make_wire_details (42, - fakebank_url), - "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - GNUNET_TIME_UNIT_ZERO, - "EUR:0.5", - MHD_HTTP_OK), - TALER_TESTING_cmd_revoke ("revoke-2", - MHD_HTTP_OK, - "payback-withdraw-coin-2a", - CONFIG_FILE), - TALER_TESTING_cmd_payback ("payback-2", - MHD_HTTP_OK, - "payback-withdraw-coin-2a", - "EUR:0.5"), - TALER_TESTING_cmd_end () - }; - - struct TALER_TESTING_Command commands[] = { - CMD_RUN_AUDITOR("virgin-auditor"), - CMD_RUN_WIRE_AUDITOR("virgin-wire-auditor"), - TALER_TESTING_cmd_batch ("withdraw", - withdraw), - TALER_TESTING_cmd_batch ("spend", - spend), - TALER_TESTING_cmd_batch ("refresh", - refresh), - TALER_TESTING_cmd_batch ("track", - track), - TALER_TESTING_cmd_batch ("unaggregation", - unaggregation), - TALER_TESTING_cmd_batch ("refund", - refund), - TALER_TESTING_cmd_batch ("payback", - payback), - CMD_RUN_AUDITOR("normal-auditor"), - CMD_RUN_WIRE_AUDITOR("normal-wire-auditor"), - TALER_TESTING_cmd_end () - }; - - TALER_TESTING_run_with_fakebank (is, - commands, - fakebank_url); -} - - -int -main (int argc, - char * const *argv) -{ - - /* These environment variables get in the way... */ - unsetenv ("XDG_DATA_HOME"); - unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup ("test-auditor-api", - "INFO", - NULL); - if (NULL == (fakebank_url - /* Check fakebank port is available and config cares - * about bank url. */ - = TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "account-2"))) - return 77; - TALER_TESTING_cleanup_files (CONFIG_FILE); - /* @helpers. Run keyup, create tables, ... Note: it - * fetches the port number from config in order to see - * if it's available. */ - switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, - &auditor_url, - &exchange_url)) - { - case GNUNET_SYSERR: - GNUNET_break (0); - return 1; - case GNUNET_NO: - return 77; - case GNUNET_OK: - if (GNUNET_OK != - /* Set up event loop and reschedule context, plus - * start/stop the exchange. It calls TALER_TESTING_setup - * which creates the 'is' object. - */ - TALER_TESTING_AUDITOR_setup (&run, - NULL, - CONFIG_FILE)) - return 1; - break; - default: - GNUNET_break (0); - return 1; - } - return 0; -} - -/* end of test_auditor_api.c */ diff --git a/src/auditor-lib/test_auditor_api.conf b/src/auditor-lib/test_auditor_api.conf deleted file mode 100644 index 532f9c932..000000000 --- a/src/auditor-lib/test_auditor_api.conf +++ /dev/null @@ -1,202 +0,0 @@ - -# This file is in the public domain. -# -[PATHS] -# Persistant data storage for the testcase -TALER_TEST_HOME = test_exchange_api_home/ - -[taler] -# Currency supported by the exchange (can only be one) -CURRENCY = EUR - -[auditor] -BASE_URL = "http://localhost:8083/" - -# HTTP port the auditor listens to -PORT = 8083 - -[exchange] - -# how long is one signkey valid? -signkey_duration = 4 weeks - -# how long are the signatures with the signkey valid? -legal_duration = 2 years - -# how long do we provide to clients denomination and signing keys -# ahead of time? -lookahead_provide = 4 weeks 1 day - -# HTTP port the exchange listens to -PORT = 8081 - -# Master public key used to sign the exchange's various keys -MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# How to access our database -DB = postgres - -# Base URL of the exchange. Must be set to a URL where the -# exchange (or the twister) is actually listening. -BASE_URL = "http://localhost:8081/" - -# Keep it short so the test runs fast. -LOOKAHEAD_SIGN = 12 h - -[exchangedb-postgres] -CONFIG = "postgres:///talercheck" - -[auditordb-postgres] -CONFIG = "postgres:///talercheck" - -# Sections starting with "account-" configure the bank accounts -# of the exchange. The "URL" specifies the account in -# payto://-format, while the WIRE_JSON specifies the -# (possibly offline) signed version to be returned in /wire. -# WIRE_JSON is optional, as not all accounts must be -# advertised in /wire. -[account-1] -# What is the URL of our account? -URL = "payto://sepa/CH9300762011623852957" -# This is the response we give out for the /wire request. It provides -# wallets with the bank information for transfers to the exchange. -WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json -# Which wire plugin should we used to access the account? -PLUGIN = ebics - -# ENABLE_CREDIT = YES - -[account-2] -# What is the bank account (with the "Taler Bank" demo system)? -URL = "payto://x-taler-bank/localhost:8082/2" - -# This is the response we give out for the /wire request. It provides -# wallets with the bank information for transfers to the exchange. -WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-2.json - -# Which wire plugin should we used to access the account? -PLUGIN = taler_bank - -# Authentication information for basic authentication -TALER_BANK_AUTH_METHOD = "basic" -USERNAME = user -PASSWORD = pass - -ENABLE_DEBIT = YES - -ENABLE_CREDIT = YES - - -# Sections starting with "fee-" configure the wire fee for the -# respective wire method. -[fees-sepa] -# Fees for the forseeable future... -# If you see this after 2017, update to match the next 10 years... -WIRE-FEE-2018 = EUR:0.01 -WIRE-FEE-2019 = EUR:0.01 -WIRE-FEE-2020 = EUR:0.01 -WIRE-FEE-2021 = EUR:0.01 -WIRE-FEE-2022 = EUR:0.01 -WIRE-FEE-2023 = EUR:0.01 -WIRE-FEE-2024 = EUR:0.01 -WIRE-FEE-2025 = EUR:0.01 -WIRE-FEE-2026 = EUR:0.01 -WIRE-FEE-2027 = EUR:0.01 - -CLOSING-FEE-2018 = EUR:0.01 -CLOSING-FEE-2019 = EUR:0.01 -CLOSING-FEE-2020 = EUR:0.01 -CLOSING-FEE-2021 = EUR:0.01 -CLOSING-FEE-2022 = EUR:0.01 -CLOSING-FEE-2023 = EUR:0.01 -CLOSING-FEE-2024 = EUR:0.01 -CLOSING-FEE-2025 = EUR:0.01 -CLOSING-FEE-2026 = EUR:0.01 -CLOSING-FEE-2027 = EUR:0.01 - -[fees-x-taler-bank] -# Fees for the forseeable future... -# If you see this after 2017, update to match the next 10 years... -WIRE-FEE-2018 = EUR:0.01 -WIRE-FEE-2019 = EUR:0.01 -WIRE-FEE-2020 = EUR:0.01 -WIRE-FEE-2021 = EUR:0.01 -WIRE-FEE-2022 = EUR:0.01 -WIRE-FEE-2023 = EUR:0.01 -WIRE-FEE-2024 = EUR:0.01 -WIRE-FEE-2025 = EUR:0.01 -WIRE-FEE-2026 = EUR:0.01 -WIRE-FEE-2027 = EUR:0.01 - -CLOSING-FEE-2018 = EUR:0.01 -CLOSING-FEE-2019 = EUR:0.01 -CLOSING-FEE-2020 = EUR:0.01 -CLOSING-FEE-2021 = EUR:0.01 -CLOSING-FEE-2022 = EUR:0.01 -CLOSING-FEE-2023 = EUR:0.01 -CLOSING-FEE-2024 = EUR:0.01 -CLOSING-FEE-2025 = EUR:0.01 -CLOSING-FEE-2026 = EUR:0.01 -CLOSING-FEE-2027 = EUR:0.01 - -# Sections starting with "coin_" specify which denominations -# the exchange should support (and their respective fee structure) -[coin_eur_ct_1] -value = EUR:0.01 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.00 -fee_deposit = EUR:0.00 -fee_refresh = EUR:0.01 -fee_refund = EUR:0.01 -rsa_keysize = 1024 - -[coin_eur_ct_10] -value = EUR:0.10 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -fee_refund = EUR:0.01 -rsa_keysize = 1024 - -[coin_eur_1] -value = EUR:1 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -fee_refund = EUR:0.01 -rsa_keysize = 1024 - -[coin_eur_5] -value = EUR:5 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -fee_refund = EUR:0.01 -rsa_keysize = 1024 - -[coin_eur_10] -value = EUR:10 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -fee_refund = EUR:0.01 -rsa_keysize = 1024 diff --git a/src/auditor-lib/test_auditor_api_expire_reserve_now.conf b/src/auditor-lib/test_auditor_api_expire_reserve_now.conf deleted file mode 100644 index 05bca956b..000000000 --- a/src/auditor-lib/test_auditor_api_expire_reserve_now.conf +++ /dev/null @@ -1,4 +0,0 @@ -@INLINE@ test_exchange_api.conf - -[exchangedb] -IDLE_RESERVE_EXPIRATION_TIME = 0 s diff --git a/src/auditor-lib/test_exchange_api_home/.config/taler/account-1.json b/src/auditor-lib/test_exchange_api_home/.config/taler/account-1.json deleted file mode 100644 index 48093f2aa..000000000 --- a/src/auditor-lib/test_exchange_api_home/.config/taler/account-1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "url": "payto://sepa/CH9300762011623852957", - "salt": "N83T9J9202WCC8TQFDMJDWEGZNBEKA33C1ZM241VNYH88RZNTHPW509Y1M2YF7Y098R8VRESWQ05H03BK1SPAZCWE54KARDCKT5N8AG", - "master_sig": "D4V5GJ998YK7D6N0N56AD0J6MZNFEW6MRZT2CFPVQ5ME3NMQ59AA2007CXYESSFGRN70CNCFM06858QSSENCWTZM8VHEJ93YQ20ZJ1R" -}
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.config/taler/account-2.json b/src/auditor-lib/test_exchange_api_home/.config/taler/account-2.json deleted file mode 100644 index 159e03171..000000000 --- a/src/auditor-lib/test_exchange_api_home/.config/taler/account-2.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "payto://x-taler-bank/localhost:8082/2", - "master_sig": "HC47BZN3C0KJ2VPMJ5EJWD2FXJ72AET0NWFE6JGSGK5CXS4GSKJJ6Z7BTS56JWM7B40SD61Z5GYYMRRE3X9JTJBVMWE0X7XHNXQ9P38" -}
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.config/taler/sepa.json b/src/auditor-lib/test_exchange_api_home/.config/taler/sepa.json deleted file mode 100644 index b435ce86b..000000000 --- a/src/auditor-lib/test_exchange_api_home/.config/taler/sepa.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Max Musterman", - "bic": "COBADEFF370", - "type": "sepa", - "sig": "4EVRC2MCJPXQC8MC00831DNWEXMZAP4JQDDE1A7R6KR3MANG24RC1VQ55AX5A2E35S58VW1VSTENFTPHG5MWG9BSN8B8WXSV21KKW20", - "address": "Musterstadt", - "salt": "3KTM1ZRMWGEQPQ254S4R5R4Q8XM0ZYWTCTE01TZ76MVBSQ6RX7A5DR08WXVH1DCHR1R7ACRB7X0EVC2XDW1CBZM9WFSD9TRMZ90BR98", - "iban": "DE89370400440532013000" -}
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.config/taler/test.json b/src/auditor-lib/test_exchange_api_home/.config/taler/test.json deleted file mode 100644 index eca394241..000000000 --- a/src/auditor-lib/test_exchange_api_home/.config/taler/test.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "salt": "AZPRFVJ58NM6M7J5CZQPJAH3EW5DYM52AEZ9Y1C1ER3W94QV8D8TQKF6CK8MYQRA9QMSKDQTGZ306ZS9GQ0M6R01CJ20KPP49WFDZK8", - "name": "The exchange", - "account_number": 3, - "bank_url": "http://localhost:8082/", - "type": "test", - "sig": "RPQXP9S4P8PQP7HEZQNRSZCT0ATNEP8GW0P5TPM34V5RX86FCD670V44R9NETSYDDKB8SZV7TKY9PAJYTY51D3VDWY9XXQ5BPFRXR28" -} diff --git a/src/auditor-lib/test_exchange_api_home/.config/taler/x-taler-bank.json b/src/auditor-lib/test_exchange_api_home/.config/taler/x-taler-bank.json deleted file mode 100644 index a15df27ca..000000000 --- a/src/auditor-lib/test_exchange_api_home/.config/taler/x-taler-bank.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "payto://x-taler-bank/http://localhost:8082/2", - "master_sig": "KQ0BWSCNVR7HGGSAMCYK8ZM30RBS1MHMXT3QBN01PZWC9TV72FEE5RJ7T84C8134EPV6WEBXXY2MTFNE8ZXST6JEJQKR8HX6FQPVY10" -}
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.local/share/taler/auditor/offline-keys/auditor.priv b/src/auditor-lib/test_exchange_api_home/.local/share/taler/auditor/offline-keys/auditor.priv deleted file mode 100644 index d71a7722c..000000000 --- a/src/auditor-lib/test_exchange_api_home/.local/share/taler/auditor/offline-keys/auditor.priv +++ /dev/null @@ -1 +0,0 @@ -~}K+*hm^-{{0Z4
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv b/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv deleted file mode 100644 index 394926938..000000000 --- a/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv +++ /dev/null @@ -1 +0,0 @@ -p^-33XX!\0qmU_
\ No newline at end of file diff --git a/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/wirefees/x-taler-bank.fee b/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/wirefees/x-taler-bank.fee Binary files differdeleted file mode 100644 index 68f27cad4..000000000 --- a/src/auditor-lib/test_exchange_api_home/.local/share/taler/exchange/wirefees/x-taler-bank.fee +++ /dev/null diff --git a/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c b/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c deleted file mode 100644 index 6a6e98571..000000000 --- a/src/auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 published by - the Free Software Foundation; either version 3, or (at your - option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/testing_auditor_api_cmd_deposit_confirmation.c - * @brief command for testing /deposit_confirmation. - * @author Christian Grothoff - */ - -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_auditor_service.h" -#include "taler_testing_lib.h" -#include "taler_signatures.h" -#include "backoff.h" - - -/** - * State for a "deposit confirmation" CMD. - */ -struct DepositConfirmationState -{ - - /** - * Reference to any command that is able to provide a deposit. - */ - const char *deposit_reference; - - /** - * What is the deposited amount without the fee (i.e. the - * amount we expect in the deposit confirmation)? - */ - const char *amount_without_fee; - - /** - * Which coin of the @e deposit_reference should we confirm. - */ - unsigned int coin_index; - - /** - * DepositConfirmation handle while operation is running. - */ - struct TALER_AUDITOR_DepositConfirmationHandle *dc; - - /** - * Auditor connection. - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * Interpreter state. - */ - struct TALER_TESTING_Interpreter *is; - - /** - * Task scheduled to try later. - */ - struct GNUNET_SCHEDULER_Task *retry_task; - - /** - * How long do we wait until we retry? - */ - struct GNUNET_TIME_Relative backoff; - - /** - * Expected HTTP response code. - */ - unsigned int expected_response_code; - - /** - * Should we retry on (transient) failures? - */ - int do_retry; - -}; - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -deposit_confirmation_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is); - - -/** - * Task scheduled to re-try #deposit_confirmation_run. - * - * @param cls a `struct DepositConfirmationState` - */ -static void -do_retry (void *cls) -{ - struct DepositConfirmationState *dcs = cls; - - dcs->retry_task = NULL; - deposit_confirmation_run (dcs, - NULL, - dcs->is); -} - - -/** - * Callback to analyze the /deposit-confirmation response, just used - * to check if the response code is acceptable. - * - * @param cls closure. - * @param http_status HTTP response code. - * @param ec taler-specific error code. - * @param obj raw response from the auditor. - */ -static void -deposit_confirmation_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - const json_t *obj) -{ - struct DepositConfirmationState *dcs = cls; - - dcs->dc = NULL; - if (dcs->expected_response_code != http_status) - { - if (GNUNET_YES == dcs->do_retry) - { - if ( (0 == http_status) || - (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Retrying deposit confirmation failed with %u/%d\n", - http_status, - (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - dcs->backoff = GNUNET_TIME_UNIT_ZERO; - else - dcs->backoff = AUDITOR_LIB_BACKOFF (dcs->backoff); - dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff, - &do_retry, - dcs); - return; - } - } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - http_status, - dcs->is->commands[dcs->is->ip].label, - __FILE__, - __LINE__); - json_dumpf (obj, stderr, 0); - TALER_TESTING_interpreter_fail (dcs->is); - return; - } - TALER_TESTING_interpreter_next (dcs->is); -} - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -deposit_confirmation_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct DepositConfirmationState *dcs = cls; - const struct TALER_TESTING_Command *deposit_cmd; - struct GNUNET_HashCode h_wire; - struct GNUNET_HashCode h_contract_terms; - struct GNUNET_TIME_Absolute timestamp; - struct GNUNET_TIME_Absolute refund_deadline; - struct TALER_Amount amount_without_fee; - struct TALER_CoinSpendPublicKeyP coin_pub; - const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv; - struct TALER_MerchantPublicKeyP merchant_pub; - const struct TALER_ExchangePublicKeyP *exchange_pub; - const struct TALER_ExchangeSignatureP *exchange_sig; - const json_t *wire_details; - const json_t *contract_terms; - const struct TALER_CoinSpendPrivateKeyP *coin_priv; - const struct TALER_EXCHANGE_Keys *keys; - const struct TALER_EXCHANGE_SigningPublicKey *spk; - - dcs->is = is; - GNUNET_assert (NULL != dcs->deposit_reference); - deposit_cmd - = TALER_TESTING_interpreter_lookup_command (is, - dcs->deposit_reference); - if (NULL == deposit_cmd) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_exchange_pub (deposit_cmd, - dcs->coin_index, - &exchange_pub)); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_exchange_sig (deposit_cmd, - dcs->coin_index, - &exchange_sig)); - keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); - GNUNET_assert (NULL != keys); - spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys, - exchange_pub); - - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_contract_terms (deposit_cmd, - dcs->coin_index, - &contract_terms)); - /* Very unlikely to fail */ - GNUNET_assert (NULL != contract_terms); - TALER_JSON_hash (contract_terms, - &h_contract_terms); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_wire_details (deposit_cmd, - dcs->coin_index, - &wire_details)); - TALER_JSON_hash (wire_details, - &h_wire); - - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_coin_priv (deposit_cmd, - dcs->coin_index, - &coin_priv)); - GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, - &coin_pub.eddsa_pub); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_peer_key (deposit_cmd, - dcs->coin_index, - &merchant_priv)); - GNUNET_CRYPTO_eddsa_key_get_public (merchant_priv, - &merchant_pub.eddsa_pub); - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (dcs->amount_without_fee, - &amount_without_fee)); - - dcs->dc = TALER_AUDITOR_deposit_confirmation - (dcs->auditor, - &h_wire, - &h_contract_terms, - timestamp, - refund_deadline, - &amount_without_fee, - &coin_pub, - &merchant_pub, - exchange_pub, - exchange_sig, - &keys->master_pub, - spk->valid_from, - spk->valid_until, - spk->valid_legal, - &spk->master_sig, - &deposit_confirmation_cb, - dcs); - - if (NULL == dcs->dc) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - return; -} - - -/** - * Free the state of a "deposit_confirmation" CMD, and possibly cancel a - * pending operation thereof. - * - * @param cls closure, a `struct DepositConfirmationState` - * @param cmd the command which is being cleaned up. - */ -static void -deposit_confirmation_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct DepositConfirmationState *dcs = cls; - - if (NULL != dcs->dc) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %u (%s) did not complete\n", - dcs->is->ip, - cmd->label); - TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc); - dcs->dc = NULL; - } - if (NULL != dcs->retry_task) - { - GNUNET_SCHEDULER_cancel (dcs->retry_task); - dcs->retry_task = NULL; - } - GNUNET_free (dcs); -} - - -/** - * Offer internal data to other commands. - * - * @param cls closure. - * @param ret[out] set to the wanted data. - * @param trait name of the trait. - * @param index index number of the traits to be returned. - * - * @return #GNUNET_OK on success - */ -static int -deposit_confirmation_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - /* Must define this function because some callbacks - * look for certain traits on _all_ the commands. */ - return GNUNET_SYSERR; -} - - -/** - * Create a "deposit-confirmation" command. - * - * @param label command label. - * @param auditor auditor connection. - * @param deposit_reference reference to any operation that can - * provide a coin. - * @param coin_index if @a deposit_reference offers an array of - * coins, this parameter selects which one in that array. - * This value is currently ignored, as only one-coin - * deposits are implemented. - * @param amount_without_fee deposited amount without the fee - * @param expected_response_code expected HTTP response code. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation - (const char *label, - struct TALER_AUDITOR_Handle *auditor, - const char *deposit_reference, - unsigned int coin_index, - const char *amount_without_fee, - unsigned int expected_response_code) -{ - struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ - struct DepositConfirmationState *dcs; - - dcs = GNUNET_new (struct DepositConfirmationState); - dcs->auditor = auditor; - dcs->deposit_reference = deposit_reference; - dcs->coin_index = coin_index; - dcs->amount_without_fee = amount_without_fee; - dcs->expected_response_code = expected_response_code; - - cmd.cls = dcs; - cmd.label = label; - cmd.run = &deposit_confirmation_run; - cmd.cleanup = &deposit_confirmation_cleanup; - cmd.traits = &deposit_confirmation_traits; - - return cmd; -} - - -/** - * Modify a deposit confirmation command to enable retries when we get - * transient errors from the auditor. - * - * @param cmd a deposit confirmation command - * @return the command with retries enabled - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command cmd) -{ - struct DepositConfirmationState *dcs; - - GNUNET_assert (&deposit_confirmation_run == cmd.run); - dcs = cmd.cls; - dcs->do_retry = GNUNET_YES; - return cmd; -} - - -/* end of testing_auditor_api_cmd_deposit_confirmation.c */ diff --git a/src/auditor-lib/testing_auditor_api_cmd_exchanges.c b/src/auditor-lib/testing_auditor_api_cmd_exchanges.c deleted file mode 100644 index 71b82a39a..000000000 --- a/src/auditor-lib/testing_auditor_api_cmd_exchanges.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 published by - the Free Software Foundation; either version 3, or (at your - option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file auditor-lib/testing_auditor_api_cmd_exchanges.c - * @brief command for testing /exchanges. - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_auditor_service.h" -#include "taler_testing_lib.h" -#include "taler_signatures.h" -#include "backoff.h" - - -/** - * State for a "deposit confirmation" CMD. - */ -struct ExchangesState -{ - - /** - * Exchanges handle while operation is running. - */ - struct TALER_AUDITOR_ListExchangesHandle *leh; - - /** - * Auditor connection. - */ - struct TALER_AUDITOR_Handle *auditor; - - /** - * Interpreter state. - */ - struct TALER_TESTING_Interpreter *is; - - /** - * Task scheduled to try later. - */ - struct GNUNET_SCHEDULER_Task *retry_task; - - /** - * How long do we wait until we retry? - */ - struct GNUNET_TIME_Relative backoff; - - /** - * Expected HTTP response code. - */ - unsigned int expected_response_code; - - /** - * Should we retry on (transient) failures? - */ - int do_retry; - -}; - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -exchanges_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is); - - -/** - * Task scheduled to re-try #exchanges_run. - * - * @param cls a `struct ExchangesState` - */ -static void -do_retry (void *cls) -{ - struct ExchangesState *es = cls; - - es->retry_task = NULL; - exchanges_run (es, - NULL, - es->is); -} - - -/** - * Callback to analyze the /exchanges response. - * - * @param cls closure. - * @param http_status HTTP response code. - * @param ec taler-specific error code. - * @param obj raw response from the auditor. - */ -static void -exchanges_cb (void *cls, - unsigned int http_status, - enum TALER_ErrorCode ec, - unsigned int num_exchanges, - const struct TALER_AUDITOR_ExchangeInfo *ei, - const json_t *raw_response) -{ - struct ExchangesState *es = cls; - - es->leh = NULL; - if (es->expected_response_code != http_status) - { - if (GNUNET_YES == es->do_retry) - { - if ( (0 == http_status) || - (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) || - (MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Retrying list exchanges failed with %u/%d\n", - http_status, - (int) ec); - /* on DB conflicts, do not use backoff */ - if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) - es->backoff = GNUNET_TIME_UNIT_ZERO; - else - es->backoff = AUDITOR_LIB_BACKOFF (es->backoff); - es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff, - &do_retry, - es); - return; - } - } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - http_status, - es->is->commands[es->is->ip].label, - __FILE__, - __LINE__); - json_dumpf (raw_response, stderr, 0); - TALER_TESTING_interpreter_fail (es->is); - return; - } - TALER_TESTING_interpreter_next (es->is); -} - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -exchanges_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct ExchangesState *es = cls; - - es->is = is; - es->leh = TALER_AUDITOR_list_exchanges - (es->auditor, - &exchanges_cb, - es); - - if (NULL == es->leh) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - return; -} - - -/** - * Free the state of a "exchanges" CMD, and possibly cancel a - * pending operation thereof. - * - * @param cls closure, a `struct ExchangesState` - * @param cmd the command which is being cleaned up. - */ -static void -exchanges_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct ExchangesState *es = cls; - - if (NULL != es->leh) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %u (%s) did not complete\n", - es->is->ip, - cmd->label); - TALER_AUDITOR_list_exchanges_cancel (es->leh); - es->leh = NULL; - } - if (NULL != es->retry_task) - { - GNUNET_SCHEDULER_cancel (es->retry_task); - es->retry_task = NULL; - } - GNUNET_free (es); -} - - -/** - * Offer internal data to other commands. - * - * @param cls closure. - * @param ret[out] set to the wanted data. - * @param trait name of the trait. - * @param index index number of the traits to be returned. - * - * @return #GNUNET_OK on success - */ -static int -exchanges_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - /* Must define this function because some callbacks - * look for certain traits on _all_ the commands. */ - return GNUNET_SYSERR; -} - - -/** - * Create a "list exchanges" command. - * - * @param label command label. - * @param auditor auditor connection. - * @param expected_response_code expected HTTP response code. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges - (const char *label, - struct TALER_AUDITOR_Handle *auditor, - unsigned int expected_response_code) -{ - struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ - struct ExchangesState *es; - - es = GNUNET_new (struct ExchangesState); - es->auditor = auditor; - es->expected_response_code = expected_response_code; - - cmd.cls = es; - cmd.label = label; - cmd.run = &exchanges_run; - cmd.cleanup = &exchanges_cleanup; - cmd.traits = &exchanges_traits; - - return cmd; -} - - -/** - * Modify an exchanges command to enable retries when we get - * transient errors from the auditor. - * - * @param cmd a deposit confirmation command - * @return the command with retries enabled - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exchanges_with_retry (struct TALER_TESTING_Command cmd) -{ - struct ExchangesState *es; - - GNUNET_assert (&exchanges_run == cmd.run); - es = cmd.cls; - es->do_retry = GNUNET_YES; - return cmd; -} - - -/* end of testing_auditor_api_cmd_exchanges.c */ diff --git a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c b/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c deleted file mode 100644 index afe9d38fc..000000000 --- a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 published - by the Free Software Foundation; either version 3, or (at your - option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, - see <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/testing_auditor_api_cmd_exec_auditor.c - * @brief run the taler-auditor command - * @author Marcello Stanisci - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "auditor_api_handle.h" -#include "taler_signatures.h" -#include "taler_testing_lib.h" - - -/** - * State for a "auditor" CMD. - */ -struct AuditorState -{ - - /** - * Process for the "auditor" command. - */ - struct GNUNET_OS_Process *auditor_proc; - - /** - * Configuration file used by the command. - */ - const char *config_filename; -}; - - -/** - * Run the command; calls the `taler-auditor' program. - * - * @param cls closure. - * @param cmd the commaind being run. - * @param is interpreter state. - */ -static void -auditor_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct AuditorState *ks = cls; - - ks->auditor_proc - = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-auditor", - "taler-auditor", - "-c", ks->config_filename, - NULL); - if (NULL == ks->auditor_proc) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - TALER_TESTING_wait_for_sigchld (is); -} - - -/** - * Free the state of a "auditor" CMD, and possibly kills its - * process if it did not terminate correctly. - * - * @param cls closure. - * @param cmd the command being freed. - */ -static void -auditor_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct AuditorState *ks = cls; - - if (NULL != ks->auditor_proc) - { - GNUNET_break (0 == - GNUNET_OS_process_kill (ks->auditor_proc, - SIGKILL)); - GNUNET_OS_process_wait (ks->auditor_proc); - GNUNET_OS_process_destroy (ks->auditor_proc); - ks->auditor_proc = NULL; - } - GNUNET_free (ks); -} - - -/** - * Offer "auditor" CMD internal data to other commands. - * - * @param cls closure. - * @param ret[out] result - * @param trait name of the trait. - * @param index index number of the object to offer. - * @return #GNUNET_OK on success. - */ -static int -auditor_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - struct AuditorState *ks = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_process (0, &ks->auditor_proc), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); -} - - -/** - * Make the "exec-auditor" CMD. - * - * @param label command label. - * @param config_filename configuration filename. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_auditor (const char *label, - const char *config_filename) -{ - struct TALER_TESTING_Command cmd; - struct AuditorState *ks; - - ks = GNUNET_new (struct AuditorState); - ks->config_filename = config_filename; - cmd.cls = ks; - cmd.label = label; - cmd.run = &auditor_run; - cmd.cleanup = &auditor_cleanup; - cmd.traits = &auditor_traits; - return cmd; -} - -/* end of testing_auditor_api_cmd_exec_auditor.c */ diff --git a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor_dbinit.c b/src/auditor-lib/testing_auditor_api_cmd_exec_auditor_dbinit.c deleted file mode 100644 index 09771660c..000000000 --- a/src/auditor-lib/testing_auditor_api_cmd_exec_auditor_dbinit.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 published - by the Free Software Foundation; either version 3, or (at your - option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, - see <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/testing_auditor_api_cmd_exec_auditor_dbinit.c - * @brief run the taler-auditor-dbinit "-r" command - * @author Marcello Stanisci - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "auditor_api_handle.h" -#include "taler_signatures.h" -#include "taler_testing_lib.h" - - -/** - * State for a "auditor-dbinit" CMD. - */ -struct AuditorDbinitState -{ - - /** - * Process for the "auditor-dbinit" command. - */ - struct GNUNET_OS_Process *auditor_dbinit_proc; - - /** - * Configuration file used by the command. - */ - const char *config_filename; -}; - - -/** - * Run the command; calls the `taler-auditor-dbinit' program. - * - * @param cls closure. - * @param cmd the commaind being run. - * @param is interpreter state. - */ -static void -auditor_dbinit_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct AuditorDbinitState *ks = cls; - - ks->auditor_dbinit_proc - = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-auditor-dbinit", - "taler-auditor-dbinit", - "-c", ks->config_filename, - "-r", - NULL); - if (NULL == ks->auditor_dbinit_proc) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - TALER_TESTING_wait_for_sigchld (is); -} - - -/** - * Free the state of a "auditor-dbinit" CMD, and possibly kills its - * process if it did not terminate correctly. - * - * @param cls closure. - * @param cmd the command being freed. - */ -static void -auditor_dbinit_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct AuditorDbinitState *ks = cls; - - if (NULL != ks->auditor_dbinit_proc) - { - GNUNET_break (0 == - GNUNET_OS_process_kill (ks->auditor_dbinit_proc, - SIGKILL)); - GNUNET_OS_process_wait (ks->auditor_dbinit_proc); - GNUNET_OS_process_destroy (ks->auditor_dbinit_proc); - ks->auditor_dbinit_proc = NULL; - } - GNUNET_free (ks); -} - - -/** - * Offer "auditor-dbinit" CMD internal data to other commands. - * - * @param cls closure. - * @param ret[out] result - * @param trait name of the trait. - * @param index index number of the object to offer. - * @return #GNUNET_OK on success. - */ -static int -auditor_dbinit_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - struct AuditorDbinitState *ks = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_process (0, &ks->auditor_dbinit_proc), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); -} - - -/** - * Make the "exec-auditor-dbinit" CMD. - * - * @param label command label. - * @param config_filename configuration filename. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_auditor_dbinit (const char *label, - const char *config_filename) -{ - struct TALER_TESTING_Command cmd; - struct AuditorDbinitState *ks; - - ks = GNUNET_new (struct AuditorDbinitState); - ks->config_filename = config_filename; - cmd.cls = ks; - cmd.label = label; - cmd.run = &auditor_dbinit_run; - cmd.cleanup = &auditor_dbinit_cleanup; - cmd.traits = &auditor_dbinit_traits; - return cmd; -} - -/* end of testing_auditor_api_cmd_exec_auditor_dbinit.c */ diff --git a/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c b/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c deleted file mode 100644 index 8371f9690..000000000 --- a/src/auditor-lib/testing_auditor_api_cmd_exec_wire_auditor.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 published - by the Free Software Foundation; either version 3, or (at your - option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, - see <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/testing_auditor_api_cmd_exec_wire-auditor.c - * @brief run the taler-wire-auditor command - * @author Marcello Stanisci - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "auditor_api_handle.h" -#include "taler_signatures.h" -#include "taler_testing_lib.h" - - -/** - * State for a "wire-auditor" CMD. - */ -struct WireAuditorState -{ - - /** - * Process for the "wire-auditor" command. - */ - struct GNUNET_OS_Process *wire_auditor_proc; - - /** - * Configuration file used by the command. - */ - const char *config_filename; -}; - - -/** - * Run the command; calls the `taler-wire-auditor' program. - * - * @param cls closure. - * @param cmd the commaind being run. - * @param is interpreter state. - */ -static void -wire_auditor_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct WireAuditorState *ks = cls; - - ks->wire_auditor_proc - = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-wire-auditor", - "taler-wire-auditor", - "-c", ks->config_filename, - NULL); - if (NULL == ks->wire_auditor_proc) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - TALER_TESTING_wait_for_sigchld (is); -} - - -/** - * Free the state of a "wire-auditor" CMD, and possibly kills its - * process if it did not terminate correctly. - * - * @param cls closure. - * @param cmd the command being freed. - */ -static void -wire_auditor_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct WireAuditorState *ks = cls; - - if (NULL != ks->wire_auditor_proc) - { - GNUNET_break (0 == - GNUNET_OS_process_kill (ks->wire_auditor_proc, - SIGKILL)); - GNUNET_OS_process_wait (ks->wire_auditor_proc); - GNUNET_OS_process_destroy (ks->wire_auditor_proc); - ks->wire_auditor_proc = NULL; - } - GNUNET_free (ks); -} - - -/** - * Offer "wire-auditor" CMD internal data to other commands. - * - * @param cls closure. - * @param ret[out] result - * @param trait name of the trait. - * @param index index number of the object to offer. - * @return #GNUNET_OK on success. - */ -static int -wire_auditor_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - struct WireAuditorState *ks = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_process (0, &ks->wire_auditor_proc), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); -} - - -/** - * Make the "exec wire-auditor" CMD. - * - * @param label command label. - * @param config_filename configuration filename. - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_wire_auditor (const char *label, - const char *config_filename) -{ - struct TALER_TESTING_Command cmd; - struct WireAuditorState *ks; - - ks = GNUNET_new (struct WireAuditorState); - ks->config_filename = config_filename; - cmd.cls = ks; - cmd.label = label; - cmd.run = &wire_auditor_run; - cmd.cleanup = &wire_auditor_cleanup; - cmd.traits = &wire_auditor_traits; - return cmd; -} - -/* end of testing_auditor_api_cmd_exec_wire_auditor.c */ diff --git a/src/auditor-lib/testing_auditor_api_helpers.c b/src/auditor-lib/testing_auditor_api_helpers.c deleted file mode 100644 index 7e7103150..000000000 --- a/src/auditor-lib/testing_auditor_api_helpers.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 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 - published by the Free Software Foundation; either version 3, or - (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with TALER; see the file COPYING. If not, see - <http://www.gnu.org/licenses/> -*/ - -/** - * @file auditor-lib/testing_auditor_api_helpers.c - * @brief helper functions - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_testing_lib.h" -#include "taler_testing_auditor_lib.h" -#include "taler_auditor_service.h" - - -/** - * Closure for #cleanup_auditor. - */ -struct CleanupContext -{ - /** - * Where we find the state to clean up. - */ - struct TALER_TESTING_Interpreter *is; - - /** - * Next cleanup routine to call, NULL for none. - */ - GNUNET_SCHEDULER_TaskCallback fcb; - - /** - * Closure for @e fcb - */ - void *fcb_cls; -}; - - -/** - * Function to clean up the auditor connection. - * - * @param cls a `struct CleanupContext` - */ -static void -cleanup_auditor (void *cls) -{ - struct CleanupContext *cc = cls; - struct TALER_TESTING_Interpreter *is = cc->is; - - TALER_AUDITOR_disconnect (is->auditor); - is->auditor = NULL; - if (NULL != cc->fcb) - cc->fcb (cc->fcb_cls); - GNUNET_free (cc); -} - - - -/** - * Function called with information about the auditor. - * - * @param cls closure - * @param vi basic information about the auditor - * @param compat protocol compatibility information - */ -static void -auditor_version_cb (void *cls, - const struct TALER_AUDITOR_VersionInformation *vi, - enum TALER_AUDITOR_VersionCompatibility compat) -{ - struct TALER_TESTING_Interpreter *is = cls; - - /* TODO: check vi/compat? */ - is->auditor_working = GNUNET_YES; -} - - - -/** - * Closure for #auditor_main_wrapper() - */ -struct MainWrapperContext -{ - /** - * Main function to launch. - */ - TALER_TESTING_Main main_cb; - - /** - * Closure for @e main_cb. - */ - void *main_cb_cls; - - /** - * Configuration we use. - */ - const struct GNUNET_CONFIGURATION_Handle *cfg; - - /** - * Name of the configuration file. - */ - const char *config_filename; - -}; - - -/** - * Setup the @a is 'auditor' member before running the main test loop. - * - * @param cls must be a `struct MainWrapperContext *` - * @param is[in,out] interpreter state to setup - */ -static void -auditor_main_wrapper (void *cls, - struct TALER_TESTING_Interpreter *is) -{ - struct MainWrapperContext *mwc = cls; - struct CleanupContext *cc; - char *auditor_base_url; - - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (mwc->cfg, - "auditor", - "BASE_URL", - &auditor_base_url)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "auditor", - "BASE_URL"); - return; - } - is->auditor = TALER_AUDITOR_connect (is->ctx, - auditor_base_url, - &auditor_version_cb, - is); - GNUNET_free (auditor_base_url); - if (NULL == is->auditor) - { - GNUNET_break (0); - return; - } - cc = GNUNET_new (struct CleanupContext); - cc->is = is; - cc->fcb = is->final_cleanup_cb; - cc->fcb_cls = is->final_cleanup_cb; - is->final_cleanup_cb = &cleanup_auditor; - is->final_cleanup_cb_cls = cc; - mwc->main_cb (mwc->main_cb_cls, - is); -} - - -/** - * Install signal handlers plus schedules the main wrapper - * around the "run" method. - * - * @param cls our `struct MainWrapperContext` - * @param cfg configuration we use - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-GNUNET_OK codes are #GNUNET_SYSERR most of the - * times. - */ -static int -setup_with_cfg (void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg) -{ - struct MainWrapperContext *mwc = cls; - struct TALER_TESTING_SetupContext setup_ctx = { - .config_filename = mwc->config_filename, - .main_cb = &auditor_main_wrapper, - .main_cb_cls = mwc - }; - - mwc->cfg = cfg; - return TALER_TESTING_setup_with_auditor_and_exchange_cfg (&setup_ctx, - cfg); -} - - -/** - * Install signal handlers plus schedules the main wrapper - * around the "run" method. - * - * @param main_cb the "run" method which contains all the - * commands. - * @param main_cb_cls a closure for "run", typically NULL. - * @param config_filename configuration filename. - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-GNUNET_OK codes are #GNUNET_SYSERR most of the - * times. - */ -int -TALER_TESTING_AUDITOR_setup (TALER_TESTING_Main main_cb, - void *main_cb_cls, - const char *config_filename) -{ - struct MainWrapperContext mwc = { - .main_cb = main_cb, - .main_cb_cls = main_cb_cls, - .config_filename = config_filename - }; - - return GNUNET_CONFIGURATION_parse_and_run (config_filename, - &setup_with_cfg, - &mwc); -} - - - -/* end of testing_auditor_api_helpers.c */ |