diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-12-01 19:47:01 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-12-01 19:47:01 +0100 |
commit | d3184e04e2a604673655899989707664736b3468 (patch) | |
tree | 7ab1235a0c99c7f120b414aece1e85a4e0058ca4 /src | |
parent | 06b8ed9ba8ed30181285b6c75089150d2662b366 (diff) | |
download | exchange-d3184e04e2a604673655899989707664736b3468.tar.xz |
add logic to launch crypto helpers as part of tests
Diffstat (limited to 'src')
-rw-r--r-- | src/testing/test_bank_api_fakebank.conf | 3 | ||||
-rw-r--r-- | src/testing/test_bank_api_fakebank_twisted.conf | 3 | ||||
-rw-r--r-- | src/testing/test_bank_api_nexus.conf | 5 | ||||
-rw-r--r-- | src/testing/test_bank_api_pybank.conf | 3 | ||||
-rw-r--r-- | src/testing/test_bank_api_pybank_twisted.conf | 3 | ||||
-rw-r--r-- | src/testing/test_exchange_management_api.c | 27 | ||||
-rw-r--r-- | src/testing/testing_api_helpers_exchange.c | 107 |
7 files changed, 143 insertions, 8 deletions
diff --git a/src/testing/test_bank_api_fakebank.conf b/src/testing/test_bank_api_fakebank.conf index 5d5053599..78f9ecbd7 100644 --- a/src/testing/test_bank_api_fakebank.conf +++ b/src/testing/test_bank_api_fakebank.conf @@ -14,3 +14,6 @@ PASSWORD = x SERVE = http HTTP_PORT = 8081 DATABASE = postgres:///talercheck + +[auditor] +BASE_URL = "http://localhost:8083/" diff --git a/src/testing/test_bank_api_fakebank_twisted.conf b/src/testing/test_bank_api_fakebank_twisted.conf index 72ab867b6..4dab123a7 100644 --- a/src/testing/test_bank_api_fakebank_twisted.conf +++ b/src/testing/test_bank_api_fakebank_twisted.conf @@ -32,3 +32,6 @@ PAYTO_URI = payto://x-taler-bank/localhost:8081/1 [exchange-account-2] PAYTO_URI = payto://x-taler-bank/localhost:8081/2 + +[auditor] +BASE_URL = "http://localhost:8083/" diff --git a/src/testing/test_bank_api_nexus.conf b/src/testing/test_bank_api_nexus.conf index a437180f8..e9a64e2a1 100644 --- a/src/testing/test_bank_api_nexus.conf +++ b/src/testing/test_bank_api_nexus.conf @@ -16,4 +16,7 @@ PASSWORD = x [bank] # not (!) used by the nexus, only by the helper # check to make sure the port is free for the nexus. -HTTP_PORT = 5001 +HTTP_PORT = 5001 + +[auditor] +BASE_URL = "http://localhost:8083/" diff --git a/src/testing/test_bank_api_pybank.conf b/src/testing/test_bank_api_pybank.conf index 9070e31e5..93169d2fd 100644 --- a/src/testing/test_bank_api_pybank.conf +++ b/src/testing/test_bank_api_pybank.conf @@ -15,3 +15,6 @@ PASSWORD = x SERVE = http HTTP_PORT = 8081 DATABASE = postgres:///talercheck + +[auditor] +BASE_URL = "http://localhost:8083/" diff --git a/src/testing/test_bank_api_pybank_twisted.conf b/src/testing/test_bank_api_pybank_twisted.conf index 9fe0fa1cb..3a7b08c98 100644 --- a/src/testing/test_bank_api_pybank_twisted.conf +++ b/src/testing/test_bank_api_pybank_twisted.conf @@ -19,6 +19,9 @@ UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES +[auditor] +BASE_URL = "http://localhost:8083/" + [taler] currency = KUDOS diff --git a/src/testing/test_exchange_management_api.c b/src/testing/test_exchange_management_api.c index 821ac1978..e44d5c8cd 100644 --- a/src/testing/test_exchange_management_api.c +++ b/src/testing/test_exchange_management_api.c @@ -47,8 +47,7 @@ static struct TALER_TESTING_BankConfiguration bc; /** - * Main function that will tell the interpreter what commands to - * run. + * Main function that will tell the interpreter what commands to run. * * @param cls closure * @param is interpreter we use to run commands @@ -58,9 +57,31 @@ run (void *cls, struct TALER_TESTING_Interpreter *is) { struct TALER_TESTING_Command commands[] = { +#if FIXME_MIGRATION_DONE + /* this currently fails, because the + auditor is already added by the test setup logic */ + TALER_TESTING_cmd_auditor_del ("del-auditor-NOT-FOUND", + MHD_HTTP_NOT_FOUND, + false), +#endif + TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG", + MHD_HTTP_FORBIDDEN, + true), TALER_TESTING_cmd_auditor_add ("add-auditor-OK", MHD_HTTP_NO_CONTENT, false), + TALER_TESTING_cmd_auditor_add ("add-auditor-OK-idempotent", + MHD_HTTP_NO_CONTENT, + false), + TALER_TESTING_cmd_auditor_del ("del-auditor-BAD-SIG", + MHD_HTTP_FORBIDDEN, + true), + TALER_TESTING_cmd_auditor_del ("del-auditor-OK", + MHD_HTTP_NO_CONTENT, + false), + TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT", + MHD_HTTP_NO_CONTENT, + false), TALER_TESTING_cmd_end () }; @@ -91,7 +112,7 @@ main (int argc, * fetches the port number from config in order to see * if it's available. */ switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, - GNUNET_YES, + GNUNET_YES, /* reset DB? */ &ec)) { case GNUNET_SYSERR: diff --git a/src/testing/testing_api_helpers_exchange.c b/src/testing/testing_api_helpers_exchange.c index 6a26ef27c..7f65bc3dd 100644 --- a/src/testing/testing_api_helpers_exchange.c +++ b/src/testing/testing_api_helpers_exchange.c @@ -718,6 +718,87 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, /** + * Stop taler-exchange-crypto helpers. + * + * @param[in] helpers the process handles. + */ +static void +stop_helpers (struct GNUNET_OS_Process *helpers[2]) +{ + for (unsigned int i = 0; i<2; i++) + { + if (NULL == helpers[i]) + continue; + GNUNET_break (0 == + GNUNET_OS_process_kill (helpers[i], + SIGTERM)); + GNUNET_break (GNUNET_OK == + GNUNET_OS_process_wait (helpers[i])); + GNUNET_OS_process_destroy (helpers[i]); + } +} + + +/** + * Start taler-exchange-crypto helpers. + * + * @param config_filename configuration file to use + * @param[out] helpers where to store the process handles. + */ +static int +start_helpers (const char *config_filename, + struct GNUNET_OS_Process *helpers[2]) +{ + char *dir; + + dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR); + if (NULL == dir) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + { + char *fn; + + GNUNET_asprintf (&fn, + "%s/%s", + dir, + "taler-helper-crypto-eddsa"); + helpers[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + fn, + "taler-helper-crypto-eddsa", + "-c", config_filename, + NULL); + GNUNET_free (fn); + } + { + char *fn; + + GNUNET_asprintf (&fn, + "%s/%s", + dir, + "taler-helper-crypto-rsa"); + helpers[1] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + fn, + "taler-helper-crypto-rsa", + "-c", config_filename, + NULL); + GNUNET_free (fn); + } + GNUNET_free (dir); + if ( (NULL == helpers[0]) || + (NULL == helpers[1]) ) + { + stop_helpers (helpers); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +/** * Initialize scheduler loop and curl context for the test case * including starting and stopping the exchange using the given * configuration file. @@ -727,12 +808,13 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main main_cb, * @return #GNUNET_OK if no errors occurred. */ int -TALER_TESTING_setup_with_exchange_cfg (void *cls, - const struct - GNUNET_CONFIGURATION_Handle *cfg) +TALER_TESTING_setup_with_exchange_cfg ( + void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const struct TALER_TESTING_SetupContext *setup_ctx = cls; struct GNUNET_OS_Process *exchanged; + struct GNUNET_OS_Process *helpers[2]; unsigned long long port; char *serve; char *base_url; @@ -777,6 +859,14 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, } } GNUNET_free (serve); + if (GNUNET_OK != + start_helpers (setup_ctx->config_filename, + helpers)) + { + GNUNET_break (0); + GNUNET_free (base_url); + return 77; + } exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, "taler-exchange-httpd", @@ -784,7 +874,13 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, "-a", /* some tests may need timetravel */ "-c", setup_ctx->config_filename, NULL); - + if (NULL == exchanged) + { + GNUNET_break (0); + GNUNET_free (base_url); + stop_helpers (helpers); + return 77; + } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "exchange", @@ -794,12 +890,14 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", "BASE_URL"); + stop_helpers (helpers); return GNUNET_NO; } if (0 != TALER_TESTING_wait_exchange_ready (base_url)) { GNUNET_free (base_url); + stop_helpers (helpers); return 77; } GNUNET_free (base_url); @@ -816,6 +914,7 @@ TALER_TESTING_setup_with_exchange_cfg (void *cls, GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (exchanged)); GNUNET_OS_process_destroy (exchanged); + stop_helpers (helpers); return result; } |