From e0497239e90df63eaee085a45488e9ff3ee799bc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 16 Dec 2020 15:05:43 +0100 Subject: adapt tests to run without keyup tool --- src/testing/test_exchange_management_api.c | 2 +- src/testing/testing_api_cmd_exec_keyup.c | 236 ------------------------- src/testing/testing_api_cmd_revoke.c | 4 +- src/testing/testing_api_cmd_revoke_denom_key.c | 4 +- src/testing/testing_api_cmd_revoke_sign_key.c | 4 +- src/testing/testing_api_helpers_exchange.c | 224 +---------------------- 6 files changed, 12 insertions(+), 462 deletions(-) delete mode 100644 src/testing/testing_api_cmd_exec_keyup.c (limited to 'src/testing') diff --git a/src/testing/test_exchange_management_api.c b/src/testing/test_exchange_management_api.c index b53926fd2..e2d1b8227 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -170,7 +170,7 @@ main (int argc, &bc)) return 77; TALER_TESTING_cleanup_files (CONFIG_FILE); - /* @helpers. Run keyup, create tables, ... Note: it + /* @helpers. 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, diff --git a/src/testing/testing_api_cmd_exec_keyup.c b/src/testing/testing_api_cmd_exec_keyup.c deleted file mode 100644 index 7a0b36d17..000000000 --- a/src/testing/testing_api_cmd_exec_keyup.c +++ /dev/null @@ -1,236 +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 -*/ - -/** - * @file testing/testing_api_cmd_exec_keyup.c - * @brief run the taler-exchange-keyup command - * @author Marcello Stanisci - * @author Christian Grothoff - */ -#include "platform.h" -#include "taler_json_lib.h" -#include -#include "taler_signatures.h" -#include "taler_testing_lib.h" - - -/** - * State for a "keyup" CMD. - */ -struct KeyupState -{ - - /** - * Process for the "keyup" command. - */ - struct GNUNET_OS_Process *keyup_proc; - - /** - * Configuration file used by the command. - */ - const char *config_filename; - - /** - * If GNUNET_YES, then the fake @e now value will be - * passed to taler-exchange-keyup via the --time - * option. - */ - unsigned int with_now; - - /** - * User-provided fake now. - */ - struct GNUNET_TIME_Absolute now; -}; - - -/** - * Run the command; calls the `taler-exchange-keyup' program. - * - * @param cls closure. - * @param cmd the commaind being run. - * @param is interpreter state. - */ -static void -keyup_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct KeyupState *ks = cls; - - if (GNUNET_YES == ks->with_now) - { - ks->keyup_proc - = GNUNET_OS_start_process - (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", ks->config_filename, - "-o", "auditor.in", - "--time", - GNUNET_STRINGS_absolute_time_to_string (ks->now), - NULL); - } - else - ks->keyup_proc - = GNUNET_OS_start_process - (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", ks->config_filename, - "-o", "auditor.in", - NULL); - - if (NULL == ks->keyup_proc) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (is); - return; - } - - /* This function does not tell whether the command - * succeeded or not! */ - TALER_TESTING_wait_for_sigchld (is); -} - - -/** - * Free the state of a "keyup" CMD, and possibly kills its - * process if it did not terminate correctly. - * - * @param cls closure. - * @param cmd the command being freed. - */ -static void -keyup_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ - struct KeyupState *ks = cls; - - (void) cmd; - if (NULL != ks->keyup_proc) - { - GNUNET_break (0 == - GNUNET_OS_process_kill (ks->keyup_proc, - SIGKILL)); - GNUNET_OS_process_wait (ks->keyup_proc); - GNUNET_OS_process_destroy (ks->keyup_proc); - ks->keyup_proc = NULL; - } - GNUNET_free (ks); -} - - -/** - * Offer "keyup" CMD internal data to other commands. - * - * @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 int -keyup_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) -{ - struct KeyupState *ks = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_process (0, &ks->keyup_proc), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); -} - - -/** - * Make the "keyup" CMD, with "--timestamp" option. - * - * @param label command label. - * @param config_filename configuration filename. - * @param now Unix timestamp representing the fake "now". - * - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_keyup_with_now - (const char *label, - const char *config_filename, - struct GNUNET_TIME_Absolute now) -{ - struct KeyupState *ks; - - ks = GNUNET_new (struct KeyupState); - ks->config_filename = config_filename; - ks->now = now; - ks->with_now = GNUNET_YES; - { - struct TALER_TESTING_Command cmd = { - .cls = ks, - .label = label, - .run = &keyup_run, - .cleanup = &keyup_cleanup, - .traits = &keyup_traits - }; - - return cmd; - } -} - - -/** - * Make the "keyup" CMD. - * - * @param label command label. - * @param config_filename configuration filename. - * - * @return the command. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_exec_keyup (const char *label, - const char *config_filename) -{ - struct KeyupState *ks; - - ks = GNUNET_new (struct KeyupState); - ks->config_filename = config_filename; - { - struct TALER_TESTING_Command cmd = { - .cls = ks, - .label = label, - .run = &keyup_run, - .cleanup = &keyup_cleanup, - .traits = &keyup_traits - }; - - return cmd; - } -} - - -/* end of testing_api_cmd_exec_keyup.c */ diff --git a/src/testing/testing_api_cmd_revoke.c b/src/testing/testing_api_cmd_revoke.c index f17f351ec..9f904454e 100644 --- a/src/testing/testing_api_cmd_revoke.c +++ b/src/testing/testing_api_cmd_revoke.c @@ -123,9 +123,7 @@ revoke_traits (void *cls, /** - * Run the "revoke" command. The core of the function - * is to call the "keyup" utility passing it the base32 - * encoding of the denomination to revoke. + * Run the "revoke" command. * * @param cls closure. * @param cmd the command to execute. diff --git a/src/testing/testing_api_cmd_revoke_denom_key.c b/src/testing/testing_api_cmd_revoke_denom_key.c index fd7695bce..7c77c3566 100644 --- a/src/testing/testing_api_cmd_revoke_denom_key.c +++ b/src/testing/testing_api_cmd_revoke_denom_key.c @@ -143,9 +143,7 @@ revoke_traits (void *cls, /** - * Run the "revoke" command. The core of the function - * is to call the "keyup" utility passing it the base32 - * encoding of the denomination to revoke. + * Run the "revoke" command for a denomination key. * * @param cls closure. * @param cmd the command to execute. diff --git a/src/testing/testing_api_cmd_revoke_sign_key.c b/src/testing/testing_api_cmd_revoke_sign_key.c index 599fe180b..9745d728d 100644 --- a/src/testing/testing_api_cmd_revoke_sign_key.c +++ b/src/testing/testing_api_cmd_revoke_sign_key.c @@ -143,9 +143,7 @@ revoke_traits (void *cls, /** - * Run the "revoke" command. The core of the function - * is to call the "keyup" utility passing it the base32 - * encoding of the signination to revoke. + * Run the "revoke" command for a signing key. * * @param cls closure. * @param cmd the command to execute. diff --git a/src/testing/testing_api_helpers_exchange.c b/src/testing/testing_api_helpers_exchange.c index a12998e29..043bf8a0d 100644 --- a/src/testing/testing_api_helpers_exchange.c +++ b/src/testing/testing_api_helpers_exchange.c @@ -30,11 +30,6 @@ #include "taler_testing_lib.h" -/** - * Remove files from previous runs - * - * @param config_name configuration filename. - */ void TALER_TESTING_cleanup_files (const char *config_name) { @@ -46,13 +41,6 @@ TALER_TESTING_cleanup_files (const char *config_name) } -/** - * Remove files from previous runs - * - * @param cls NULL - * @param cfg configuration - * @return #GNUNET_OK on success - */ int TALER_TESTING_cleanup_files_cfg (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -97,88 +85,6 @@ TALER_TESTING_cleanup_files_cfg (void *cls, } -/** - * Run `taler-exchange-keyup`. - * - * @param config_filename configuration file to use - * @param output_filename where to write the output for the auditor - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_run_keyup (const char *config_filename, - const char *output_filename) -{ - struct GNUNET_OS_Process *proc; - - proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-keyup", - "taler-exchange-keyup", - "-c", config_filename, - "-o", output_filename, - NULL); - if (NULL == proc) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); - return GNUNET_SYSERR; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - return GNUNET_OK; -} - - -/** - * Run `taler-auditor-sign`. - * - * @param config_filename configuration file to use - * @param exchange_master_pub master public key of the exchange - * @param auditor_base_url what is the base URL of the auditor - * @param signdata_in where is the information from taler-exchange-keyup - * @param signdata_out where to write the output for the exchange - * @return #GNUNET_OK on success - */ -int -TALER_TESTING_run_auditor_sign (const char *config_filename, - const char *exchange_master_pub, - const char *auditor_base_url, - const char *signdata_in, - const char *signdata_out) -{ - struct GNUNET_OS_Process *proc; - - proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-auditor-sign", - "taler-auditor-sign", - "-c", config_filename, - "-u", auditor_base_url, - "-m", exchange_master_pub, - "-r", signdata_in, - "-o", signdata_out, - NULL); - if (NULL == proc) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-auditor-sign`, is your PATH correct?\n"); - return GNUNET_SYSERR; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - return GNUNET_OK; -} - - -/** - * Run `taler-auditor-exchange`. - * - * @param config_filename configuration file to use - * @param exchange_master_pub master public key of the exchange - * @param exchange_base_url what is the base URL of the exchange - * @param do_remove #GNUNET_NO to add exchange, #GNUNET_YES to remove - * @return #GNUNET_OK on success - */ int TALER_TESTING_run_auditor_exchange (const char *config_filename, const char *exchange_master_pub, @@ -228,12 +134,6 @@ TALER_TESTING_run_auditor_exchange (const char *config_filename, } -/** - * Run `taler-exchange-dbinit -r` (reset exchange database). - * - * @param config_filename configuration file to use - * @return #GNUNET_OK on success - */ int TALER_TESTING_exchange_db_reset (const char *config_filename) { @@ -285,12 +185,6 @@ TALER_TESTING_exchange_db_reset (const char *config_filename) } -/** - * Run `taler-auditor-dbinit -R` (reset auditor database). - * - * @param config_filename configuration file to use - * @return #GNUNET_OK on success - */ int TALER_TESTING_auditor_db_reset (const char *config_filename) { @@ -358,12 +252,6 @@ struct SignInfo */ const char *config_filename; - /** - * Must be set to input file with the data to be signed before - * calling #TALER_TESTING_sign_keys_for_exchange. - */ - const char *auditor_sign_input_filename; - /** * Did we reset the database? */ @@ -384,8 +272,6 @@ sign_keys_for_exchange (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct SignInfo *si = cls; - char *test_home_dir; - char *signed_keys_out; char *exchange_master_pub; int ret; @@ -408,7 +294,6 @@ sign_keys_for_exchange (void *cls, si->ec->exchange_url = NULL; return GNUNET_NO; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "auditor", @@ -429,24 +314,6 @@ sign_keys_for_exchange (void *cls, ret = GNUNET_NO; goto fail; } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "paths", - "TALER_TEST_HOME", - &test_home_dir)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "paths", - "TALER_TEST_HOME"); - ret = GNUNET_SYSERR; - goto fail; - } - - GNUNET_asprintf (&signed_keys_out, - "%s/.local/share/taler/auditors/auditor.out", - test_home_dir); - GNUNET_free (test_home_dir); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "exchange", @@ -456,7 +323,6 @@ sign_keys_for_exchange (void *cls, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", "MASTER_PUBLIC_KEY"); - GNUNET_free (signed_keys_out); ret = GNUNET_SYSERR; goto fail; } @@ -467,25 +333,9 @@ sign_keys_for_exchange (void *cls, GNUNET_NO)) && (GNUNET_YES == si->db_reset) ) { - GNUNET_free (signed_keys_out); - ret = GNUNET_NO; - goto fail; - } - - if ( (GNUNET_OK != - TALER_TESTING_run_auditor_sign (si->config_filename, - exchange_master_pub, - si->ec->auditor_url, - si->auditor_sign_input_filename, - signed_keys_out)) && - (GNUNET_YES == si->db_reset) ) - { - GNUNET_free (signed_keys_out); - GNUNET_free (exchange_master_pub); ret = GNUNET_NO; goto fail; } - GNUNET_free (signed_keys_out); GNUNET_free (exchange_master_pub); return GNUNET_OK; fail: @@ -499,8 +349,7 @@ fail: /** * Prepare launching an exchange. Checks that the configured - * port is available, runs taler-exchange-keyup, - * taler-auditor-sign and taler-exchange-dbinit. Does NOT + * port is available, runs taler-exchange-dbinit. Does NOT * launch the exchange process itself. * * @param config_filename configuration file to use @@ -517,14 +366,9 @@ TALER_TESTING_prepare_exchange (const char *config_filename, struct SignInfo si = { .config_filename = config_filename, .ec = ec, - .auditor_sign_input_filename = "auditor.in", .db_reset = reset_db }; - if (GNUNET_OK != - TALER_TESTING_run_keyup (config_filename, - si.auditor_sign_input_filename)) - return GNUNET_NO; if (GNUNET_YES == reset_db) { if (GNUNET_OK != @@ -683,18 +527,6 @@ TALER_TESTING_wait_auditor_ready (const char *base_url) } -/** - * Initialize scheduler loop and curl context for the testcase - * including starting and stopping the exchange using the given - * configuration file. - * - * @param main_cb routine containing all the commands to run. - * @param main_cb_cls closure for @a main_cb, typically NULL. - * @param config_file configuration file for the test-suite. - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-#GNUNET_OK codes are #GNUNET_SYSERR most of the - * time. - */ int TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, void *main_cb_cls, @@ -802,15 +634,6 @@ start_helpers (const char *config_filename, } -/** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the exchange using the given - * configuration file. - * - * @param cls must be a `struct TALER_TESTING_SetupContext *` - * @param cfg configuration to use. - * @return #GNUNET_OK if no errors occurred. - */ int TALER_TESTING_setup_with_exchange_cfg ( void *cls, @@ -921,20 +744,10 @@ TALER_TESTING_setup_with_exchange_cfg ( } -/** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the auditor and exchange using the - * given configuration file. - * - * @param cls must be a `struct TALER_TESTING_SetupContext *` - * @param cfg configuration to use. - * @return #GNUNET_OK if no errors occurred. - */ int -TALER_TESTING_setup_with_auditor_and_exchange_cfg (void *cls, - const struct - GNUNET_CONFIGURATION_Handle * - cfg) +TALER_TESTING_setup_with_auditor_and_exchange_cfg ( + void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const struct TALER_TESTING_SetupContext *setup_ctx = cls; struct GNUNET_OS_Process *auditord; @@ -1027,21 +840,6 @@ TALER_TESTING_setup_with_auditor_and_exchange_cfg (void *cls, } -/** - * Initialize scheduler loop and curl context for the test case - * including starting and stopping the auditor and exchange using the - * given configuration file. - * - * @param main_cb main method. - * @param main_cb_cls main method closure. - * @param config_file configuration file name. Is is used - * by both this function and the exchange itself. In the - * first case it gives out the exchange port number and - * the exchange base URL so as to check whether the port - * is available and the exchange responds when requested - * at its base URL. - * @return #GNUNET_OK if no errors occurred. - */ int TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, void *main_cb_cls, @@ -1053,19 +851,13 @@ TALER_TESTING_setup_with_auditor_and_exchange (TALER_TESTING_Main main_cb, .main_cb_cls = main_cb_cls }; - return GNUNET_CONFIGURATION_parse_and_run (config_file, - & - TALER_TESTING_setup_with_auditor_and_exchange_cfg, - &setup_ctx); + return GNUNET_CONFIGURATION_parse_and_run ( + config_file, + &TALER_TESTING_setup_with_auditor_and_exchange_cfg, + &setup_ctx); } -/** - * Test port in URL string for availability. - * - * @param url URL to extract port from, 80 is default - * @return #GNUNET_OK if the port is free - */ int TALER_TESTING_url_port_free (const char *url) { -- cgit v1.2.3