diff --git a/contrib/Makefile.am b/contrib/Makefile.am index dfe37429e..58b00812e 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,9 +1,11 @@ SUBDIRS = . tos pp +bin_SCRIPTS = \ + taler-bank-manage-testing + EXTRA_DIST = \ auditor-report.tex.j2 \ coverage.sh \ gnunet.tag \ microhttpd.tag \ render.py - diff --git a/contrib/exchange-template/config/exchange-common.conf b/contrib/exchange-template/config/exchange-common.conf index 425bb92b2..922726ec2 100644 --- a/contrib/exchange-template/config/exchange-common.conf +++ b/contrib/exchange-template/config/exchange-common.conf @@ -52,8 +52,8 @@ PLUGIN = taler_bank # We also may need authentication data. TALER_BANK_AUTH_METHOD = "none" # or basic -# TALER_BANK_USERNAME = user -# TALER_BANK_PASSWORD = pass +# TALER_TALER_TESTING_BANK_USERNAME = user +# TALER_TALER_TESTING_BANK_PASSWORD = pass # Accounts need to be enabled for the aggregator to debit them. ENABLE_DEBIT = YES diff --git a/contrib/taler-bank-manage-testing b/contrib/taler-bank-manage-testing new file mode 100755 index 000000000..196a02d5e --- /dev/null +++ b/contrib/taler-bank-manage-testing @@ -0,0 +1,30 @@ +#!/bin/sh +# This file is in the public domain +# Wrapper around 'taler-bank-manage' to first configure the required +# testing accounts before launching the bank properly. +# +# Takes 3 arguments: +# $1: the configuration file name +# $2: the database name +# $3: serve-http or serve-uwsgi + +set -eu + +# Reset database, provide starting accounts +taler-bank-manage -c $1 --with-db $2 django flush --no-input +taler-bank-manage -c $1 --with-db $2 django provide_accounts + +# This is 'x' hashed by Django +PW_HASH='pbkdf2_sha256$180000$RBYjEO0WzE1z$x2Avt35TkOL2pMHvts3B1U1NIJalXZf95WnJhGFOAUs=' + +# hack password hash directly into the database: +echo "UPDATE auth_user SET password='$PW_HASH'" | psql -Aqt $2 + +# Note that calling +# taler-bank-manage -c $1 --with-db $2 django changepassword Bank x +# does not work: (1) it always insists on going interactive, and (2) +# rejects 'x' as a password. + + +# Now run Django for good +exec taler-bank-manage -c $1 --with-db $2 $3 \ No newline at end of file diff --git a/src/auditor/generate-auditor-basedb.sh b/src/auditor/generate-auditor-basedb.sh index e08bd12eb..7e8724cbf 100755 --- a/src/auditor/generate-auditor-basedb.sh +++ b/src/auditor/generate-auditor-basedb.sh @@ -96,7 +96,7 @@ mv a2e.dat $ABD # Launch services echo "Launching services" -taler-bank-manage -c $CONF serve-http & +taler-bank-manage-testing $CONF $TARGET_DB serve-http & taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log & taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log & taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log & diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index cff444fb9..5240a3724 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -23,7 +23,6 @@ #include "bank_api_common.h" #include /* just for HTTP status codes */ #include "taler_signatures.h" -// FIXME(dold): temporary hack #include "taler_curl_lib.h" diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index a7b6aef7e..d15984a9c 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -92,7 +92,7 @@ run (void *cls, struct TALER_TESTING_Command commands[] = { TALER_TESTING_cmd_bank_history ("history-0", bank_url, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_YES, NULL, @@ -101,65 +101,65 @@ run (void *cls, * the parameters, although it was always set as '200 OK' */ TRANSFER ("debit-1", "KUDOS:5.01", - EXCHANGE_ACCOUNT_NUMBER, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, "subject 1"), TALER_TESTING_cmd_bank_history ("history-1c", bank_url, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_CREDIT, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_bank_history ("history-1d", bank_url, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_DEBIT, GNUNET_YES, NULL, 5), TRANSFER ("debit-2", "KUDOS:3.21", - EXCHANGE_ACCOUNT_NUMBER, - USER_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_USER_ACCOUNT_NUMBER, "subject 2"), TRANSFER ("credit-2", "KUDOS:3.22", - USER_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_USER_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, "credit 2"), TALER_TESTING_cmd_bank_history ("history-2b", bank_url, - EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_bank_history ("history-2bi", bank_url, - EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_YES, "debit-1", 5), TRANSFER ("credit-for-reject-1", "KUDOS:1.01", - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, "subject 3"), TALER_TESTING_cmd_bank_reject ("reject-1", bank_url, "credit-for-reject-1"), TALER_TESTING_cmd_bank_history ("history-r1", bank_url, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_bank_history ("history-r1c", bank_url, - BANK_ACCOUNT_NUMBER, + TALER_TESTING_BANK_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, GNUNET_YES, @@ -187,7 +187,7 @@ main (int argc, /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup ("test-bank-api-with-(fake)bank-new", + GNUNET_log_setup ("test-bank-api", "DEBUG", NULL); diff --git a/src/bank-lib/test_bank_api_twisted.c b/src/bank-lib/test_bank_api_twisted.c index 2d2483d49..b926f9655 100644 --- a/src/bank-lib/test_bank_api_twisted.c +++ b/src/bank-lib/test_bank_api_twisted.c @@ -93,7 +93,7 @@ run (void *cls, TWISTED_BANK_URL), TALER_TESTING_cmd_bank_history ("history-0", TWISTED_BANK_URL, - EXCHANGE_ACCOUNT_NUMBER, + TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_NO, NULL, diff --git a/src/bank-lib/testing_api_helpers.c b/src/bank-lib/testing_api_helpers.c index 2f5ea36f5..499129aeb 100644 --- a/src/bank-lib/testing_api_helpers.c +++ b/src/bank-lib/testing_api_helpers.c @@ -41,18 +41,18 @@ struct TALER_BANK_AuthenticationData AUTHS[] = { /* Bank credentials */ {.method = TALER_BANK_AUTH_BASIC, - .details.basic.username = BANK_USERNAME, - .details.basic.password = BANK_PASSWORD}, + .details.basic.username = TALER_TESTING_BANK_USERNAME, + .details.basic.password = TALER_TESTING_BANK_PASSWORD}, /* Exchange credentials */ {.method = TALER_BANK_AUTH_BASIC, - .details.basic.username = EXCHANGE_USERNAME, - .details.basic.password = EXCHANGE_PASSWORD }, + .details.basic.username = TALER_TESTING_EXCHANGE_USERNAME, + .details.basic.password = TALER_TESTING_EXCHANGE_PASSWORD }, /* User credentials */ {.method = TALER_BANK_AUTH_BASIC, - .details.basic.username = USER_USERNAME, - .details.basic.password = USER_PASSWORD } + .details.basic.username = TALER_TESTING_USER_USERNAME, + .details.basic.password = TALER_TESTING_USER_PASSWORD } }; @@ -193,10 +193,10 @@ TALER_TESTING_run_bank (const char *config_filename, (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", config_filename, - "--with-db", database, + "taler-bank-manage-testing", + "taler-bank-manage-testing", + config_filename, + database, serve_arg, NULL); GNUNET_free (database); if (NULL == bank_proc) @@ -243,6 +243,9 @@ TALER_TESTING_run_bank (const char *config_filename, * Prepare the bank execution. Check if the port is available * and reset database. * + * NOTE: resetting the database is now done by taler-bank-manage-testing + * and should be removed here (once it works...)! FIXME! + * * @param config_filename configuration file name. * * @return the base url, or NULL upon errors. Must be freed diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index da10762cf..31dbdf15a 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -63,7 +63,7 @@ enum BenchmarkError * the only requirement is that this number then matches the * number given when building payto URLs at deposit time. */ -#define USER_ACCOUNT_NUMBER 3 +#define TALER_TESTING_USER_ACCOUNT_NUMBER 3 #define FIRST_INSTRUCTION -1 @@ -72,7 +72,7 @@ enum BenchmarkError (TALER_TESTING_cmd_fakebank_transfer (label, amount, \ exchange_bank_account.details. \ x_taler_bank.bank_base_url, \ - USER_ACCOUNT_NUMBER, \ + TALER_TESTING_USER_ACCOUNT_NUMBER, \ exchange_bank_account.details. \ x_taler_bank.no, \ "dummy_user", \ @@ -321,7 +321,7 @@ run (void *cls, withdraw_label, 0, /* Index of the one withdrawn coin in the traits. */ TALER_TESTING_make_wire_details - (USER_ACCOUNT_NUMBER, + (TALER_TESTING_USER_ACCOUNT_NUMBER, exchange_bank_account.details.x_taler_bank.hostname), order_enc, GNUNET_TIME_UNIT_ZERO, diff --git a/src/include/taler_testing_bank_lib.h b/src/include/taler_testing_bank_lib.h index 6b407197f..350aca3b7 100644 --- a/src/include/taler_testing_bank_lib.h +++ b/src/include/taler_testing_bank_lib.h @@ -35,15 +35,17 @@ /* ******** Credentials to log in at the bank ******* */ -#define BANK_ACCOUNT_NUMBER 1 -#define BANK_USERNAME "Bank" -#define BANK_PASSWORD "x" -#define EXCHANGE_ACCOUNT_NUMBER 2 -#define EXCHANGE_USERNAME "Exchange" -#define EXCHANGE_PASSWORD "x" -#define USER_ACCOUNT_NUMBER 3 -#define USER_USERNAME "Tor" -#define USER_PASSWORD "x" +/* Note that the same passwords must be set in the script in + contrib/taler-bank-manage-testing for the tests to work! */ +#define TALER_TESTING_BANK_ACCOUNT_NUMBER 1 +#define TALER_TESTING_BANK_USERNAME "Bank" +#define TALER_TESTING_BANK_PASSWORD "x" +#define TALER_TESTING_EXCHANGE_ACCOUNT_NUMBER 2 +#define TALER_TESTING_EXCHANGE_USERNAME "Exchange" +#define TALER_TESTING_EXCHANGE_PASSWORD "x" +#define TALER_TESTING_USER_ACCOUNT_NUMBER 3 +#define TALER_TESTING_USER_USERNAME "Tor" +#define TALER_TESTING_USER_PASSWORD "x" /* ********************* Helper functions ********************* */