[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add logic to launch crypto helpe
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add logic to launch crypto helpers as part of tests |
Date: |
Tue, 01 Dec 2020 19:47:04 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new d3184e04 add logic to launch crypto helpers as part of tests
d3184e04 is described below
commit d3184e04e2a604673655899989707664736b3468
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Dec 1 19:47:01 2020 +0100
add logic to launch crypto helpers as part of tests
---
src/testing/test_bank_api_fakebank.conf | 3 +
src/testing/test_bank_api_fakebank_twisted.conf | 3 +
src/testing/test_bank_api_nexus.conf | 5 +-
src/testing/test_bank_api_pybank.conf | 3 +
src/testing/test_bank_api_pybank_twisted.conf | 3 +
src/testing/test_exchange_management_api.c | 27 +++++-
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 5d505359..78f9ecbd 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 72ab867b..4dab123a 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 a437180f..e9a64e2a 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 9070e31e..93169d2f 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 9fe0fa1c..3a7b08c9 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 821ac197..e44d5c8c 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 6a26ef27..7f65bc3d 100644
--- a/src/testing/testing_api_helpers_exchange.c
+++ b/src/testing/testing_api_helpers_exchange.c
@@ -717,6 +717,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
@@ -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;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add logic to launch crypto helpers as part of tests,
gnunet <=