aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-01-18 03:50:54 +0100
committerFlorian Dold <florian.dold@gmail.com>2020-01-18 03:50:54 +0100
commit08a447985c598561555a00e15b83f84ece79ceb8 (patch)
treef43b1d1fe9a8074174a6bd991611ffe3d5f8c73c /src/lib
parent572f35066075efef81c17eca9bd8b6696dc02dea (diff)
small steps towards removing hard-coded exchange account
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/test_bank_api.c1
-rw-r--r--src/lib/test_bank_api_fakebank_twisted.conf3
-rw-r--r--src/lib/test_bank_api_twisted.c1
-rw-r--r--src/lib/testing_api_helpers_bank.c57
4 files changed, 48 insertions, 14 deletions
diff --git a/src/lib/test_bank_api.c b/src/lib/test_bank_api.c
index b12576175..c6049c019 100644
--- a/src/lib/test_bank_api.c
+++ b/src/lib/test_bank_api.c
@@ -157,6 +157,7 @@ main (int argc,
cfgfilename = CONFIG_FILE_PYBANK;
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (CONFIG_FILE_PYBANK,
+ "account-2",
&bc))
{
GNUNET_break (0);
diff --git a/src/lib/test_bank_api_fakebank_twisted.conf b/src/lib/test_bank_api_fakebank_twisted.conf
index 49ed4d535..4455ac743 100644
--- a/src/lib/test_bank_api_fakebank_twisted.conf
+++ b/src/lib/test_bank_api_fakebank_twisted.conf
@@ -29,3 +29,6 @@ database = postgres:///talercheck
[account-1]
URL = payto://x-taler-bank/localhost:8081/1
+
+[account-2]
+URL = payto://x-taler-bank/localhost:8081/2
diff --git a/src/lib/test_bank_api_twisted.c b/src/lib/test_bank_api_twisted.c
index daaa5afac..a1452804d 100644
--- a/src/lib/test_bank_api_twisted.c
+++ b/src/lib/test_bank_api_twisted.c
@@ -178,6 +178,7 @@ main (int argc,
TALER_LOG_DEBUG ("Running against the Pybank.\n");
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (cfgfilename,
+ "account-2",
&bc))
{
GNUNET_break (0);
diff --git a/src/lib/testing_api_helpers_bank.c b/src/lib/testing_api_helpers_bank.c
index d6fac4bd8..5fcc50222 100644
--- a/src/lib/testing_api_helpers_bank.c
+++ b/src/lib/testing_api_helpers_bank.c
@@ -27,8 +27,6 @@
#include "taler_testing_lib.h"
#include "taler_fakebank_lib.h"
-#define EXCHANGE_ACCOUNT_NAME "2"
-
#define BANK_FAIL() \
do {GNUNET_break (0); return NULL; } while (0)
@@ -227,6 +225,7 @@ TALER_TESTING_run_bank (const char *config_filename,
*/
int
TALER_TESTING_prepare_bank (const char *config_filename,
+ const char *config_section,
struct TALER_TESTING_BankConfiguration *bc)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -235,6 +234,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
enum GNUNET_OS_ProcessStatusType type;
unsigned long code;
char *database;
+ char *exchange_payto_uri;
cfg = GNUNET_CONFIGURATION_create ();
@@ -260,6 +260,19 @@ TALER_TESTING_prepare_bank (const char *config_filename,
}
if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ config_section,
+ "URL", /* FIXME: config should be renamed to payto_uri, it's not an url even! */
+ &exchange_payto_uri))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ config_section,
+ "URL");
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
+
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
"bank",
"HTTP_PORT",
@@ -340,7 +353,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
GNUNET_OS_process_destroy (dbreset_proc);
if (GNUNET_OK !=
TALER_BANK_auth_parse_cfg (cfg,
- "account-" EXCHANGE_ACCOUNT_NAME,
+ config_section,
&bc->exchange_auth))
{
GNUNET_break (0);
@@ -350,7 +363,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
GNUNET_CONFIGURATION_destroy (cfg);
bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
bc->exchange_account_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
- bc->exchange_payto = "payto://x-taler-bank/localhost/2";
+ bc->exchange_payto = exchange_payto_uri;
bc->user42_payto = "payto://x-taler-bank/localhost/42";
bc->user43_payto = "payto://x-taler-bank/localhost/43";
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -384,6 +397,8 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
{
struct GNUNET_CONFIGURATION_Handle *cfg;
unsigned long long fakebank_port;
+ char *exchange_payto_uri;
+ char *exchange_xtalerbank_account;
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
@@ -402,22 +417,39 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
GNUNET_CONFIGURATION_destroy (cfg);
return GNUNET_SYSERR;
}
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ config_section,
+ "URL", /* FIXME: config should be renamed to payto_uri, it's not an url even! */
+ &exchange_payto_uri))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ config_section,
+ "URL");
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
+ exchange_xtalerbank_account = TALER_xtalerbank_account_from_payto (
+ exchange_payto_uri);
+
+ if (NULL == exchange_xtalerbank_account)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+
GNUNET_asprintf (&bc->exchange_auth.wire_gateway_url,
"http://localhost:%u/%s/",
(unsigned int) fakebank_port,
- EXCHANGE_ACCOUNT_NAME);
+ exchange_xtalerbank_account);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Using fakebank %s on port %u\n",
bc->exchange_auth.wire_gateway_url,
(unsigned int) fakebank_port);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Fakebank port from config: %u\n",
- (unsigned int) fakebank_port);
-
GNUNET_CONFIGURATION_destroy (cfg);
bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
if (GNUNET_OK !=
@@ -428,17 +460,14 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
return GNUNET_SYSERR;
}
/* FIXME: this duplicates bc->exchange_auth.wire_gateway_url */
- GNUNET_asprintf (&bc->exchange_account_url,
- "http://localhost:%u/%s/",
- fakebank_port,
- EXCHANGE_ACCOUNT_NAME);
+ bc->exchange_account_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
GNUNET_assert (NULL != bc->exchange_account_url);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
bc->exchange_account_url);
/* Now we know it's the fake bank, for purpose of authentication, we
* don't have any auth. */
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
- bc->exchange_payto = "payto://x-taler-bank/localhost/2";
+ bc->exchange_payto = exchange_payto_uri;
bc->user42_payto = "payto://x-taler-bank/localhost/42";
bc->user43_payto = "payto://x-taler-bank/localhost/43";
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",