small steps towards removing hard-coded exchange account
This commit is contained in:
parent
572f350660
commit
08a447985c
@ -801,6 +801,7 @@ TALER_TESTING_run_fakebank (const char *bank_url);
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_prepare_bank (const char *config_filename,
|
TALER_TESTING_prepare_bank (const char *config_filename,
|
||||||
|
const char *config_section,
|
||||||
struct TALER_TESTING_BankConfiguration *bc);
|
struct TALER_TESTING_BankConfiguration *bc);
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ main (int argc,
|
|||||||
cfgfilename = CONFIG_FILE_PYBANK;
|
cfgfilename = CONFIG_FILE_PYBANK;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_prepare_bank (CONFIG_FILE_PYBANK,
|
TALER_TESTING_prepare_bank (CONFIG_FILE_PYBANK,
|
||||||
|
"account-2",
|
||||||
&bc))
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -29,3 +29,6 @@ database = postgres:///talercheck
|
|||||||
|
|
||||||
[account-1]
|
[account-1]
|
||||||
URL = payto://x-taler-bank/localhost:8081/1
|
URL = payto://x-taler-bank/localhost:8081/1
|
||||||
|
|
||||||
|
[account-2]
|
||||||
|
URL = payto://x-taler-bank/localhost:8081/2
|
||||||
|
@ -178,6 +178,7 @@ main (int argc,
|
|||||||
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
TALER_LOG_DEBUG ("Running against the Pybank.\n");
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_prepare_bank (cfgfilename,
|
TALER_TESTING_prepare_bank (cfgfilename,
|
||||||
|
"account-2",
|
||||||
&bc))
|
&bc))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
|
|
||||||
#define EXCHANGE_ACCOUNT_NAME "2"
|
|
||||||
|
|
||||||
#define BANK_FAIL() \
|
#define BANK_FAIL() \
|
||||||
do {GNUNET_break (0); return NULL; } while (0)
|
do {GNUNET_break (0); return NULL; } while (0)
|
||||||
|
|
||||||
@ -227,6 +225,7 @@ TALER_TESTING_run_bank (const char *config_filename,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_TESTING_prepare_bank (const char *config_filename,
|
TALER_TESTING_prepare_bank (const char *config_filename,
|
||||||
|
const char *config_section,
|
||||||
struct TALER_TESTING_BankConfiguration *bc)
|
struct TALER_TESTING_BankConfiguration *bc)
|
||||||
{
|
{
|
||||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
@ -235,6 +234,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
enum GNUNET_OS_ProcessStatusType type;
|
enum GNUNET_OS_ProcessStatusType type;
|
||||||
unsigned long code;
|
unsigned long code;
|
||||||
char *database;
|
char *database;
|
||||||
|
char *exchange_payto_uri;
|
||||||
|
|
||||||
cfg = GNUNET_CONFIGURATION_create ();
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
|
|
||||||
@ -259,6 +259,19 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
return GNUNET_SYSERR;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_number (cfg,
|
GNUNET_CONFIGURATION_get_value_number (cfg,
|
||||||
"bank",
|
"bank",
|
||||||
@ -340,7 +353,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
GNUNET_OS_process_destroy (dbreset_proc);
|
GNUNET_OS_process_destroy (dbreset_proc);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_BANK_auth_parse_cfg (cfg,
|
TALER_BANK_auth_parse_cfg (cfg,
|
||||||
"account-" EXCHANGE_ACCOUNT_NAME,
|
config_section,
|
||||||
&bc->exchange_auth))
|
&bc->exchange_auth))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -350,7 +363,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
|
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_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->user42_payto = "payto://x-taler-bank/localhost/42";
|
||||||
bc->user43_payto = "payto://x-taler-bank/localhost/43";
|
bc->user43_payto = "payto://x-taler-bank/localhost/43";
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
@ -384,6 +397,8 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|||||||
{
|
{
|
||||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
unsigned long long fakebank_port;
|
unsigned long long fakebank_port;
|
||||||
|
char *exchange_payto_uri;
|
||||||
|
char *exchange_xtalerbank_account;
|
||||||
|
|
||||||
cfg = GNUNET_CONFIGURATION_create ();
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
|
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
|
||||||
@ -402,22 +417,39 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
return GNUNET_SYSERR;
|
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;
|
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,
|
GNUNET_asprintf (&bc->exchange_auth.wire_gateway_url,
|
||||||
"http://localhost:%u/%s/",
|
"http://localhost:%u/%s/",
|
||||||
(unsigned int) fakebank_port,
|
(unsigned int) fakebank_port,
|
||||||
EXCHANGE_ACCOUNT_NAME);
|
exchange_xtalerbank_account);
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Using fakebank %s on port %u\n",
|
"Using fakebank %s on port %u\n",
|
||||||
bc->exchange_auth.wire_gateway_url,
|
bc->exchange_auth.wire_gateway_url,
|
||||||
(unsigned int) fakebank_port);
|
(unsigned int) fakebank_port);
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
||||||
"Fakebank port from config: %u\n",
|
|
||||||
(unsigned int) fakebank_port);
|
|
||||||
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
|
bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -428,17 +460,14 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
/* FIXME: this duplicates bc->exchange_auth.wire_gateway_url */
|
/* FIXME: this duplicates bc->exchange_auth.wire_gateway_url */
|
||||||
GNUNET_asprintf (&bc->exchange_account_url,
|
bc->exchange_account_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
|
||||||
"http://localhost:%u/%s/",
|
|
||||||
fakebank_port,
|
|
||||||
EXCHANGE_ACCOUNT_NAME);
|
|
||||||
GNUNET_assert (NULL != bc->exchange_account_url);
|
GNUNET_assert (NULL != bc->exchange_account_url);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
|
||||||
bc->exchange_account_url);
|
bc->exchange_account_url);
|
||||||
/* Now we know it's the fake bank, for purpose of authentication, we
|
/* Now we know it's the fake bank, for purpose of authentication, we
|
||||||
* don't have any auth. */
|
* don't have any auth. */
|
||||||
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
|
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->user42_payto = "payto://x-taler-bank/localhost/42";
|
||||||
bc->user43_payto = "payto://x-taler-bank/localhost/43";
|
bc->user43_payto = "payto://x-taler-bank/localhost/43";
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user