summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/Makefile.am2
-rw-r--r--src/exchange/exchange.conf33
-rw-r--r--src/exchange/taler-exchange-aggregator.c73
-rw-r--r--src/exchange/taler-exchange-httpd.c34
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c6
-rw-r--r--src/exchange/test_taler_exchange_aggregator.c6
-rw-r--r--src/exchange/test_taler_exchange_httpd.conf (renamed from src/exchange/test-exchange-home/config/exchange-common.conf)43
-rwxr-xr-xsrc/exchange/test_taler_exchange_httpd.sh14
-rw-r--r--src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv (renamed from src/exchange/test-exchange-home/master.priv)0
9 files changed, 122 insertions, 89 deletions
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am
index e815d911b..dc7225b0c 100644
--- a/src/exchange/Makefile.am
+++ b/src/exchange/Makefile.am
@@ -89,4 +89,6 @@ TESTS = \
EXTRA_DIST = \
test-taler-exchange-aggregator-postgres.conf \
+ test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
+ test_taler_exchange_httpd.conf \
exchange.conf
diff --git a/src/exchange/exchange.conf b/src/exchange/exchange.conf
index 6a4f03ac1..eab476ccd 100644
--- a/src/exchange/exchange.conf
+++ b/src/exchange/exchange.conf
@@ -1,13 +1,20 @@
+# This file is in the public domain.
+#
[exchange]
# Currency supported by the exchange (can only be one)
# CURRENCY = EUR
-# Wire format supported by the exchange We use 'test' for testing of
+# Where do we store the private keys the exchange needs at
+# runtime? (Denomination and signing keys are then stored
+# in respective subdirectories.)
+KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/
+
+# Wire format supported by the exchange. We use 'test' for testing of
# the actual coin operations.
-WIREFORMAT = test
+# WIREFORMAT = test
# HTTP port the exchange listens to
-PORT = 8081
+# PORT = 8081
# Master public key used to sign the exchange's various keys
# MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
@@ -18,21 +25,5 @@ DB = postgres
# Is this is a testcase, use transient DB actions?
# TESTRUN = YES
-[exchangedb-postgres]
-DB_CONN_STR = "postgres:///taler"
-
-
-[wire-incoming-test]
-# What is the main website of the bank?
-BANK_URI = "http://localhost:8082/"
-# Into which account at the 'bank' should incoming
-# wire transfers be made?
-BANK_ACCOUNT_NUMBER = 2
-
-[wire-outgoing-test]
-# What is the main website of the bank?
-BANK_URI = "http://localhost:8082/"
-
-# From which account at the 'bank' should outgoing
-# wire transfers be made?
-BANK_ACCOUNT_NUMBER = 3
+# Where do we store the offline master private key of the exchange?
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index 25ddcf3f6..e4ba975a2 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -135,11 +135,6 @@ static char *exchange_currency_string;
static char *exchange_wireformat;
/**
- * Base directory of the exchange (global)
- */
-static char *exchange_directory;
-
-/**
* The exchange's configuration (global)
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -238,26 +233,20 @@ shutdown_task (void *cls)
}
TALER_EXCHANGEDB_plugin_unload (db_plugin);
TALER_WIRE_plugin_unload (wire_plugin);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = NULL;
}
/**
- * Load configuration parameters for the exchange
- * server into the corresponding global variables.
+ * Parse configuration parameters for the exchange server into the
+ * corresponding global variables.
*
- * @param exchange_directory the exchange's directory
* @return #GNUNET_OK on success
*/
static int
-exchange_serve_process_config (const char *exchange_directory)
+exchange_serve_process_config ()
{
- cfg = TALER_config_load (exchange_directory);
- if (NULL == cfg)
- {
- fprintf (stderr,
- "Failed to load exchange configuration\n");
- return GNUNET_SYSERR;
- }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange",
@@ -311,7 +300,6 @@ exchange_serve_process_config (const char *exchange_directory)
exchange_wireformat);
return GNUNET_SYSERR;
}
-
return GNUNET_OK;
}
@@ -958,10 +946,24 @@ run_transfers (void *cls)
* First task.
*
* @param cls closure, NULL
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param c configuration
*/
static void
-run (void *cls)
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
+ cfg = GNUNET_CONFIGURATION_dup (c);
+ if (GNUNET_OK != exchange_serve_process_config ())
+ {
+ GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = NULL;
+ global_ret = 1;
+ return;
+ }
task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
@@ -982,13 +984,9 @@ main (int argc,
char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'d', "exchange-dir", "DIR",
- "exchange directory with configuration and keys for operating the exchange", 1,
- &GNUNET_GETOPT_set_filename, &exchange_directory},
{'f', "format", "WIREFORMAT",
"wireformat to use, overrides WIREFORMAT option in [exchange] section", 1,
&GNUNET_GETOPT_set_filename, &exchange_wireformat},
- GNUNET_GETOPT_OPTION_HELP ("background process that aggregates and executes wire transfers to merchants"),
{'t', "test", NULL,
"run in test mode with temporary tables", 0,
&GNUNET_GETOPT_set_one, &test_mode},
@@ -996,30 +994,17 @@ main (int argc,
GNUNET_GETOPT_OPTION_END
};
- GNUNET_assert (GNUNET_OK ==
- GNUNET_log_setup ("taler-exchange-aggregator",
- "INFO",
- NULL));
- if (0 >=
- GNUNET_GETOPT_run ("taler-exchange-aggregator",
- options,
- argc, argv))
- return 1;
- if (NULL == exchange_directory)
- {
- fprintf (stderr,
- "Exchange directory not specified\n");
- return 1;
- }
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
+ return 2;
if (GNUNET_OK !=
- exchange_serve_process_config (exchange_directory))
- {
+ GNUNET_PROGRAM_run (argc, argv,
+ "taler-exchange-aggregator",
+ gettext_noop ("background process that aggregates and executes wire transfers to merchants"),
+ options,
+ &run, NULL))
return 1;
- }
- global_ret = GNUNET_OK;
- GNUNET_SCHEDULER_run (&run, NULL);
-
- return (GNUNET_SYSERR == global_ret) ? 1 : 0;
+ return global_ret;
}
/* end of taler-exchange-aggregator.c */
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 3061443b5..a8e9b3b08 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -360,16 +360,20 @@ handle_mhd_request (void *cls,
* @return #GNUNET_OK on success
*/
static int
-exchange_serve_process_config (const char *exchange_directory)
+exchange_serve_process_config ()
{
unsigned long long port;
char *TMH_master_public_key_str;
- cfg = TALER_config_load (exchange_directory);
- if (NULL == cfg)
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "exchange",
+ "KEYDIR",
+ &TMH_exchange_directory))
{
- fprintf (stderr,
- "Failed to load exchange configuration\n");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "KEYDIR");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@@ -615,13 +619,12 @@ int
main (int argc,
char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ char *cfgfile = NULL;
+ const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'C', "connection-close", NULL,
"force HTTP connections to be closed after each request", 0,
&GNUNET_GETOPT_set_one, &TMH_exchange_connection_close},
- {'d', "exchange-dir", "DIR",
- "exchange directory with configuration and keys for operating the exchange", 1,
- &GNUNET_GETOPT_set_filename, &TMH_exchange_directory},
+ GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile),
{'t', "timeout", "SECONDS",
"after how long do connections timeout by default (in seconds)", 1,
&GNUNET_GETOPT_set_uint, &connection_timeout},
@@ -645,15 +648,18 @@ main (int argc,
options,
argc, argv))
return 1;
- if (NULL == TMH_exchange_directory)
+ cfg = GNUNET_CONFIGURATION_create ();
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfgfile))
{
- fprintf (stderr,
- "Exchange directory not specified\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Malformed configuration file `%s', exit ...\n"),
+ cfgfile);
+ GNUNET_free_non_null (cfgfile);
return 1;
}
-
+ GNUNET_free_non_null (cfgfile);
if (GNUNET_OK !=
- exchange_serve_process_config (TMH_exchange_directory))
+ exchange_serve_process_config ())
return 1;
mydaemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index dbb72fab2..c9db50895 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -650,9 +650,9 @@ TMH_KS_acquire_ (const char *location)
TALER_EXCHANGEDB_signing_keys_iterate (TMH_exchange_directory,
&reload_keys_sign_iter,
key_state);
- TALER_EXCHANGEDB_auditor_iterate (TMH_exchange_directory,
- &reload_auditor_iter,
- key_state);
+ TALER_EXCHANGEDB_auditor_iterate (cfg,
+ &reload_auditor_iter,
+ key_state);
ks.purpose.size = htonl (sizeof (ks));
ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET);
ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time);
diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c
index 80c14ed67..594f972c1 100644
--- a/src/exchange/test_taler_exchange_aggregator.c
+++ b/src/exchange/test_taler_exchange_aggregator.c
@@ -570,8 +570,7 @@ interpreter (void *cls)
NULL, NULL, NULL,
"taler-exchange-aggregator",
"taler-exchange-aggregator",
- /* "-c", config_filename, */
- "-d", "test-exchange-home",
+ "-c", "test_taler_exchange_httpd.conf",
"-t", /* enable temporary tables */
NULL);
return;
@@ -1523,6 +1522,9 @@ main (int argc,
"test-taler-exchange-aggregator-%s", plugin_name);
(void) GNUNET_asprintf (&config_filename,
"%s.conf", testname);
+ /* these might get in the way */
+ unsetenv ("XDG_DATA_HOME");
+ unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test_taler_exchange_aggregator",
"WARNING",
NULL);
diff --git a/src/exchange/test-exchange-home/config/exchange-common.conf b/src/exchange/test_taler_exchange_httpd.conf
index 4078cbee5..0ce9dadd2 100644
--- a/src/exchange/test-exchange-home/config/exchange-common.conf
+++ b/src/exchange/test_taler_exchange_httpd.conf
@@ -1,3 +1,8 @@
+[PATHS]
+# Persistant data storage for the testcase
+TALER_TEST_HOME = test_taler_exchange_httpd_home/
+
+
[exchange]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
@@ -19,6 +24,9 @@ DB = postgres
# Is this is a testcase, use transient DB actions?
TESTRUN = YES
+
+
+
[exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck"
@@ -37,3 +45,38 @@ BANK_URI = "http://localhost:8082/"
# From which account at the 'bank' should outgoing
# wire transfers be made?
BANK_ACCOUNT_NUMBER = 3
+
+
+# Coins for the tests.
+[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
+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
+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
+rsa_keysize = 1024
diff --git a/src/exchange/test_taler_exchange_httpd.sh b/src/exchange/test_taler_exchange_httpd.sh
index 727014243..2b55ef5f4 100755
--- a/src/exchange/test_taler_exchange_httpd.sh
+++ b/src/exchange/test_taler_exchange_httpd.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
# This file is part of TALER
-# Copyright (C) 2015 GNUnet e.V.
+# Copyright (C) 2015, 2016 Inria and GNUnet e.V.
#
# TALER is free software; you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
@@ -19,15 +19,19 @@
# taler-exchange-httpd. Basically, the goal is to make sure that the
# HTTP server survives (and produces the 'correct' error code).
#
-# We read the JSON snippets to POST from test_taler_exchange_httpd.data
+#
+# Clear environment from variables that override config.
+export XDG_DATA_HOME=
+export XDG_CONFIG_HOME=
#
# Setup keys.
-taler-exchange-keyup -d test-exchange-home -m test-exchange-home/master.priv
+taler-exchange-keyup -c test_taler_exchange_httpd.conf
# Run Exchange HTTPD (in background)
-taler-exchange-httpd -d test-exchange-home &
+taler-exchange-httpd -c test_taler_exchange_httpd.conf &
# Give HTTP time to start
sleep 5
-# Run test...
+# Finally run test...
+# We read the JSON snippets to POST from test_taler_exchange_httpd.data
cat test_taler_exchange_httpd.data | grep -v ^\# | awk '{ print "curl -d \47" $2 "\47 http://localhost:8081" $1 }' | bash
# Stop HTTP server
kill -TERM %%
diff --git a/src/exchange/test-exchange-home/master.priv b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv
index 394926938..394926938 100644
--- a/src/exchange/test-exchange-home/master.priv
+++ b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv