From 77cd82c34fa8fc14583c8ebf5b197c5ed42ee01d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 1 Mar 2016 16:14:41 +0100 Subject: update ignore file --- .gitignore | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index de64370a9..14d8fdb48 100644 --- a/.gitignore +++ b/.gitignore @@ -27,16 +27,18 @@ GPATH GRTAGS GTAGS *.swp -src/lib/test_mint_api +src/lib/test_exchange_api doc/doxygen/doxygen_sqlite3.db -src/mint-lib/test_mint_api -src/mint-tools/taler-auditor-sign -src/mint-tools/taler-mint-dbinit -src/mint-tools/taler-mint-keycheck -src/mint-tools/taler-mint-keyup -src/mint-tools/taler-mint-reservemod -src/mint-tools/taler-mint-sepa -src/mintdb/perf-mintdb +src/bank-lib/test_bank_api +src/exchange-lib/test_exchange_api +src/exchange/taler-exchange-aggregator +src/exchange-tools/taler-auditor-sign +src/exchange-tools/taler-exchange-dbinit +src/exchange-tools/taler-exchange-keycheck +src/exchange-tools/taler-exchange-keyup +src/exchange-tools/taler-exchange-reservemod +src/exchange-tools/taler-exchange-sepa +src/exchangedb/perf-exchangedb src/pq/test_pq src/util/test_amount src/util/test_crypto -- cgit v1.2.3 From 199fa6a840b71d712c50c8480d5b2f7e13121e79 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 19 Mar 2016 15:56:40 +0100 Subject: update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 14d8fdb48..671e39e98 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ src/exchange-tools/taler-exchange-keyup src/exchange-tools/taler-exchange-reservemod src/exchange-tools/taler-exchange-sepa src/exchangedb/perf-exchangedb +src/json/test_json +src/wire/test_sepa_wireformat src/pq/test_pq src/util/test_amount src/util/test_crypto -- cgit v1.2.3 From b4c4f0b07822b66e2b60e43c3654a927c768ac94 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 30 Mar 2016 22:56:17 +0200 Subject: towards a testcase for aggregation logic --- .gitignore | 1 + doc/Makefile.am | 1 + doc/taler-exchange-aggregator.1 | 35 +++++ src/bank-lib/bank_api_admin.c | 2 +- src/exchange-lib/test_exchange_api.c | 18 +-- src/exchange/Makefile.am | 23 +++- src/exchange/taler-exchange-aggregator.c | 13 +- .../test-exchange-home/config/exchange-common.conf | 33 +++++ .../test-taler-exchange-aggregator-postgres.conf | 8 ++ src/exchange/test_taler_exchange_aggregator.c | 142 +++++++++++++++++++++ src/exchangedb/test_exchangedb.c | 46 +++---- src/include/taler_exchangedb_plugin.h | 52 ++++---- src/util/Makefile.am | 2 +- 13 files changed, 313 insertions(+), 63 deletions(-) create mode 100644 doc/taler-exchange-aggregator.1 create mode 100644 src/exchange/test-exchange-home/config/exchange-common.conf create mode 100644 src/exchange/test-taler-exchange-aggregator-postgres.conf create mode 100644 src/exchange/test_taler_exchange_aggregator.c (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 671e39e98..f633a66eb 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ doc/doxygen/doxygen_sqlite3.db src/bank-lib/test_bank_api src/exchange-lib/test_exchange_api src/exchange/taler-exchange-aggregator +src/exchange/test_taler_exchange_aggregator src/exchange-tools/taler-auditor-sign src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-keycheck diff --git a/doc/Makefile.am b/doc/Makefile.am index 0b3dc39c4..5a9de87a0 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -4,6 +4,7 @@ SUBDIRS = . doxygen man_MANS = \ taler-auditor-sign.1 \ + taler-exchange-aggregator.1 \ taler-exchange-dbinit.1 \ taler-exchange-httpd.1 \ taler-exchange-keyup.1 \ diff --git a/doc/taler-exchange-aggregator.1 b/doc/taler-exchange-aggregator.1 new file mode 100644 index 000000000..954f88b20 --- /dev/null +++ b/doc/taler-exchange-aggregator.1 @@ -0,0 +1,35 @@ +.TH TALER\-EXCHANGE\-AGGREGATOR 1 "Mar 30, 2016" "GNU Taler" + +.SH NAME +taler\-exchange\-aggregator \- Aggregate and execute exchange transactions + +.SH SYNOPSIS +.B taler\-exchange\-aggregator +.RI [ options ] +.br + +.SH DESCRIPTION +\fBtaler\-exchange\-aggregator\fP is a command line tool to run pending transactions from the Taler exchange. + +.SH OPTIONS +.B +.IP "\-d DIRNAME, \-\-exchange-dir=DIRNAME" +Use the configuration and other resources for the exchange to operate from DIRNAME. +.B +.IP "\-f WIREFORMAT, \-\-format=WIREFORMAT" +Overrides WIREFORMAT option from the configuation file. +.B +.IP "\-h, \-\-help" +Print short help on options. +.B +.IP "\-t, \-\-test" +Run in test mode (use temporary tables). Only useful for testcases. +.B +.IP "\-v, \-\-version" +Print version information. +.B +.SH BUGS +Report bugs by using Mantis or by sending electronic mail to + +.SH "SEE ALSO" +\fBtaler\-exchange\-dbinit\fP(1), \fBtaler\-exchange\-keyup\fP(1), \fBtaler\-exchange\-httpd\fP(1), \fBtaler.conf\fP(5) diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 36872d7a9..907e15ea7 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -175,7 +175,7 @@ TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank, admin_obj = json_pack ("{s:o, s:o," " s:I, s:I}", - "wid", GNUNET_JSON_from_data (wtid, + "wtid", GNUNET_JSON_from_data (wtid, sizeof (*wtid)), /* #4340 */ "amount", TALER_JSON_from_amount (amount), "debit_account", (json_int_t) debit_account_no, diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index 2aee8077d..2a7f670cd 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -2543,9 +2543,9 @@ run (void *cls, ctx_task = GNUNET_SCHEDULER_add_now (&context_task, ctx); exchange = TALER_EXCHANGE_connect (ctx, - "http://localhost:8081", - &cert_cb, is, - TALER_EXCHANGE_OPTION_END); + "http://localhost:8081", + &cert_cb, is, + TALER_EXCHANGE_OPTION_END); GNUNET_assert (NULL != exchange); shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -2581,12 +2581,12 @@ main (int argc, GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); exchanged = GNUNET_OS_start_process (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-httpd", - "taler-exchange-httpd", - "-d", "test-exchange-home", - NULL); + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-httpd", + "taler-exchange-httpd", + "-d", "test-exchange-home", + NULL); /* give child time to start and bind against the socket */ fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); do diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index e29a51bbb..18a7c1b54 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -59,4 +59,25 @@ check_SCRIPTS += \ test_taler_exchange_httpd_afl.sh endif -TESTS = $(check_SCRIPTS) +test_taler_exchange_aggregator_postgres_SOURCES = \ + test_taler_exchange_aggregator.c +test_taler_exchange_aggregator_postgres_LDADD = \ + $(LIBGCRYPT_LIBS) \ + $(top_builddir)/src/exchangedb/libtalerexchangedb.la \ + $(top_builddir)/src/util/libtalerutil.la \ + -lmicrohttpd \ + -lgnunetutil \ + -lgnunetjson \ + -ljansson \ + -lpthread + +check_PROGRAMS = \ + test_taler_exchange_aggregator-postgres + +TESTS = \ + $(check_SCRIPTS) \ + $(check_PROGRAMS) + + +EXTRA_DIST = \ + test-taler-exchange-aggregator-postgres.conf diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index e399a422e..4699ff4bc 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -67,6 +67,11 @@ static struct TALER_WIRE_Plugin *wire_plugin; */ static struct GNUNET_SCHEDULER_Task *task; +/** + * #GNUNET_YES if we are in test mode and are using temporary tables. + */ +static int test_mode; + /** * Limit on the number of transactions we aggregate at once. Note * that the limit must be big enough to ensure that when transactions @@ -448,7 +453,7 @@ run_aggregation (void *cls, if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; if (NULL == (session = db_plugin->get_session (db_plugin->cls, - GNUNET_NO))) + test_mode))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to obtain database session!\n"); @@ -813,7 +818,7 @@ run_transfers (void *cls, if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; if (NULL == (session = db_plugin->get_session (db_plugin->cls, - GNUNET_NO))) + test_mode))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to obtain database session!\n"); @@ -879,6 +884,10 @@ main (int argc, "wireformat to use, overrides WIREFORMAT option in [exchange] section", 1, &GNUNET_GETOPT_set_filename, &exchange_wireformat}, TALER_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}, + TALER_GETOPT_OPTION_HELP ("background process that aggregates and executes wire transfers to merchants"), GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; diff --git a/src/exchange/test-exchange-home/config/exchange-common.conf b/src/exchange/test-exchange-home/config/exchange-common.conf new file mode 100644 index 000000000..e4ff2a4d6 --- /dev/null +++ b/src/exchange/test-exchange-home/config/exchange-common.conf @@ -0,0 +1,33 @@ +[exchange] +# Currency supported by the exchange (can only be one) +CURRENCY = EUR + +# Wire format supported by the exchange +# We use 'test' for testing of the actual +# coin operations. +WIREFORMAT = test + +# HTTP port the exchange listens to +PORT = 8081 + +# Master public key used to sign the exchange's various keys +MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG + +# How to access our database +DB = postgres + +# Is this is a testcase, use transient DB actions? +TESTRUN = YES + +[exchangedb-postgres] +DB_CONN_STR = "postgres:///talercheck" + +[wire-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_NO_INCOMING = 2 +# From which account at the 'bank' should outgoing +# wire transfers be made? +BANK_ACCOUNT_NO_OUTGOING = 3 diff --git a/src/exchange/test-taler-exchange-aggregator-postgres.conf b/src/exchange/test-taler-exchange-aggregator-postgres.conf new file mode 100644 index 000000000..0822bab44 --- /dev/null +++ b/src/exchange/test-taler-exchange-aggregator-postgres.conf @@ -0,0 +1,8 @@ +[exchange] +#The DB plugin to use +DB = postgres + +[exchangedb-postgres] + +#The connection string the plugin has to use for connecting to the database +DB_CONN_STR = postgres:///talercheck diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c new file mode 100644 index 000000000..a36fcdec4 --- /dev/null +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -0,0 +1,142 @@ +/* + This file is part of TALER + (C) 2016 GNUnet e.V. + + 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, If not, see +*/ + +/** + * @file exchange/test_taler_exchange_aggregator.c + * @brief Tests for taler-exchange-aggregator logic + * @author Christian Grothoff + */ +#include "platform.h" +#include "taler_util.h" +#include "taler_exchangedb_plugin.h" + +/** + * Return value from main(). + */ +static int result; + +/** + * Name of the configuration file to use. + */ +static char *config_filename; + + +/** + * Runs the aggregator process. + */ +static void +run_aggregator () +{ + struct GNUNET_OS_Process *proc; + + proc = GNUNET_OS_start_process (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-aggregator", + "taler-exchange-aggregator", + /* "-c", config_filename, */ + "-d", "test-exchange-home", + "-t", /* enable temporary tables */ + NULL); + GNUNET_OS_process_wait (proc); + GNUNET_OS_process_destroy (proc); +} + + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be NULL!) + * @param cfg configuration + */ +static void +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + struct TALER_EXCHANGEDB_Plugin *plugin; + struct TALER_EXCHANGEDB_Session *session; + + plugin = TALER_EXCHANGEDB_plugin_load (cfg); + if (GNUNET_OK != + plugin->create_tables (plugin->cls, + GNUNET_YES)) + { + TALER_EXCHANGEDB_plugin_unload (plugin); + result = 77; + return; + } + session = plugin->get_session (plugin->cls, + GNUNET_YES); + /* FIXME: prime DB */ + /* FIXME: launch bank on 8082! */ + run_aggregator (); + /* FIXME: check DB and bank */ + + plugin->drop_temporary (plugin->cls, + session); + TALER_EXCHANGEDB_plugin_unload (plugin); + result = 77; /* skip: not finished */ +} + + +int +main (int argc, + char *const argv[]) +{ + static const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_END + }; + char *argv2[] = { + "test-taler-exchange-aggregator-", /* will be replaced later */ + "-c", "test-taler-exchange-aggregator-.conf", /* will be replaced later */ + NULL, + }; + const char *plugin_name; + char *testname; + + result = -1; + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) + { + GNUNET_break (0); + return -1; + } + plugin_name++; + (void) GNUNET_asprintf (&testname, + "test-taler-exchange-aggregator-%s", plugin_name); + (void) GNUNET_asprintf (&config_filename, + "%s.conf", testname); + argv2[0] = argv[0]; + argv2[2] = config_filename; + if (GNUNET_OK != + GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, + testname, + "Test cases for exchange aggregator.", + options, &run, NULL)) + { + GNUNET_free (config_filename); + GNUNET_free (testname); + return 3; + } + GNUNET_free (config_filename); + GNUNET_free (testname); + return result; +} + +/* end of test_taler_exchange_aggregator.c */ diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 2ab91c72e..090c08fbd 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -867,31 +867,31 @@ int main (int argc, char *const argv[]) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + static const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - char *argv2[] = { - "test-exchange-db-", /* will be replaced later */ - "-c", "test-exchange-db-.conf", /* will be replaced later */ - NULL, - }; - const char *plugin_name; - char *config_filename; - char *testname; - - result = -1; - if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) - { - GNUNET_break (0); - return -1; - } - plugin_name++; - (void) GNUNET_asprintf (&testname, - "test-exchange-db-%s", plugin_name); - (void) GNUNET_asprintf (&config_filename, - "%s.conf", testname); - argv2[0] = argv[0]; - argv2[2] = config_filename; + char *argv2[] = { + "test-exchange-db-", /* will be replaced later */ + "-c", "test-exchange-db-.conf", /* will be replaced later */ + NULL, + }; + const char *plugin_name; + char *config_filename; + char *testname; + + result = -1; + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) + { + GNUNET_break (0); + return -1; + } + plugin_name++; + (void) GNUNET_asprintf (&testname, + "test-exchange-db-%s", plugin_name); + (void) GNUNET_asprintf (&config_filename, + "%s.conf", testname); + argv2[0] = argv[0]; + argv2[2] = config_filename; if (GNUNET_OK != GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, testname, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index f45014463..cb1dcb344 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -546,15 +546,15 @@ struct TALER_EXCHANGEDB_Session; */ typedef int (*TALER_EXCHANGEDB_DepositIterator)(void *cls, - unsigned long long rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *deposit_fee, - uint64_t transaction_id, - const struct GNUNET_HashCode *h_contract, - struct GNUNET_TIME_Absolute wire_deadline, - const json_t *wire); + unsigned long long rowid, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *deposit_fee, + uint64_t transaction_id, + const struct GNUNET_HashCode *h_contract, + struct GNUNET_TIME_Absolute wire_deadline, + const json_t *wire); /** @@ -568,9 +568,9 @@ typedef int */ typedef void (*TALER_EXCHANGEDB_TransferDataCallback)(void *cls, - const struct GNUNET_HashCode *session_hash, - const struct TALER_TransferPublicKeyP *transfer_pub, - const struct TALER_EncryptedLinkSecretP *shared_secret_enc); + const struct GNUNET_HashCode *session_hash, + const struct TALER_TransferPublicKeyP *transfer_pub, + const struct TALER_EncryptedLinkSecretP *shared_secret_enc); /** @@ -589,10 +589,10 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_DepositWtidCallback)(void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_Amount *coin_contribution, - const struct TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute execution_time); + const struct TALER_WireTransferIdentifierRawP *wtid, + const struct TALER_Amount *coin_contribution, + const struct TALER_Amount *coin_fee, + struct GNUNET_TIME_Absolute execution_time); /** @@ -610,13 +610,13 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_WireTransferDataCallback)(void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract, - uint64_t transaction_id, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *coin_value, - const struct TALER_Amount *coin_fee); + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract, + uint64_t transaction_id, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *coin_value, + const struct TALER_Amount *coin_fee); /** @@ -629,9 +629,9 @@ typedef void */ typedef void (*TALER_EXCHANGEDB_WirePreparationCallback) (void *cls, - unsigned long long rowid, - const char *buf, - size_t buf_size); + unsigned long long rowid, + const char *buf, + size_t buf_size); /** diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 41afcc97f..e4352852c 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -47,7 +47,7 @@ TESTS = \ test_amount \ test_crypto -check_PROGRAMS= \ +check_PROGRAMS = \ test_amount \ test_crypto -- cgit v1.2.3 From a2a7a3272da4e0783bb7562d5f66baffc51d96dc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 1 Apr 2016 20:43:03 +0200 Subject: fix ignores --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index f633a66eb..81be5b2f5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ doc/doxygen/doxygen_sqlite3.db src/bank-lib/test_bank_api src/exchange-lib/test_exchange_api src/exchange/taler-exchange-aggregator -src/exchange/test_taler_exchange_aggregator +src/exchange/test_taler_exchange_aggregator-postgres src/exchange-tools/taler-auditor-sign src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-keycheck -- cgit v1.2.3 From aee021aa3701213471dff9f378c58a0a0599f9b6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 6 Apr 2016 11:27:51 +0200 Subject: update ignore file, fix compiler warning --- .gitignore | 2 +- src/json/json.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 81be5b2f5..ce73b4d26 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,7 @@ src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-keycheck src/exchange-tools/taler-exchange-keyup src/exchange-tools/taler-exchange-reservemod -src/exchange-tools/taler-exchange-sepa +src/exchange-tools/taler-exchange-wire src/exchangedb/perf-exchangedb src/json/test_json src/wire/test_sepa_wireformat diff --git a/src/json/json.c b/src/json/json.c index 1fbc59a73..da9e8b9f8 100644 --- a/src/json/json.c +++ b/src/json/json.c @@ -32,7 +32,7 @@ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ int -TALER_JSON_hash (json_t *json, +TALER_JSON_hash (const json_t *json, struct GNUNET_HashCode *hc) { char *wire_enc; -- cgit v1.2.3 From 30d66bcebc27a1cdcbad39ddbeeaf047da6cc1dd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 10 Apr 2016 17:10:20 +0200 Subject: fixing #4386: use more sane configuration and data file structure --- .gitignore | 2 + doc/taler.conf.5 | 6 +- src/exchange-lib/Makefile.am | 5 +- .../test-exchange-home/config/exchange-common.conf | 41 --------- .../test-exchange-home/config/exchange-keyup.conf | 86 ------------------- src/exchange-lib/test-exchange-home/master.priv | 1 - src/exchange-lib/test-exchange-home/sepa.json | 9 -- src/exchange-lib/test_exchange_api.c | 8 +- src/exchange-lib/test_exchange_api.conf | 96 ++++++++++++++++++++++ .../test_exchange_api_home/.config/taler/sepa.json | 9 ++ .../share/taler/exchange/offline-keys/master.priv | 1 + src/exchange-tools/Makefile.am | 12 +++ src/exchange-tools/auditor.conf | 12 +++ src/exchange-tools/coins.conf | 25 ++++++ src/exchange-tools/exchange-signkeys.conf | 16 ++++ src/exchange-tools/taler-auditor-sign.c | 47 +++++++++-- src/exchange-tools/taler-exchange-dbinit.c | 46 ++++------- src/exchange-tools/taler-exchange-keycheck.c | 42 ++++++---- src/exchange-tools/taler-exchange-keyup.c | 42 ++++++---- src/exchange-tools/taler-exchange-reservemod.c | 42 ++++++---- src/exchange-tools/taler-exchange-wire.c | 29 ++++++- src/exchange/Makefile.am | 2 + src/exchange/exchange.conf | 33 +++----- src/exchange/taler-exchange-aggregator.c | 73 +++++++--------- src/exchange/taler-exchange-httpd.c | 34 ++++---- src/exchange/taler-exchange-httpd_keystate.c | 6 +- .../test-exchange-home/config/exchange-common.conf | 39 --------- src/exchange/test-exchange-home/master.priv | 1 - src/exchange/test_taler_exchange_aggregator.c | 6 +- src/exchange/test_taler_exchange_httpd.conf | 82 ++++++++++++++++++ src/exchange/test_taler_exchange_httpd.sh | 14 ++-- .../share/taler/exchange/offline-keys/master.priv | 1 + src/exchangedb/Makefile.am | 11 +++ src/exchangedb/exchangedb-postgres.conf | 2 + src/exchangedb/exchangedb.conf | 7 ++ src/exchangedb/exchangedb_keyio.c | 21 ++--- src/include/taler_exchangedb_lib.h | 12 +-- src/include/taler_util.h | 11 --- src/util/Makefile.am | 9 ++ src/util/paths.conf | 29 +++++++ src/util/util.c | 27 ------ src/wire/Makefile.am | 11 +++ src/wire/wire-sepa.conf | 7 ++ src/wire/wire-test.conf | 14 ++++ 44 files changed, 606 insertions(+), 423 deletions(-) delete mode 100644 src/exchange-lib/test-exchange-home/config/exchange-common.conf delete mode 100644 src/exchange-lib/test-exchange-home/config/exchange-keyup.conf delete mode 100644 src/exchange-lib/test-exchange-home/master.priv delete mode 100644 src/exchange-lib/test-exchange-home/sepa.json create mode 100644 src/exchange-lib/test_exchange_api.conf create mode 100644 src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json create mode 100644 src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv create mode 100644 src/exchange-tools/auditor.conf create mode 100644 src/exchange-tools/coins.conf create mode 100644 src/exchange-tools/exchange-signkeys.conf delete mode 100644 src/exchange/test-exchange-home/config/exchange-common.conf delete mode 100644 src/exchange/test-exchange-home/master.priv create mode 100644 src/exchange/test_taler_exchange_httpd.conf create mode 100644 src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv create mode 100644 src/exchangedb/exchangedb-postgres.conf create mode 100644 src/exchangedb/exchangedb.conf create mode 100644 src/util/paths.conf create mode 100644 src/wire/wire-sepa.conf create mode 100644 src/wire/wire-test.conf (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index ce73b4d26..fc31e919e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,10 @@ src/lib/test_exchange_api doc/doxygen/doxygen_sqlite3.db src/bank-lib/test_bank_api src/exchange-lib/test_exchange_api +src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/live-keys/ src/exchange/taler-exchange-aggregator src/exchange/test_taler_exchange_aggregator-postgres +src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/live-keys/ src/exchange-tools/taler-auditor-sign src/exchange-tools/taler-exchange-dbinit src/exchange-tools/taler-exchange-keycheck diff --git a/doc/taler.conf.5 b/doc/taler.conf.5 index e4c7083d6..1d03927ea 100644 --- a/doc/taler.conf.5 +++ b/doc/taler.conf.5 @@ -1,14 +1,14 @@ -.TH TALER.CONF 5 "Aug 11, 2015" "GNU Taler" +.TH TALER.CONF 5 "Apr 11, 2016" "GNU Taler" .SH NAME taler.conf \- Taler configuration file. .SH SYNOPSIS -.B DIRNAME/taler.conf +.B taler.conf .SH DESCRIPTION -The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments. +The basic structure of the configuration file is the following. The file is split into sections. Every section begins with "[SECTIONNAME]" and contains a number of options of the form "OPTION=VALUE". Empty lines and lines beginning with a "#" are treated as comments. Files containing default values for many of the options described below are installed under \$TALER\_PREFIX/share/taler/config.d/. The configuration file given with \-c to Taler binaries overrides these defaults. .SH EXCHANGE OPTIONS diff --git a/src/exchange-lib/Makefile.am b/src/exchange-lib/Makefile.am index 49cb234a1..58a903342 100644 --- a/src/exchange-lib/Makefile.am +++ b/src/exchange-lib/Makefile.am @@ -61,5 +61,6 @@ test_exchange_api_LDADD = \ -ljansson EXTRA_DIST = \ - test-exchange-home/config/exchange-common.conf \ - test-exchange-home/master.priv + test_taler_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \ + test_taler_exchange_api_home/.config/taler/sepa.json \ + test_taler_exchange_api.conf diff --git a/src/exchange-lib/test-exchange-home/config/exchange-common.conf b/src/exchange-lib/test-exchange-home/config/exchange-common.conf deleted file mode 100644 index 97947f111..000000000 --- a/src/exchange-lib/test-exchange-home/config/exchange-common.conf +++ /dev/null @@ -1,41 +0,0 @@ -[exchange] -# Currency supported by the exchange (can only be one) -CURRENCY = EUR - -# Wire format supported by the exchange -# We use 'test' for testing of the actual -# coin operations, and 'sepa' to test SEPA-specific routines. -WIREFORMAT = test sepa - -# HTTP port the exchange listens to -PORT = 8081 - -# Master public key used to sign the exchange's various keys -MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# How to access our database -DB = postgres - -# Is this is a testcase, use transient DB actions? -TESTRUN = YES - -[exchangedb-postgres] -DB_CONN_STR = "postgres:///talercheck" - -[wire-incoming-sepa] -SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" - -[wire-incoming-sepa] -SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" - -[wire-incoming-test] -# What is the main website of the bank? -BANK_URI = "http://localhost/" -# 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/" -# Into which account at the 'bank' should (incoming) wire transfers be made? -BANK_ACCOUNT_NUMBER = 2 diff --git a/src/exchange-lib/test-exchange-home/config/exchange-keyup.conf b/src/exchange-lib/test-exchange-home/config/exchange-keyup.conf deleted file mode 100644 index 4a80da7e9..000000000 --- a/src/exchange-lib/test-exchange-home/config/exchange-keyup.conf +++ /dev/null @@ -1,86 +0,0 @@ -[exchange_keys] - -# how long is one signkey valid? -signkey_duration = 4 weeks - -# how long are the signatures with the signkey valid? -legal_duration = 2 years - -# how long do we generate denomination and signing keys -# ahead of time? -lookahead_sign = 32 weeks 1 day - -# how long do we provide to clients denomination and signing keys -# ahead of time? -lookahead_provide = 4 weeks 1 day - - -# Coin definitions are detected because the section -# name begins with "coin_". The rest of the -# name is free, but of course following the convention -# of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. -[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 - -[coin_eur_5] -value = EUR:5 -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_10] -value = EUR: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_1000] -value = EUR:1000 -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 = 2048 diff --git a/src/exchange-lib/test-exchange-home/master.priv b/src/exchange-lib/test-exchange-home/master.priv deleted file mode 100644 index 394926938..000000000 --- a/src/exchange-lib/test-exchange-home/master.priv +++ /dev/null @@ -1 +0,0 @@ -p^-33XX!\0qmU_ \ No newline at end of file diff --git a/src/exchange-lib/test-exchange-home/sepa.json b/src/exchange-lib/test-exchange-home/sepa.json deleted file mode 100644 index b435ce86b..000000000 --- a/src/exchange-lib/test-exchange-home/sepa.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Max Musterman", - "bic": "COBADEFF370", - "type": "sepa", - "sig": "4EVRC2MCJPXQC8MC00831DNWEXMZAP4JQDDE1A7R6KR3MANG24RC1VQ55AX5A2E35S58VW1VSTENFTPHG5MWG9BSN8B8WXSV21KKW20", - "address": "Musterstadt", - "salt": "3KTM1ZRMWGEQPQ254S4R5R4Q8XM0ZYWTCTE01TZ76MVBSQ6RX7A5DR08WXVH1DCHR1R7ACRB7X0EVC2XDW1CBZM9WFSD9TRMZ90BR98", - "iban": "DE89370400440532013000" -} \ No newline at end of file diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index c7eb9e314..68f4852be 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -2539,13 +2539,15 @@ main (int argc, GNUNET_log_setup ("test-exchange-api", "WARNING", NULL); + /* These might get in the way... */ + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, "taler-exchange-keyup", "taler-exchange-keyup", - "-d", "test-exchange-home", - "-m", "test-exchange-home/master.priv", + "-c", "test_exchange_api.conf", NULL); GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); @@ -2554,7 +2556,7 @@ main (int argc, NULL, NULL, NULL, "taler-exchange-httpd", "taler-exchange-httpd", - "-d", "test-exchange-home", + "-c", "test_exchange_api.conf", NULL); /* give child time to start and bind against the socket */ fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); diff --git a/src/exchange-lib/test_exchange_api.conf b/src/exchange-lib/test_exchange_api.conf new file mode 100644 index 000000000..e1e916bd2 --- /dev/null +++ b/src/exchange-lib/test_exchange_api.conf @@ -0,0 +1,96 @@ +# This file is in the public domain. +# +[PATHS] +# Persistant data storage for the testcase +TALER_TEST_HOME = test_exchange_api_home/ + +[exchange] +# Currency supported by the exchange (can only be one) +CURRENCY = EUR + +# Wire format supported by the exchange +# We use 'test' for testing of the actual +# coin operations, and 'sepa' to test SEPA-specific routines. +WIREFORMAT = test sepa + +# HTTP port the exchange listens to +PORT = 8081 + +# Master public key used to sign the exchange's various keys +MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG + +# How to access our database +DB = postgres + +# Is this is a testcase, use transient DB actions? +TESTRUN = YES + +[exchangedb-postgres] +DB_CONN_STR = "postgres:///talercheck" + +[wire-incoming-test] +# What is the main website of the bank? +BANK_URI = "http://localhost/" +# 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/" +# Into which account at the 'bank' should (incoming) wire transfers be made? +BANK_ACCOUNT_NUMBER = 2 + +[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 + +[coin_eur_5] +value = EUR:5 +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_10] +value = EUR: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 diff --git a/src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json b/src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json new file mode 100644 index 000000000..b435ce86b --- /dev/null +++ b/src/exchange-lib/test_exchange_api_home/.config/taler/sepa.json @@ -0,0 +1,9 @@ +{ + "name": "Max Musterman", + "bic": "COBADEFF370", + "type": "sepa", + "sig": "4EVRC2MCJPXQC8MC00831DNWEXMZAP4JQDDE1A7R6KR3MANG24RC1VQ55AX5A2E35S58VW1VSTENFTPHG5MWG9BSN8B8WXSV21KKW20", + "address": "Musterstadt", + "salt": "3KTM1ZRMWGEQPQ254S4R5R4Q8XM0ZYWTCTE01TZ76MVBSQ6RX7A5DR08WXVH1DCHR1R7ACRB7X0EVC2XDW1CBZM9WFSD9TRMZ90BR98", + "iban": "DE89370400440532013000" +} \ No newline at end of file diff --git a/src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv b/src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv new file mode 100644 index 000000000..394926938 --- /dev/null +++ b/src/exchange-lib/test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv @@ -0,0 +1 @@ +p^-33XX!\0qmU_ \ No newline at end of file diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am index feb3c314f..d283979c8 100644 --- a/src/exchange-tools/Makefile.am +++ b/src/exchange-tools/Makefile.am @@ -1,6 +1,14 @@ # This Makefile.am is in the public domain AM_CPPFLAGS = -I$(top_srcdir)/src/include +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + auditor.conf \ + exchange-signkeys.conf \ + coins.conf + + if USE_COVERAGE AM_CFLAGS = --coverage -O0 XLIB = -lgcov @@ -81,3 +89,7 @@ taler_exchange_dbinit_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/pq/ \ $(POSTGRESQL_CPPFLAGS) + + +EXTRA_DIST = \ + auditor.conf diff --git a/src/exchange-tools/auditor.conf b/src/exchange-tools/auditor.conf new file mode 100644 index 000000000..7eb5f8ae9 --- /dev/null +++ b/src/exchange-tools/auditor.conf @@ -0,0 +1,12 @@ +# This configuration file is in the public domain +# +# It cointains options for the auditor. + +[auditor] + +# Where do we store the auditor's private key? +AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv + +# What is the Web site of the auditor (i.e. to file complaints about +# a misbehaving exchange)? +# AUDITOR_URL = https://auditor.taler.net/ diff --git a/src/exchange-tools/coins.conf b/src/exchange-tools/coins.conf new file mode 100644 index 000000000..90bf7064c --- /dev/null +++ b/src/exchange-tools/coins.conf @@ -0,0 +1,25 @@ +# This configuration file is in the public domain +# +# This is a template file for coin definitions. There are no +# reasonable defaults, as legal and business concerns influence each +# value given. +# +# Note that while we only give one section here, you can define +# any number of coins by providing many "coin_" sections. +# +# Coin definitions are detected because the section name begins with +# "coin_". The rest of the name is free, but of course following the +# convention of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. +# +# [coin_eur_ct_1] + +# All options are mandatory! +# value = EUR:0.01 +# duration_overlap = 60 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 diff --git a/src/exchange-tools/exchange-signkeys.conf b/src/exchange-tools/exchange-signkeys.conf new file mode 100644 index 000000000..3146f09b2 --- /dev/null +++ b/src/exchange-tools/exchange-signkeys.conf @@ -0,0 +1,16 @@ +# General data for signing keys. +[exchange_keys] + +# how long is one signkey valid? +signkey_duration = 4 weeks + +# how long are the signatures with the signkey valid? +legal_duration = 2 years + +# how long do we generate denomination and signing keys +# ahead of time? +lookahead_sign = 32 weeks 1 day + +# how long do we provide to clients denomination and signing keys +# ahead of time? +lookahead_provide = 4 weeks 1 day diff --git a/src/exchange-tools/taler-auditor-sign.c b/src/exchange-tools/taler-auditor-sign.c index 870f889ea..d5a3a9403 100644 --- a/src/exchange-tools/taler-auditor-sign.c +++ b/src/exchange-tools/taler-auditor-sign.c @@ -59,6 +59,11 @@ static char *auditor_url; */ static struct TALER_MasterPublicKeyP master_public_key; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; + /** * Print denomination key details for diagnostics. @@ -131,10 +136,12 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'a', "auditor-key", "FILE", + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + {'a', "auditor-key", "FILENAME", "file containing the private key of the auditor", 1, &GNUNET_GETOPT_set_filename, &auditor_key_file}, + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Private key of the auditor to use for signing"), {'m', "exchange-key", "KEY", "public key of the exchange (Crockford base32 encoded)", 1, @@ -142,10 +149,10 @@ main (int argc, {'u', "auditor-url", "URL", "URL of the auditor (informative link for the user)", 1, &GNUNET_GETOPT_set_string, &auditor_url}, - {'r', "exchange-request", "FILE", + {'r', "exchange-request", "FILENAME", "set of keys the exchange requested the auditor to sign", 1, &GNUNET_GETOPT_set_string, &exchange_request_file}, - {'o', "output", "FILE", + {'o', "output", "FILENAME", "where to write our signature", 1, &GNUNET_GETOPT_set_string, &output_file}, GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), @@ -163,20 +170,41 @@ main (int argc, unsigned int i; GNUNET_assert (GNUNET_OK == - GNUNET_log_setup ("taler-exchange-keyup", + GNUNET_log_setup ("taler-auditor-sign", "WARNING", NULL)); - if (GNUNET_GETOPT_run ("taler-exchange-keyup", + if (GNUNET_GETOPT_run ("taler-auditor-sign", options, argc, argv) < 0) return 1; - if (NULL == auditor_key_file) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) + { + 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 ( (NULL == auditor_key_file) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "auditor", + "AUDITOR_PRIV_FILE", + &auditor_key_file)) ) { fprintf (stderr, - "Auditor key file not given\n"); + "Auditor key file not given in neither configuration nor command-line\n"); return 1; } - if (NULL == auditor_url) + if ( (NULL == auditor_url) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "auditor", + "AUDITOR_URL", + &auditor_url)) ) { fprintf (stderr, "Auditor URL not given\n"); @@ -328,6 +356,7 @@ main (int argc, GNUNET_free (dks); return 1; } + GNUNET_free (sigs); GNUNET_free (dks); GNUNET_free (eddsa_priv); diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 43a070228..9f301854f 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -20,24 +20,8 @@ */ #include "platform.h" #include -#include #include "taler_exchangedb_plugin.h" -/** - * Exchange directory with the keys. - */ -static char *exchange_base_dir; - -/** - * Our configuration. - */ -static struct GNUNET_CONFIGURATION_Handle *cfg; - -/** - * Our DB plugin. - */ -static struct TALER_EXCHANGEDB_Plugin *plugin; - /** * The main function of the database initialization tool. @@ -51,14 +35,15 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'d', "exchange-dir", "DIR", - "exchange directory", 1, - &GNUNET_GETOPT_set_filename, &exchange_base_dir}, + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Initialize Taler Exchange database"), GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; + struct GNUNET_CONFIGURATION_Handle *cfg; + struct TALER_EXCHANGEDB_Plugin *plugin; if (GNUNET_GETOPT_run ("taler-exchange-dbinit", options, @@ -69,24 +54,23 @@ main (int argc, GNUNET_log_setup ("taler-exchange-dbinit", "INFO", NULL)); - if (NULL == exchange_base_dir) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) { - fprintf (stderr, - "Exchange base directory not given.\n"); - return 1; - } - cfg = TALER_config_load (exchange_base_dir); - if (NULL == cfg) - { - fprintf (stderr, - "Failed to load exchange configuration.\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 (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) { fprintf (stderr, "Failed to initialize database plugin.\n"); + GNUNET_CONFIGURATION_destroy (cfg); return 1; } if (GNUNET_OK != @@ -96,9 +80,11 @@ main (int argc, fprintf (stderr, "Failed to initialize database.\n"); TALER_EXCHANGEDB_plugin_unload (plugin); + GNUNET_CONFIGURATION_destroy (cfg); return 1; } TALER_EXCHANGEDB_plugin_unload (plugin); + GNUNET_CONFIGURATION_destroy (cfg); return 0; } diff --git a/src/exchange-tools/taler-exchange-keycheck.c b/src/exchange-tools/taler-exchange-keycheck.c index d6566cd03..064f2249e 100644 --- a/src/exchange-tools/taler-exchange-keycheck.c +++ b/src/exchange-tools/taler-exchange-keycheck.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. 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 @@ -104,8 +104,8 @@ static int exchange_signkeys_check () { if (0 > TALER_EXCHANGEDB_signing_keys_iterate (exchange_directory, - &signkeys_iter, - NULL)) + &signkeys_iter, + NULL)) return GNUNET_NO; return GNUNET_OK; } @@ -186,8 +186,8 @@ static int exchange_denomkeys_check () { if (0 > TALER_EXCHANGEDB_denomination_keys_iterate (exchange_directory, - &denomkeys_iter, - NULL)) + &denomkeys_iter, + NULL)) return GNUNET_NO; return GNUNET_OK; } @@ -203,11 +203,10 @@ exchange_denomkeys_check () int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + char *cfgfile; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("gnunet-exchange-keycheck OPTIONS"), - {'d', "directory", "DIRECTORY", - "exchange directory with keys to check", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, GNUNET_GETOPT_OPTION_END }; @@ -220,20 +219,29 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + kcfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); return 1; } - - kcfg = TALER_config_load (exchange_directory); - if (NULL == kcfg) + GNUNET_free_non_null (cfgfile); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "KEYDIR", + &exchange_directory)) { - fprintf (stderr, - "Failed to load exchange configuration\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); return 1; } + if ( (GNUNET_OK != exchange_signkeys_check ()) || (GNUNET_OK != exchange_denomkeys_check ()) ) { diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 3413dfb42..ab2123a15 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. 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 @@ -876,10 +876,9 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { - {'d', "exchange-dir", "DIR", - "exchange directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), GNUNET_GETOPT_OPTION_HELP ("Setup signing and denomination keys for a Taler exchange"), {'m', "master-key", "FILE", "master key file (private key)", 1, @@ -905,12 +904,17 @@ main (int argc, options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + kcfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (kcfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\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 (NULL != pretend_time_str) { if (GNUNET_OK != @@ -928,18 +932,26 @@ main (int argc, now = GNUNET_TIME_absolute_get (); } GNUNET_TIME_round_abs (&now); - - kcfg = TALER_config_load (exchange_directory); - if (NULL == kcfg) + if ( (NULL == masterkeyfile) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "MASTER_PRIV_FILE", + &masterkeyfile)) ) { fprintf (stderr, - "Failed to load exchange configuration\n"); + "Master key file not given in neither configuration nor command-line\n"); return 1; } - if (NULL == masterkeyfile) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (kcfg, + "exchange", + "KEYDIR", + &exchange_directory)) { - fprintf (stderr, - "Master key file not given\n"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); return 1; } eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); diff --git a/src/exchange-tools/taler-exchange-reservemod.c b/src/exchange-tools/taler-exchange-reservemod.c index 03a0d17d5..3494e88a0 100644 --- a/src/exchange-tools/taler-exchange-reservemod.c +++ b/src/exchange-tools/taler-exchange-reservemod.c @@ -51,6 +51,7 @@ static struct TALER_EXCHANGEDB_Plugin *plugin; int main (int argc, char *const *argv) { + char *cfgfile = NULL; char *reserve_pub_str = NULL; char *add_str = NULL; struct TALER_Amount add_value; @@ -63,10 +64,8 @@ main (int argc, char *const *argv) {'a', "add", "DENOM", "value to add", 1, &GNUNET_GETOPT_set_string, &add_str}, - {'d', "exchange-dir", "DIR", - "exchange directory with keys to update", 1, - &GNUNET_GETOPT_set_filename, &exchange_directory}, - {'D', "details", "JSON", + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), + {'d', "details", "JSON", "details about the bank transaction which justify why we add this amount", 1, &GNUNET_GETOPT_set_string, &details}, GNUNET_GETOPT_OPTION_HELP ("Deposit funds into a Taler reserve"), @@ -87,10 +86,29 @@ main (int argc, char *const *argv) options, argc, argv) < 0) return 1; - if (NULL == exchange_directory) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) { - fprintf (stderr, - "Exchange directory not given\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Malformed configuration file `%s', exit ...\n"), + cfgfile); + GNUNET_free_non_null (cfgfile); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); + return 1; + } + GNUNET_free_non_null (cfgfile); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchange", + "KEYDIR", + &exchange_directory)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KEYDIR"); GNUNET_free_non_null (add_str); GNUNET_free_non_null (details); GNUNET_free_non_null (reserve_pub_str); @@ -133,16 +151,6 @@ main (int argc, char *const *argv) return 1; } - cfg = TALER_config_load (exchange_directory); - if (NULL == cfg) - { - fprintf (stderr, - "Failed to load exchange configuration\n"); - GNUNET_free_non_null (add_str); - GNUNET_free_non_null (details); - GNUNET_free_non_null (reserve_pub_str); - return 1; - } ret = 1; if (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))) diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c index 5bb4835de..930086d39 100644 --- a/src/exchange-tools/taler-exchange-wire.c +++ b/src/exchange-tools/taler-exchange-wire.c @@ -46,6 +46,11 @@ static char *method; */ static char *output_filename; +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; + /** * The main function of the taler-exchange-sepa tool. This tool is used @@ -59,7 +64,9 @@ int main (int argc, char *const *argv) { - static const struct GNUNET_GETOPT_CommandLineOption options[] = { + char *cfgfile = NULL; + const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_CFG_FILE (&cfgfile), {'j', "json", "JSON", "account information in JSON format", 1, &GNUNET_GETOPT_set_string, &json_in}, @@ -95,10 +102,26 @@ main (int argc, options, argc, argv) < 0) return 1; - if (NULL == masterkeyfile) + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, + cfgfile)) + { + 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 ( (NULL == masterkeyfile) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchange-master", + "MASTER_PRIV_FILE", + &masterkeyfile)) ) { fprintf (stderr, - "Master key file not given\n"); + "Master key file not given in neither configuration nor command-line\n"); return 1; } eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); 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 @@ -134,11 +134,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) */ @@ -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-exchange-home/config/exchange-common.conf b/src/exchange/test-exchange-home/config/exchange-common.conf deleted file mode 100644 index 4078cbee5..000000000 --- a/src/exchange/test-exchange-home/config/exchange-common.conf +++ /dev/null @@ -1,39 +0,0 @@ -[exchange] -# Currency supported by the exchange (can only be one) -CURRENCY = EUR - -# Wire format supported by the exchange -# We use 'test' for testing of the actual -# coin operations. -WIREFORMAT = test - -# HTTP port the exchange listens to -PORT = 8081 - -# Master public key used to sign the exchange's various keys -MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# How to access our database -DB = postgres - -# Is this is a testcase, use transient DB actions? -TESTRUN = YES - -[exchangedb-postgres] -DB_CONN_STR = "postgres:///talercheck" - - -[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 diff --git a/src/exchange/test-exchange-home/master.priv b/src/exchange/test-exchange-home/master.priv deleted file mode 100644 index 394926938..000000000 --- a/src/exchange/test-exchange-home/master.priv +++ /dev/null @@ -1 +0,0 @@ -p^-33XX!\0qmU_ \ No newline at end of file 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_taler_exchange_httpd.conf b/src/exchange/test_taler_exchange_httpd.conf new file mode 100644 index 000000000..0ce9dadd2 --- /dev/null +++ b/src/exchange/test_taler_exchange_httpd.conf @@ -0,0 +1,82 @@ +[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 + +# Wire format supported by the exchange +# We use 'test' for testing of the actual +# coin operations. +WIREFORMAT = test + +# HTTP port the exchange listens to +PORT = 8081 + +# Master public key used to sign the exchange's various keys +MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG + +# How to access our database +DB = postgres + +# Is this is a testcase, use transient DB actions? +TESTRUN = YES + + + + +[exchangedb-postgres] +DB_CONN_STR = "postgres:///talercheck" + + +[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 + + +# 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_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv new file mode 100644 index 000000000..394926938 --- /dev/null +++ b/src/exchange/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv @@ -0,0 +1 @@ +p^-33XX!\0qmU_ \ No newline at end of file diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index fff112994..0c6a73138 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -6,6 +6,17 @@ if USE_COVERAGE XLIB = -lgcov endif +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + exchangedb.conf \ + exchangedb-postgres.conf + +EXTRA_DIST = \ + exchangedb.conf \ + exchangedb-postgres.conf + + plugindir = $(libdir)/taler if HAVE_POSTGRESQL diff --git a/src/exchangedb/exchangedb-postgres.conf b/src/exchangedb/exchangedb-postgres.conf new file mode 100644 index 000000000..3de7474ff --- /dev/null +++ b/src/exchangedb/exchangedb-postgres.conf @@ -0,0 +1,2 @@ +[exchangedb-postgres] +DB_CONN_STR = "postgres:///taler" diff --git a/src/exchangedb/exchangedb.conf b/src/exchangedb/exchangedb.conf new file mode 100644 index 000000000..19277ed23 --- /dev/null +++ b/src/exchangedb/exchangedb.conf @@ -0,0 +1,7 @@ +# This file is in the public domain. +# +# Database-backend independent specification for the exchangedb module. +# +[exchangedb] +# Where do we expect to find information about auditors? +AUDITOR_BASE_DIR = ${TALER_DATA_HOME}/auditors/ diff --git a/src/exchangedb/exchangedb_keyio.c b/src/exchangedb/exchangedb_keyio.c index 4d4f78ed5..9f170f645 100644 --- a/src/exchangedb/exchangedb_keyio.c +++ b/src/exchangedb/exchangedb_keyio.c @@ -502,9 +502,7 @@ auditor_iter (void *cls, /** * Call @a it with information for each auditor found in the @a exchange_base_dir. * - * @param exchange_base_dir base directory for the exchange, - * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS - * subdirectory + * @param cfg configuration to use * @param it function to call with auditor information * @param it_cls closure for @a it * @return -1 on error, 0 if no files were found, otherwise @@ -513,23 +511,26 @@ auditor_iter (void *cls, * as maybe none of the files were well-formed) */ int -TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, +TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_AuditorIterator it, void *it_cls) { - char *dir; struct AuditorIterateContext aic; int ret; + char *auditor_base_dir; - GNUNET_asprintf (&dir, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_AUDITORS, - exchange_base_dir); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "exchangedb", + "AUDITOR_BASE_DIR", + &auditor_base_dir)) + return -1; aic.it = it; aic.it_cls = it_cls; - ret = GNUNET_DISK_directory_scan (dir, + ret = GNUNET_DISK_directory_scan (auditor_base_dir, &auditor_iter, &aic); - GNUNET_free (dir); + GNUNET_free (auditor_base_dir); return ret; } diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index e13df2d46..1f6445212 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -37,12 +37,6 @@ */ #define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys" -/** - * Subdirectory under the exchange's base directory which contains - * the exchange's auditing information. - */ -#define TALER_EXCHANGEDB_DIR_AUDITORS "auditors" - GNUNET_NETWORK_STRUCT_BEGIN @@ -234,9 +228,7 @@ typedef int /** * Call @a it with information for each auditor found in the @a exchange_base_dir. * - * @param exchange_base_dir base directory for the exchange, - * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS - * subdirectory + * @param cfg configuration to use * @param it function to call with auditor information * @param it_cls closure for @a it * @return -1 on error, 0 if no files were found, otherwise @@ -245,7 +237,7 @@ typedef int * as maybe none of the files were well-formed) */ int -TALER_EXCHANGEDB_auditor_iterate (const char *exchange_base_dir, +TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, TALER_EXCHANGEDB_AuditorIterator it, void *it_cls); diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 425304152..0b1d40c85 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -95,17 +95,6 @@ TALER_b2s (const void *buf, #define TALER_B2S(obj) TALER_b2s (obj, sizeof (*obj)) -/** - * Load configuration by parsing all configuration - * files in the given directory. - * - * @param base_dir directory with the configuration files - * @return NULL on error, otherwise configuration - */ -struct GNUNET_CONFIGURATION_Handle * -TALER_config_load (const char *base_dir); - - /** * Obtain denomination amount from configuration file. * diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 54f0f0e38..f52bc81c6 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -6,6 +6,15 @@ if USE_COVERAGE XLIB = -lgcov endif + +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + paths.conf + +EXTRA_DIST = \ + paths.conf + if WALLET_ONLY lib_LTLIBRARIES = \ libtalerutil_wallet.la diff --git a/src/util/paths.conf b/src/util/paths.conf new file mode 100644 index 000000000..03febb0e4 --- /dev/null +++ b/src/util/paths.conf @@ -0,0 +1,29 @@ +# This file is in the public domain. +# +[PATHS] +# The PATHS section is special, as filenames including $-expression are +# expanded using the values from PATHS or the system environment (PATHS +# is checked first). Taler also supports expanding $-expressions using +# defaults with the syntax "${VAR:-default}". Here, "default" can again +# be a $-expression. +# +# We usually want $HOME for $TALER_HOME, but we allow testcases to +# easily override this by setting $TALER_TEST_HOME. +# +TALER_HOME = ${TALER_TEST_HOME:-${HOME:-${USERPROFILE}}} + +# see XDG Base Directory Specification at +# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +# for how these should be used. + +# Persistant data storage +TALER_DATA_HOME = ${XDG_DATA_HOME:-$TALER_HOME/.local/share}/taler/ + +# Configuration files +TALER_CONFIG_HOME = ${XDG_CONFIG_HOME:-$TALER_HOME/.config}/taler/ + +# Cached data, no big deal if lost +TALER_CACHE_HOME = ${XDG_CACHE_HOME:-$TALER_HOME/.cache}/taler/ + +# Runtime data (always lost on system boot) +TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/ diff --git a/src/util/util.c b/src/util/util.c index 434ce8a9d..d5fa8c05c 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -89,31 +89,4 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, } -/** - * Load configuration by parsing all configuration - * files in the given directory. - * - * @param base_dir directory with the configuration files - * @return NULL on error, otherwise configuration - */ -struct GNUNET_CONFIGURATION_Handle * -TALER_config_load (const char *base_dir) -{ - struct GNUNET_CONFIGURATION_Handle *cfg; - char *cfg_dir; - int res; - - res = GNUNET_asprintf (&cfg_dir, - "%s" DIR_SEPARATOR_STR "config", - base_dir); - GNUNET_assert (res > 0); - cfg = GNUNET_CONFIGURATION_create (); - res = GNUNET_CONFIGURATION_load_from (cfg, cfg_dir); - GNUNET_free (cfg_dir); - if (GNUNET_OK != res) - return NULL; - return cfg; -} - - /* end of util.c */ diff --git a/src/wire/Makefile.am b/src/wire/Makefile.am index fd59c8eb7..0ed5f7be9 100644 --- a/src/wire/Makefile.am +++ b/src/wire/Makefile.am @@ -6,6 +6,17 @@ if USE_COVERAGE XLIB = -lgcov endif +pkgcfgdir = $(prefix)/share/taler/config.d/ + +pkgcfg_DATA = \ + wire-sepa.conf \ + wire-test.conf + + +EXTRA_DIST = \ + wire-sepa.conf \ + wire-test.conf + plugindir = $(libdir)/taler plugin_LTLIBRARIES = \ diff --git a/src/wire/wire-sepa.conf b/src/wire/wire-sepa.conf new file mode 100644 index 000000000..0ee17db30 --- /dev/null +++ b/src/wire/wire-sepa.conf @@ -0,0 +1,7 @@ +# Configuration for SEPA wire plugin. + +[wire-incoming-sepa] +SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json + +[wire-incoming-sepa] +SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json diff --git a/src/wire/wire-test.conf b/src/wire/wire-test.conf new file mode 100644 index 000000000..f2a71e2e4 --- /dev/null +++ b/src/wire/wire-test.conf @@ -0,0 +1,14 @@ +[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 -- cgit v1.2.3 From a7f2496795a80dca6fbbfb5a20f0ee4b7a72650e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 11 Apr 2016 15:59:24 +0200 Subject: adding wire plugin tests, resolving #4357 --- .gitignore | 1 + src/wire/Makefile.am | 4 +- src/wire/plugin_wire_sepa.c | 3 + src/wire/test_wire_plugin.c | 108 +++++++++++++++++++++++++++++++++--- src/wire/test_wire_plugin.conf | 21 +++++++ src/wire/test_wire_plugin_key.priv | 1 + src/wire/test_wire_plugin_sepa.json | 8 +++ src/wire/test_wire_plugin_test.json | 7 +++ 8 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 src/wire/test_wire_plugin.conf create mode 100644 src/wire/test_wire_plugin_key.priv create mode 100644 src/wire/test_wire_plugin_sepa.json create mode 100644 src/wire/test_wire_plugin_test.json (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index fc31e919e..20d4b52c2 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ src/exchange-tools/taler-exchange-wire src/exchangedb/perf-exchangedb src/json/test_json src/wire/test_sepa_wireformat +src/wire/test_wire_plugin src/pq/test_pq src/util/test_amount src/util/test_crypto diff --git a/src/wire/Makefile.am b/src/wire/Makefile.am index 107ceb379..debb27828 100644 --- a/src/wire/Makefile.am +++ b/src/wire/Makefile.am @@ -15,7 +15,8 @@ pkgcfg_DATA = \ EXTRA_DIST = \ wire-sepa.conf \ - wire-test.conf + wire-test.conf \ + test_wire_plugin.conf plugindir = $(libdir)/taler @@ -97,6 +98,7 @@ test_sepa_wireformat_LDADD = \ test_wire_plugin_SOURCES = \ test_wire_plugin.c test_wire_plugin_LDADD = \ + -lgnunetjson \ -lgnunetutil \ -ljansson \ libtalerwire.la \ diff --git a/src/wire/plugin_wire_sepa.c b/src/wire/plugin_wire_sepa.c index e0a3426c2..6f01167d9 100644 --- a/src/wire/plugin_wire_sepa.c +++ b/src/wire/plugin_wire_sepa.c @@ -539,6 +539,9 @@ sepa_get_wire_details (void *cls, "SEPA_RESPONSE_FILE", &sepa_wire_file)) { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, + account_name, + "SEPA_RESPONSE_FILE"); return NULL; } ret = json_load_file (sepa_wire_file, diff --git a/src/wire/test_wire_plugin.c b/src/wire/test_wire_plugin.c index 9f61b21fe..27b4366c1 100644 --- a/src/wire/test_wire_plugin.c +++ b/src/wire/test_wire_plugin.c @@ -23,6 +23,8 @@ #include "taler_util.h" #include "taler_wire_lib.h" #include "taler_wire_plugin.h" +#include +#include /** @@ -48,32 +50,120 @@ struct TestBlock { * to use for the tests. */ static struct TestBlock tests[] = { - { "sepa", "{ \"iban\":3 }" }, - { "test", "{ \"bank_uri\":3 }" }, + { "sepa", "{ \"type\":\"sepa\", \"iban\":\"DE67830654080004822650\", \"name\":\"GNUnet e.V.\", \"bic\":\"GENODEF1SLR\" }" }, + { "test", "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":42 }" }, { NULL, NULL } }; +/** + * Private key used to sign wire details. + */ +static struct TALER_MasterPrivateKeyP priv_key; + +/** + * Public key matching #priv_key. + */ +static struct TALER_MasterPublicKeyP pub_key; + +/** + * Our configuration. + */ +static struct GNUNET_CONFIGURATION_Handle *cfg; + + +/** + * Run the test. + * + * @param name of the test + * @param plugin plugin to test + * @param wire wire details for testing + * @return #GNUNET_OK on success + */ +static int +run_test (const char *name, + struct TALER_WIRE_Plugin *plugin, + json_t *wire) +{ + struct GNUNET_HashCode salt; + struct TALER_MasterSignatureP sig; + json_t *lwire; + + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, + &salt, + sizeof (salt)); + if (GNUNET_OK != + plugin->sign_wire_details (plugin->cls, + wire, + &priv_key, + &salt, + &sig)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + json_object_set_new (wire, + "salt", + GNUNET_JSON_from_data (&salt, + sizeof (salt))); + json_object_set_new (wire, + "sig", + GNUNET_JSON_from_data (&sig, + sizeof (sig))); + if (GNUNET_OK != + plugin->wire_validate (plugin->cls, + wire, + &pub_key)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + /* load wire details from file */ + lwire = plugin->get_wire_details (plugin->cls, + cfg, + name); + if (NULL == lwire) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + plugin->wire_validate (plugin->cls, + lwire, + &pub_key)) + { + GNUNET_break (0); + json_decref (lwire); + return GNUNET_SYSERR; + } + json_decref (lwire); + return GNUNET_OK; +} + + int main (int argc, const char *const argv[]) { json_t *wire; - json_error_t error; int ret; - struct GNUNET_CONFIGURATION_Handle *cfg; struct TALER_WIRE_Plugin *plugin; const struct TestBlock *test; unsigned int i; + struct GNUNET_CRYPTO_EddsaPrivateKey *pk; GNUNET_log_setup ("test-wire-plugin", "WARNING", NULL); cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "exchange", - "currency", - "EUR"); + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_load (cfg, + "test_wire_plugin.conf")); + pk = GNUNET_CRYPTO_eddsa_key_create_from_file ("test_wire_plugin_key.priv"); + priv_key.eddsa_priv = *pk; + GNUNET_free (pk); + GNUNET_CRYPTO_eddsa_key_get_public (&priv_key.eddsa_priv, + &pub_key.eddsa_pub); ret = GNUNET_OK; for (i=0;NULL != (test = &tests[i])->plugin_name;i++) { @@ -82,7 +172,7 @@ main (int argc, GNUNET_assert (NULL != plugin); wire = json_loads (test->json_proto, 0, NULL); GNUNET_assert (NULL != wire); - // FIXME: do test... + ret = run_test (test->plugin_name, plugin, wire); json_decref (wire); TALER_WIRE_plugin_unload (plugin); if (GNUNET_OK != ret) diff --git a/src/wire/test_wire_plugin.conf b/src/wire/test_wire_plugin.conf new file mode 100644 index 000000000..ece816954 --- /dev/null +++ b/src/wire/test_wire_plugin.conf @@ -0,0 +1,21 @@ +# This file is in the public domain. +# +[test] +# This is the response we give out for the /wire request. It provides +# wallets with the bank information for transfers to the exchange. +TEST_RESPONSE_FILE = test_wire_plugin_test.json + +[sepa] +# This is the response we give out for the /wire request. It provides +# wallets with the bank information for transfers to the exchange. +SEPA_RESPONSE_FILE = test_wire_plugin_sepa.json + + +[wire-outgoing-test] +# For transfers made by the exchange, we need to know +# the URI of the bank (where the /admin/add/incoming API +# is avaialble). +BANK_URI = http://localhost/ + +[exchange] +CURRENCY = "EUR" diff --git a/src/wire/test_wire_plugin_key.priv b/src/wire/test_wire_plugin_key.priv new file mode 100644 index 000000000..26b4f26f6 --- /dev/null +++ b/src/wire/test_wire_plugin_key.priv @@ -0,0 +1 @@ +?Sgb@Js; %aKȉs_Hў \ No newline at end of file diff --git a/src/wire/test_wire_plugin_sepa.json b/src/wire/test_wire_plugin_sepa.json new file mode 100644 index 000000000..175345f0c --- /dev/null +++ b/src/wire/test_wire_plugin_sepa.json @@ -0,0 +1,8 @@ +{ + "salt": "32V01R7K4T02S74PZZMVXRQ1K7FR948RBNB9BJ5Z101HEQFH7CW7J82006GY3BPTGQ4FM775PSSRD3K9MY97HSNVVCGEVBPVSAQ2710", + "type": "sepa", + "iban": "DE67830654080004822650", + "sig": "K48GPPM715ZXX0DC597WESD5ECT3R0B3TAFQMB68SBF4K5CZ5KCE9NESN1JX412SPZ82PSV7JAPVJFXDDTZ63YV4295S5RC28E4221G", + "name": "GNUnet e.V.", + "bic": "GENODEF1SLR" +} \ No newline at end of file diff --git a/src/wire/test_wire_plugin_test.json b/src/wire/test_wire_plugin_test.json new file mode 100644 index 000000000..6fe6b2359 --- /dev/null +++ b/src/wire/test_wire_plugin_test.json @@ -0,0 +1,7 @@ +{ + "type": "test", + "bank_uri": "http://localhost/", + "sig": "KX1CMHNFH1WE10244AEF07AXHJCF9PZDZVNZBC9P4EJEQ1MH1Y3C2TWF08VTQMK4N5TCV0V1VTGWSV0WB8TB9YQRZW87F5A6KCEZ81R", + "account_number": 42, + "salt": "EZV905MQPVAZEMGC6SEZQF2Z75P6ZKTN8TX00JHN11S7J81DQ78G8Z551K6TGR9WHPP0JW1X9J9X9CVRY48JTHBCP6Q4XKJ6R2G18G0" +} \ No newline at end of file -- cgit v1.2.3