summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-01-17 01:23:32 +0100
committerFlorian Dold <florian.dold@gmail.com>2020-01-17 01:23:32 +0100
commit6faf6fc732afe58a5da71dd442ede78cdbd7c495 (patch)
treec3f8cc519f5a4bc14b7a361ff168b2b19095392d /src
parentc677720e7b5c6a228159044e35ac12554e9c280b (diff)
downloadexchange-6faf6fc732afe58a5da71dd442ede78cdbd7c495.tar.gz
exchange-6faf6fc732afe58a5da71dd442ede78cdbd7c495.tar.bz2
exchange-6faf6fc732afe58a5da71dd442ede78cdbd7c495.zip
payto fixes WIP
Diffstat (limited to 'src')
-rw-r--r--src/auditor/taler-wire-auditor.c3
-rw-r--r--src/bank-lib/bank_api_parse.c45
-rw-r--r--src/exchange/taler-exchange-aggregator.c3
-rw-r--r--src/exchange/taler-exchange-wirewatch.c3
-rw-r--r--src/include/taler_bank_service.h21
-rw-r--r--src/lib/test_auditor_api.conf1
-rw-r--r--src/lib/test_bank_api.c2
-rw-r--r--src/lib/test_bank_api.conf5
-rw-r--r--src/lib/testing_api_helpers_bank.c29
9 files changed, 98 insertions, 14 deletions
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c
index d8da36d07..8ea2b2fd0 100644
--- a/src/auditor/taler-wire-auditor.c
+++ b/src/auditor/taler-wire-auditor.c
@@ -1842,8 +1842,7 @@ process_credits (void *cls)
"Starting bank CREDIT history of account `%s'\n",
wa->section_name);
wa->chh = TALER_BANK_credit_history (ctx,
- wa->account.details.x_taler_bank.
- account_base_url,
+ wa->auth.wire_gateway_url,
&wa->auth,
wa->in_wire_off,
INT64_MAX,
diff --git a/src/bank-lib/bank_api_parse.c b/src/bank-lib/bank_api_parse.c
index 6e5c9f12c..5423d01b7 100644
--- a/src/bank-lib/bank_api_parse.c
+++ b/src/bank-lib/bank_api_parse.c
@@ -98,16 +98,50 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
{ NULL, TALER_BANK_AUTH_NONE }
};
char *method;
+ unsigned long long fakebank_port;
+
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ section,
+ "FAKEBANK_PORT",
+ &fakebank_port))
+ {
+ auth->method = TALER_BANK_AUTH_FAKEBANK;
+ auth->details.fakebank.fb_port = (uint16_t) fakebank_port;
+ // FIXME: we should not hardcode exchange account number "2"
+ GNUNET_asprintf (&auth->wire_gateway_url,
+ "http://localhost:%u/2/",
+ (unsigned int) fakebank_port);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Using fakebank %s on port %u\n",
+ auth->wire_gateway_url,
+ (unsigned int) fakebank_port);
+ return GNUNET_OK;
+ }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "TALER_BANK_AUTH_METHOD",
+ "WIRE_GATEWAY_URL",
+ &auth->wire_gateway_url))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "WIRE_GATEWAY_URL");
+ return GNUNET_SYSERR;
+ }
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "WIRE_GATEWAY_AUTH_METHOD",
&method))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section,
- "TALER_BANK_AUTH_METHOD");
+ "WIRE_GATEWAY_AUTH_METHOD");
+ GNUNET_free (auth->wire_gateway_url);
return GNUNET_SYSERR;
}
for (unsigned int i = 0; NULL != methods[i].m; i++)
@@ -132,6 +166,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
section,
"USERNAME");
GNUNET_free (method);
+ GNUNET_free (auth->wire_gateway_url);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@@ -146,11 +181,14 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
section,
"PASSWORD");
GNUNET_free (method);
+ GNUNET_free (auth->wire_gateway_url);
return GNUNET_SYSERR;
}
auth->method = TALER_BANK_AUTH_BASIC;
GNUNET_free (method);
return GNUNET_OK;
+ case TALER_BANK_AUTH_FAKEBANK:
+ GNUNET_assert (0);
}
}
}
@@ -184,7 +222,10 @@ TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth)
auth->details.basic.password = NULL;
}
break;
+ case TALER_BANK_AUTH_FAKEBANK:
+ break;
}
+ GNUNET_free (auth->wire_gateway_url);
}
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index 264cbf62b..df201d694 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1783,8 +1783,7 @@ wire_prepare_cb (void *cls,
}
wa = wpd->wa;
wpd->eh = TALER_BANK_execute_wire_transfer (ctx,
- wa->account.details.x_taler_bank.
- account_base_url,
+ wa->auth.wire_gateway_url,
&wa->auth,
buf,
buf_size,
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index c328e73e2..600ae5366 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -537,8 +537,7 @@ find_transfers (void *cls)
current_batch_size = 0;
hh = TALER_BANK_credit_history (ctx,
- wa_pos->account.details.x_taler_bank.
- account_base_url,
+ wa_pos->auth.wire_gateway_url,
&wa_pos->auth,
last_row_off,
batch_size,
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index aace9402f..c9843f2fc 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -42,7 +42,12 @@ enum TALER_BANK_AuthenticationMethod
/**
* Basic authentication with cleartext username and password.
*/
- TALER_BANK_AUTH_BASIC
+ TALER_BANK_AUTH_BASIC,
+
+ /**
+ * The authentication data refers to a fakebank.
+ */
+ TALER_BANK_AUTH_FAKEBANK,
};
@@ -53,6 +58,12 @@ struct TALER_BANK_AuthenticationData
{
/**
+ * Base URL we use to talk to the wire gateway,
+ * which talks to the bank for us.
+ */
+ char *wire_gateway_url;
+
+ /**
* Which authentication method should we use?
*/
enum TALER_BANK_AuthenticationMethod method;
@@ -79,6 +90,14 @@ struct TALER_BANK_AuthenticationData
char *password;
} basic;
+ struct
+ {
+ /**
+ * Port that the fakebank runs on.
+ */
+ uint16_t fb_port;
+ } fakebank;
+
} details;
};
diff --git a/src/lib/test_auditor_api.conf b/src/lib/test_auditor_api.conf
index 5c6ee031f..8133ce481 100644
--- a/src/lib/test_auditor_api.conf
+++ b/src/lib/test_auditor_api.conf
@@ -71,6 +71,7 @@ METHOD = x-taler-bank
[account-2]
# What is the bank account (with the "Taler Bank" demo system)?
URL = "payto://x-taler-bank/localhost:8082/2"
+FAKEBANK_PORT = 8082
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
diff --git a/src/lib/test_bank_api.c b/src/lib/test_bank_api.c
index 5ebf76370..f47123975 100644
--- a/src/lib/test_bank_api.c
+++ b/src/lib/test_bank_api.c
@@ -140,7 +140,7 @@ main (int argc,
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
- "account-1",
+ "account-2",
&bc))
{
GNUNET_break (0);
diff --git a/src/lib/test_bank_api.conf b/src/lib/test_bank_api.conf
index 906b95fc5..97fe09c98 100644
--- a/src/lib/test_bank_api.conf
+++ b/src/lib/test_bank_api.conf
@@ -1,8 +1,9 @@
[taler]
currency = KUDOS
-[account-1]
-URL = payto://x-taler-bank/localhost:8081/1
+[account-2]
+URL = payto://x-taler-bank/localhost:8081/2
+FAKEBANK_PORT = 8081
[bank]
SERVE = http
diff --git a/src/lib/testing_api_helpers_bank.c b/src/lib/testing_api_helpers_bank.c
index f0ba9f99f..342137c9c 100644
--- a/src/lib/testing_api_helpers_bank.c
+++ b/src/lib/testing_api_helpers_bank.c
@@ -380,11 +380,30 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
{
struct GNUNET_CONFIGURATION_Handle *cfg;
char *payto_url;
+ uint16_t fakebank_port;
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
config_filename))
return GNUNET_SYSERR;
+
+ if (GNUNET_OK !=
+ TALER_BANK_auth_parse_cfg (cfg,
+ "account-" EXCHANGE_ACCOUNT_NAME,
+ &bc->exchange_auth))
+ {
+ GNUNET_break (0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
+
+ GNUNET_assert (TALER_BANK_AUTH_FAKEBANK == bc->exchange_auth.method);
+
+ fakebank_port = bc->exchange_auth.details.fakebank.fb_port;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Fakebank port from config: %u\n",
+ (unsigned int) fakebank_port);
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
config_section,
@@ -418,10 +437,16 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
GNUNET_free (payto_url);
return GNUNET_SYSERR;
}
- bc->exchange_account_url
- = TALER_xtalerbank_account_url_from_payto (payto_url);
+ GNUNET_asprintf (&bc->exchange_account_url,
+ "http://localhost:%u/%s/",
+ fakebank_port,
+ EXCHANGE_ACCOUNT_NAME);
GNUNET_assert (NULL != bc->exchange_account_url);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
+ bc->exchange_account_url);
GNUNET_free (payto_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 = TALER_payto_xtalerbank_make (bc->bank_url, "2");
bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");