diff options
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/Makefile.am | 3 | ||||
| -rw-r--r-- | src/testing/test_auditor_api.c | 2 | ||||
| -rw-r--r-- | src/testing/test_exchange_api.c | 2 | ||||
| -rw-r--r-- | src/testing/test_exchange_api.conf | 2 | ||||
| -rw-r--r-- | src/testing/test_exchange_api_keys_cherry_picking.c | 23 | ||||
| -rw-r--r-- | src/testing/test_exchange_api_overlapping_keys_bug.c | 16 | ||||
| -rw-r--r-- | src/testing/test_exchange_api_revocation.c | 13 | ||||
| -rw-r--r-- | src/testing/test_exchange_api_twisted.c | 1 | ||||
| -rw-r--r-- | src/testing/test_exchange_management_api.c | 12 | ||||
| -rw-r--r-- | src/testing/test_exchange_p2p.c | 2 | ||||
| -rw-r--r-- | src/testing/test_kyc_api.c | 2 | ||||
| -rw-r--r-- | src/testing/test_taler_exchange_wirewatch.c | 2 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_check_keys.c | 203 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_connect_with_state.c | 208 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_get_exchange.c | 97 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_run_fakebank.c | 1 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_serialize_keys.c | 144 | 
17 files changed, 138 insertions, 595 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 1de9b602..a66aa742 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -59,9 +59,7 @@ libtalertesting_la_SOURCES = \    testing_api_cmd_batch_withdraw.c \    testing_api_cmd_check_aml_decision.c \    testing_api_cmd_check_aml_decisions.c \ -  testing_api_cmd_check_keys.c \    testing_api_cmd_common.c \ -  testing_api_cmd_connect_with_state.c \    testing_api_cmd_contract_get.c \    testing_api_cmd_deposit.c \    testing_api_cmd_deposits_get.c \ @@ -106,7 +104,6 @@ libtalertesting_la_SOURCES = \    testing_api_cmd_revoke_denom_key.c \    testing_api_cmd_revoke_sign_key.c \    testing_api_cmd_run_fakebank.c \ -  testing_api_cmd_serialize_keys.c \    testing_api_cmd_set_officer.c \    testing_api_cmd_set_wire_fee.c \    testing_api_cmd_signal.c \ diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c index b5d6df0c..23646870 100644 --- a/src/testing/test_auditor_api.c +++ b/src/testing/test_auditor_api.c @@ -653,12 +653,12 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true),      TALER_TESTING_cmd_get_auditor ("get-auditor",                                     cred.cfg,                                     true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),      TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline",                                              config_file),      CMD_RUN_AUDITOR ("virgin-auditor"), diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 8ecf5d5b..21891350 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -1235,9 +1235,9 @@ run (void *cls,                                        NULL),        TALER_TESTING_cmd_get_exchange ("get-exchange",                                        cred.cfg, +                                      NULL,                                        true,                                        true), -      // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),        TALER_TESTING_cmd_batch ("wire",                                 wire),        TALER_TESTING_cmd_batch ("withdraw", diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf index b7f8c5c6..c0e4d2f4 100644 --- a/src/testing/test_exchange_api.conf +++ b/src/testing/test_exchange_api.conf @@ -21,7 +21,7 @@ CONFIG = "postgres:///talercheck"  HTTP_PORT = 8082  [exchange] -TERMS_ETAG = 0 +TERMS_ETAG = tos  PRIVACY_ETAG = 0  AML_THRESHOLD = EUR:1000000  PORT = 8081 diff --git a/src/testing/test_exchange_api_keys_cherry_picking.c b/src/testing/test_exchange_api_keys_cherry_picking.c index 11e18e5c..f2a8b88e 100644 --- a/src/testing/test_exchange_api_keys_cherry_picking.c +++ b/src/testing/test_exchange_api_keys_cherry_picking.c @@ -65,22 +65,21 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys"),      TALER_TESTING_cmd_sleep ("sleep",                               6 /* seconds */), -    TALER_TESTING_cmd_check_keys ("check-keys-1"), -    TALER_TESTING_cmd_check_keys_with_last_denom ("check-keys-2", -                                                  "check-keys-1"), -    TALER_TESTING_cmd_serialize_keys ("serialize-keys"), -    TALER_TESTING_cmd_connect_with_state ("reconnect-with-state", -                                          "serialize-keys"), -    /** -     * Make sure we have the same keys situation as -     * it was before the serialization. -     */ -    TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization"), +    TALER_TESTING_cmd_get_exchange ("get-exchange-1", +                                    cred.cfg, +                                    "get-exchange", +                                    true, +                                    true), +    TALER_TESTING_cmd_get_exchange ("get-exchange-2", +                                    cred.cfg, +                                    "get-exchange-1", +                                    true, +                                    true),      /**       * Use one of the deserialized keys.       */ diff --git a/src/testing/test_exchange_api_overlapping_keys_bug.c b/src/testing/test_exchange_api_overlapping_keys_bug.c index 3f7353b9..e88cc2c3 100644 --- a/src/testing/test_exchange_api_overlapping_keys_bug.c +++ b/src/testing/test_exchange_api_overlapping_keys_bug.c @@ -69,13 +69,19 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL, +                                    true, +                                    true), +    TALER_TESTING_cmd_get_exchange ("get-exchange-1", +                                    cred.cfg, +                                    "get-exchange", +                                    true, +                                    true), +    TALER_TESTING_cmd_get_exchange ("get-exchange-2", +                                    cred.cfg, +                                    NULL,                                      true,                                      true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"), -    TALER_TESTING_cmd_check_keys ("first-download"), -    /* Causes GET /keys?last_denom_issue=0 */ -    TALER_TESTING_cmd_check_keys_with_last_denom ("second-download", -                                                  "zero"),      TALER_TESTING_cmd_end ()    }; diff --git a/src/testing/test_exchange_api_revocation.c b/src/testing/test_exchange_api_revocation.c index 1cb544da..70e5fa78 100644 --- a/src/testing/test_exchange_api_revocation.c +++ b/src/testing/test_exchange_api_revocation.c @@ -67,20 +67,9 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true), -#if 0 -    TALER_TESTING_cmd_auditor_add ("add-auditor-OK", -                                   MHD_HTTP_NO_CONTENT, -                                   false), -    TALER_TESTING_cmd_wire_add ("add-wire-account", -                                "payto://x-taler-bank/localhost/2?receiver-name=2", -                                MHD_HTTP_NO_CONTENT, -                                false), -    TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys", -                                              config_file), -#endif -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),      /**       * Fill reserve with EUR:10.02, as withdraw fee is 1 ct per       * config. diff --git a/src/testing/test_exchange_api_twisted.c b/src/testing/test_exchange_api_twisted.c index 3a7455eb..5324a102 100644 --- a/src/testing/test_exchange_api_twisted.c +++ b/src/testing/test_exchange_api_twisted.c @@ -255,6 +255,7 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true),      TALER_TESTING_cmd_batch ( diff --git a/src/testing/test_exchange_management_api.c b/src/testing/test_exchange_management_api.c index fded3f03..c92d4c22 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -59,6 +59,7 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true),      TALER_TESTING_cmd_get_auditor ("get-auditor", @@ -145,7 +146,16 @@ run (void *cls,                                  false),      TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",                                                config_file), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"), +    TALER_TESTING_cmd_get_exchange ("get-exchange-1", +                                    cred.cfg, +                                    "get-exchange", +                                    true, +                                    true), +    TALER_TESTING_cmd_get_exchange ("get-exchange-2", +                                    cred.cfg, +                                    NULL, +                                    true, +                                    true),      TALER_TESTING_cmd_end ()    }; diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c index 689d2460..3bf19135 100644 --- a/src/testing/test_exchange_p2p.c +++ b/src/testing/test_exchange_p2p.c @@ -504,9 +504,9 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),      TALER_TESTING_cmd_batch ("withdraw",                               withdraw),      TALER_TESTING_cmd_batch ("push", diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 733a5e2f..c4560419 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -523,9 +523,9 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),      TALER_TESTING_cmd_batch ("withdraw",                               withdraw),      TALER_TESTING_cmd_batch ("spend", diff --git a/src/testing/test_taler_exchange_wirewatch.c b/src/testing/test_taler_exchange_wirewatch.c index 54d25887..86b61645 100644 --- a/src/testing/test_taler_exchange_wirewatch.c +++ b/src/testing/test_taler_exchange_wirewatch.c @@ -87,9 +87,9 @@ run (void *cls,                                      NULL),      TALER_TESTING_cmd_get_exchange ("get-exchange",                                      cred.cfg, +                                    NULL,                                      true,                                      true), -    // FIXME: TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),      TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),      CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"),      TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-empty", diff --git a/src/testing/testing_api_cmd_check_keys.c b/src/testing/testing_api_cmd_check_keys.c deleted file mode 100644 index e483424c..00000000 --- a/src/testing/testing_api_cmd_check_keys.c +++ /dev/null @@ -1,203 +0,0 @@ -/* -  This file is part of TALER -  (C) 2018, 2020, 2021 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 testing/testing_api_cmd_check_keys.c - * @brief Implementation of "check keys" test command. - * @author Marcello Stanisci - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include <gnunet/gnunet_curl_lib.h> -#include "taler_testing_lib.h" - -// FIXME: duplicated with testing_api_cmd_connect_with_state -// FIXME: this is now duplicated with testing_api_cmd_get_exchange! - -/** - * State for a "check keys" CMD. - */ -struct CheckKeysState -{ - -  /** -   * Label of a command to use to derive the "last_denom_issue" date to use. -   * FIXME: actually use this! -   */ -  const char *last_denom_date_ref; - -  /** -   * Our interpreter state. -   */ -  struct TALER_TESTING_Interpreter *is; - -  /** -   * Our get keys operation. -   */ -  struct TALER_EXCHANGE_GetKeysHandle *gkh; - -  /** -   * Last denomination date we received when doing this request. -   */ -  struct GNUNET_TIME_Timestamp my_denom_date; -}; - - -/** - * Function called with information about who is auditing - * a particular exchange and what keys the exchange is using. - * - * @param cls closure - * @param kr response from /keys - */ -static void -keys_cb (void *cls, -         const struct TALER_EXCHANGE_KeysResponse *kr, -         struct TALER_EXCHANGE_Keys *keys) -{ -  struct CheckKeysState *cks = cls; - -  cks->gkh = NULL; -  if (MHD_HTTP_OK != kr->hr.http_status) -  { -    TALER_TESTING_unexpected_status (cks->is, -                                     kr->hr.http_status, -                                     MHD_HTTP_OK); -    return; -  } -  cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date; -  /* FIXME: expose keys (and exchange_url) via trait! */ -  TALER_EXCHANGE_keys_decref (keys); -  TALER_TESTING_interpreter_next (cks->is); -} - - -/** - * Run the "check keys" command. - * - * @param cls closure. - * @param cmd the command currently being executed. - * @param is the interpreter state. - */ -static void -check_keys_run (void *cls, -                const struct TALER_TESTING_Command *cmd, -                struct TALER_TESTING_Interpreter *is) -{ -  struct CheckKeysState *cks = cls; -  const char *exchange_url -    = TALER_TESTING_get_exchange_url (is); - -  cks->is = is; -  GNUNET_log (GNUNET_ERROR_TYPE_INFO, -              "Triggering GET /keys, cmd `%s'\n", -              cmd->label); -  cks->gkh = TALER_EXCHANGE_get_keys ( -    TALER_TESTING_interpreter_get_context (is), -    exchange_url, -    NULL, /* FIXME: get form last_denom_date_ref! */ -    &keys_cb, -    cks); -} - - -/** - * Cleanup the state. - * - * @param cls closure. - * @param cmd the command which is being cleaned up. - */ -static void -check_keys_cleanup (void *cls, -                    const struct TALER_TESTING_Command *cmd) -{ -  struct CheckKeysState *cks = cls; - -  (void) cmd; -  if (NULL != cks->gkh) -  { -    TALER_EXCHANGE_get_keys_cancel (cks->gkh); -    cks->gkh = NULL; -  } -  GNUNET_free (cks); -} - - -/** - * Offer internal data to a "check_keys" CMD state to other - * commands. - * - * @param cls closure - * @param[out] ret result (could be anything) - * @param trait name of the trait - * @param index index number of the object to offer. - * @return #GNUNET_OK on success - */ -static enum GNUNET_GenericReturnValue -check_keys_traits (void *cls, -                   const void **ret, -                   const char *trait, -                   unsigned int index) -{ -  struct CheckKeysState *cks = cls; -  struct TALER_TESTING_Trait traits[] = { -    TALER_TESTING_make_trait_timestamp (0, -                                        &cks->my_denom_date), -    TALER_TESTING_trait_end () -  }; - -  return TALER_TESTING_get_trait (traits, -                                  ret, -                                  trait, -                                  index); -} - - -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys (const char *label) -{ -  return TALER_TESTING_cmd_check_keys_with_last_denom (label, -                                                       NULL); -} - - -struct TALER_TESTING_Command -TALER_TESTING_cmd_check_keys_with_last_denom ( -  const char *label, -  const char *last_denom_date_ref) -{ -  struct CheckKeysState *cks; - -  cks = GNUNET_new (struct CheckKeysState); -  cks->last_denom_date_ref = last_denom_date_ref; -  { -    struct TALER_TESTING_Command cmd = { -      .cls = cks, -      .label = label, -      .run = &check_keys_run, -      .cleanup = &check_keys_cleanup, -      .traits = &check_keys_traits -    }; - -    return cmd; -  } -} - - -/* end of testing_api_cmd_check_keys.c */ diff --git a/src/testing/testing_api_cmd_connect_with_state.c b/src/testing/testing_api_cmd_connect_with_state.c deleted file mode 100644 index caeef90b..00000000 --- a/src/testing/testing_api_cmd_connect_with_state.c +++ /dev/null @@ -1,208 +0,0 @@ -/* -  This file is part of TALER -  (C) 2018-2023 Taler Systems SA - -  TALER is free software; you can redistribute it and/or modify -  it under the terms of the GNU General Public License as -  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 testing/testing_api_cmd_connect_with_state.c - * @brief Lets tests use the keys deserialization API. - * @author Marcello Stanisci - */ -#include "platform.h" -#include <jansson.h> -#include "taler_testing_lib.h" - - -// FIXME: this is now duplicated with testing_api_cmd_check_keys! -// FIXME: this is now duplicated with testing_api_cmd_get_exchange! - -/** - * Internal state for a connect-with-state CMD. - */ -struct ConnectWithStateState -{ - -  /** -   * Reference to a CMD that offers a serialized key-state -   * that will be used in the reconnection. -   */ -  const char *state_reference; - -  /** -   * Interpreter state. -   */ -  struct TALER_TESTING_Interpreter *is; - -  /** -   * New exchange handle. -   */ -  struct TALER_EXCHANGE_GetKeysHandle *exchange; - -  /** -   * Keys handle. -   */ -  struct TALER_EXCHANGE_Keys *keys; -}; - - -static void -cert_cb (void *cls, -         const struct TALER_EXCHANGE_KeysResponse *kr, -         struct TALER_EXCHANGE_Keys *keys) -{ -  struct ConnectWithStateState *cwss = cls; -  struct TALER_TESTING_Interpreter *is = cwss->is; -  const struct TALER_EXCHANGE_HttpResponse *hr = &kr->hr; - -  cwss->exchange = NULL; -  switch (hr->http_status) -  { -  case MHD_HTTP_OK: -    /* dealt with below */ -    break; -  default: -    GNUNET_break (0); -    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, -                "Got failure response %u/%d for /keys!\n", -                hr->http_status, -                (int) hr->ec); -    TALER_TESTING_interpreter_fail (is); -    return; -  } -  cwss->keys = keys; -  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, -              "Got %d DK from /keys\n", -              kr->details.ok.keys->num_denom_keys); -  TALER_TESTING_interpreter_next (is); -} - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -connect_with_state_run (void *cls, -                        const struct TALER_TESTING_Command *cmd, -                        struct TALER_TESTING_Interpreter *is) -{ -  struct ConnectWithStateState *cwss = cls; -  const struct TALER_TESTING_Command *state_cmd; -  const json_t *serialized_keys; -  const char *exchange_url; - -  cwss->is = is; -  state_cmd = TALER_TESTING_interpreter_lookup_command (is, -                                                        cwss->state_reference); -  if (NULL == state_cmd) -  { -    /* Command providing serialized keys not found.  */ -    GNUNET_break (0); -    TALER_TESTING_interpreter_fail (is); -    return; -  } -  GNUNET_assert (GNUNET_OK == -                 TALER_TESTING_get_trait_exchange_keys (state_cmd, -                                                        &serialized_keys)); -  GNUNET_assert (GNUNET_OK == -                 TALER_TESTING_get_trait_exchange_url (state_cmd, -                                                       &exchange_url)); -  cwss->exchange -    = TALER_EXCHANGE_get_keys ( -        TALER_TESTING_interpreter_get_context (is), -        exchange_url, -        TALER_EXCHANGE_keys_from_json (serialized_keys), -        &cert_cb, -        cwss); -} - - -/** - * Offer exchange connection as trait. - * - * @param cls closure. - * @param[out] ret result. - * @param trait name of the trait. - * @param index index number of the object to offer. - * @return #GNUNET_OK on success. - */ -static enum GNUNET_GenericReturnValue -connect_with_state_traits (void *cls, -                           const void **ret, -                           const char *trait, -                           unsigned int index) -{ -  struct ConnectWithStateState *cwss = cls; -  struct TALER_TESTING_Trait traits[] = { -    TALER_TESTING_make_trait_keys (cwss->keys), -    // FIXME: also expose exchange_url as trait -    TALER_TESTING_trait_end () -  }; - -  return TALER_TESTING_get_trait (traits, -                                  ret, -                                  trait, -                                  index); -} - - -/** - * Cleanup the state of a "connect with state" CMD.  Just - * a placeholder to avoid jumping on an invalid address. - * - * @param cls closure. - * @param cmd the command which is being cleaned up. - */ -static void -connect_with_state_cleanup (void *cls, -                            const struct TALER_TESTING_Command *cmd) -{ -  struct ConnectWithStateState *cwss = cls; - -  TALER_EXCHANGE_keys_decref (cwss->keys); -  cwss->keys = NULL; -  if (NULL != cwss->exchange) -  { -    TALER_EXCHANGE_get_keys_cancel (cwss->exchange); -    cwss->exchange = NULL; -  } -  GNUNET_free (cwss); -} - - -struct TALER_TESTING_Command -TALER_TESTING_cmd_connect_with_state (const char *label, -                                      const char *state_reference) -{ -  struct ConnectWithStateState *cwss; - -  cwss = GNUNET_new (struct ConnectWithStateState); -  cwss->state_reference = state_reference; -  { -    struct TALER_TESTING_Command cmd = { -      .cls = cwss, -      .label = label, -      .run = connect_with_state_run, -      .cleanup = connect_with_state_cleanup, -      .traits = connect_with_state_traits -    }; - -    return cmd; -  } -} diff --git a/src/testing/testing_api_cmd_get_exchange.c b/src/testing/testing_api_cmd_get_exchange.c index b6634286..69a6e82b 100644 --- a/src/testing/testing_api_cmd_get_exchange.c +++ b/src/testing/testing_api_cmd_get_exchange.c @@ -64,12 +64,31 @@ struct GetExchangeState    char *master_priv_file;    /** +   * Label of a command to use to obtain existing +   * keys. +   */ +  const char *last_keys_ref; + +  /** +   * Last denomination date we received when doing this request. +   */ +  struct GNUNET_TIME_Timestamp my_denom_date; + +  /**     * Are we waiting for /keys before continuing?     */    bool wait_for_keys;  }; +/** + * Function called with information about who is auditing + * a particular exchange and what keys the exchange is using. + * + * @param cls closure + * @param kr response from /keys + * @param[in] keys the keys of the exchange + */  static void  cert_cb (void *cls,           const struct TALER_EXCHANGE_KeysResponse *kr, @@ -90,6 +109,7 @@ cert_cb (void *cls,        TALER_TESTING_interpreter_next (is);        return;      } +    ges->my_denom_date = kr->details.ok.keys->last_denom_issue_date;      return;    default:      GNUNET_break (0); @@ -120,6 +140,7 @@ get_exchange_run (void *cls,                    struct TALER_TESTING_Interpreter *is)  {    struct GetExchangeState *ges = cls; +  struct TALER_EXCHANGE_Keys *xkeys = NULL;    (void) cmd;    if (NULL == ges->exchange_url) @@ -128,6 +149,72 @@ get_exchange_run (void *cls,      TALER_TESTING_interpreter_fail (is);      return;    } +  if (NULL != ges->last_keys_ref) +  { +    const struct TALER_TESTING_Command *state_cmd; +    struct TALER_EXCHANGE_Keys *old_keys; +    const char *exchange_url; +    json_t *s_keys; + +    state_cmd +      = TALER_TESTING_interpreter_lookup_command (is, +                                                  ges->last_keys_ref); +    if (NULL == state_cmd) +    { +      /* Command providing serialized keys not found.  */ +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    if (GNUNET_OK != +        TALER_TESTING_get_trait_keys (state_cmd, +                                      &old_keys)) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    if (NULL == old_keys) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    if (GNUNET_OK != +        TALER_TESTING_get_trait_exchange_url (state_cmd, +                                              &exchange_url)) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    if (0 != strcmp (exchange_url, +                     ges->exchange_url)) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    s_keys = TALER_EXCHANGE_keys_to_json (old_keys); +    if (NULL == s_keys) +    { +      GNUNET_break (0); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    xkeys = TALER_EXCHANGE_keys_from_json (s_keys); +    if (NULL == xkeys) +    { +      GNUNET_break (0); +      json_dumpf (s_keys, +                  stderr, +                  JSON_INDENT (2)); +      json_decref (s_keys); +      TALER_TESTING_interpreter_fail (is); +      return; +    } +    json_decref (s_keys); +  }    if (NULL != ges->master_priv_file)    {      if (GNUNET_SYSERR == @@ -136,6 +223,7 @@ get_exchange_run (void *cls,                                             &ges->master_priv.eddsa_priv))      {        GNUNET_break (0); +      TALER_EXCHANGE_keys_decref (xkeys);        TALER_TESTING_interpreter_fail (is);        return;      } @@ -144,9 +232,10 @@ get_exchange_run (void *cls,    ges->exchange      = TALER_EXCHANGE_get_keys (TALER_TESTING_interpreter_get_context (is),                                 ges->exchange_url, -                               NULL, +                               xkeys,                                 &cert_cb,                                 ges); +  TALER_EXCHANGE_keys_decref (xkeys);    if (NULL == ges->exchange)    {      GNUNET_break (0); @@ -208,6 +297,8 @@ get_exchange_traits (void *cls,        TALER_TESTING_make_trait_master_pub (&ges->keys->master_pub),        TALER_TESTING_make_trait_keys (ges->keys),        TALER_TESTING_make_trait_exchange_url (ges->exchange_url), +      TALER_TESTING_make_trait_timestamp (0, +                                          &ges->my_denom_date),        TALER_TESTING_trait_end ()      }; @@ -221,6 +312,8 @@ get_exchange_traits (void *cls,      struct TALER_TESTING_Trait traits[] = {        TALER_TESTING_make_trait_master_priv (&ges->master_priv),        TALER_TESTING_make_trait_exchange_url (ges->exchange_url), +      TALER_TESTING_make_trait_timestamp (0, +                                          &ges->my_denom_date),        TALER_TESTING_trait_end ()      }; @@ -291,6 +384,7 @@ struct TALER_TESTING_Command  TALER_TESTING_cmd_get_exchange (    const char *label,    const struct GNUNET_CONFIGURATION_Handle *cfg, +  const char *last_keys_ref,    bool wait_for_keys,    bool load_private_key)  { @@ -298,6 +392,7 @@ TALER_TESTING_cmd_get_exchange (    ges = GNUNET_new (struct GetExchangeState);    ges->exchange_url = get_exchange_base_url (cfg); +  ges->last_keys_ref = last_keys_ref;    if (load_private_key)      ges->master_priv_file = get_exchange_master_priv_file (cfg);    ges->wait_for_keys = wait_for_keys; diff --git a/src/testing/testing_api_cmd_run_fakebank.c b/src/testing/testing_api_cmd_run_fakebank.c index 3664f160..7739d3c0 100644 --- a/src/testing/testing_api_cmd_run_fakebank.c +++ b/src/testing/testing_api_cmd_run_fakebank.c @@ -197,6 +197,7 @@ TALER_TESTING_cmd_run_fakebank (      GNUNET_free (exchange_xtalerbank_account);      GNUNET_free (exchange_payto_uri);    } +  GNUNET_free (exchange_payto_uri);    rfs->ba.method = TALER_BANK_AUTH_NONE;    {      struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_cmd_serialize_keys.c b/src/testing/testing_api_cmd_serialize_keys.c deleted file mode 100644 index 13464dff..00000000 --- a/src/testing/testing_api_cmd_serialize_keys.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -  This file is part of TALER -  (C) 2018-2023 Taler Systems SA - -  TALER is free software; you can redistribute it and/or modify -  it under the terms of the GNU General Public License as -  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 testing/testing_api_cmd_serialize_keys.c - * @brief Lets tests use the keys serialization API. - * @author Marcello Stanisci - */ -#include "platform.h" -#include <jansson.h> -#include "taler_testing_lib.h" - - -/** - * Internal state for a serialize-keys CMD. - */ -struct SerializeKeysState -{ -  /** -   * Serialized keys. -   */ -  json_t *keys; - -  /** -   * Exchange URL.  Needed because the exchange gets disconnected -   * from, after keys serialization.  This value is then needed by -   * subsequent commands that have to reconnect to the exchange. -   */ -  char *exchange_url; -}; - - -/** - * Run the command. - * - * @param cls closure. - * @param cmd the command to execute. - * @param is the interpreter state. - */ -static void -serialize_keys_run (void *cls, -                    const struct TALER_TESTING_Command *cmd, -                    struct TALER_TESTING_Interpreter *is) -{ -  struct SerializeKeysState *sks = cls; -  struct TALER_EXCHANGE_Keys *keys -    = TALER_TESTING_get_keys (is); - -  if (NULL == keys) -    return; -  sks->keys = TALER_EXCHANGE_keys_to_json (keys); -  if (NULL == sks->keys) -  { -    GNUNET_break (0); -    TALER_TESTING_interpreter_fail (is); -  } -  sks->exchange_url -    = GNUNET_strdup ( -        TALER_TESTING_get_exchange_url (is)); -  TALER_TESTING_interpreter_next (is); -} - - -/** - * Cleanup the state of a "serialize keys" CMD. - * - * @param cls closure. - * @param cmd the command which is being cleaned up. - */ -static void -serialize_keys_cleanup (void *cls, -                        const struct TALER_TESTING_Command *cmd) -{ -  struct SerializeKeysState *sks = cls; - -  if (NULL != sks->keys) -    json_decref (sks->keys); -  GNUNET_free (sks->exchange_url); -  GNUNET_free (sks); -} - - -/** - * Offer serialized keys as trait. - * - * @param cls closure. - * @param[out] ret result. - * @param trait name of the trait. - * @param index index number of the object to offer. - * @return #GNUNET_OK on success. - */ -static enum GNUNET_GenericReturnValue -serialize_keys_traits (void *cls, -                       const void **ret, -                       const char *trait, -                       unsigned int index) -{ -  struct SerializeKeysState *sks = cls; -  struct TALER_TESTING_Trait traits[] = { -    TALER_TESTING_make_trait_exchange_keys (sks->keys), -    TALER_TESTING_make_trait_exchange_url (sks->exchange_url), -    TALER_TESTING_trait_end () -  }; - -  return TALER_TESTING_get_trait (traits, -                                  ret, -                                  trait, -                                  index); -} - - -struct TALER_TESTING_Command -TALER_TESTING_cmd_serialize_keys (const char *label) -{ -  struct SerializeKeysState *sks; - -  sks = GNUNET_new (struct SerializeKeysState); -  { -    struct TALER_TESTING_Command cmd = { -      .cls = sks, -      .label = label, -      .run = serialize_keys_run, -      .cleanup = serialize_keys_cleanup, -      .traits = serialize_keys_traits -    }; - -    return cmd; -  } -}  | 
