-generate 404 on non-existing accounts for fakebank, use payto://-URIs with receiver-name in tests

This commit is contained in:
Christian Grothoff 2022-05-30 16:31:24 +02:00
parent 7f902c0fc9
commit 7b25787a4b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
49 changed files with 331 additions and 245 deletions

View File

@ -11,6 +11,7 @@ Arguments mandatory for long options are also mandatory for short options.
-h, --help print this help
-i, --internal perform checks only applicable for
exchange-internal audits
-I, --ignore-not-found ignore problems with the exchange bank account not existing
-L, --log=LOGLEVEL configure logging to use LOGLEVEL
-l, --logfile=FILENAME configure logging to write logs to FILENAME
-m, --exchange-key=KEY public key of the exchange (Crockford base32
@ -28,7 +29,7 @@ EOF
function optcheck {
TEMP=`getopt -o c:hiL:l:m:T:v --long config:,help,internal,log:,logfile:exchange-key:,timetravel:,version -n 'taler-auditor' -- "$@"`
TEMP=`getopt -o c:hiIL:l:m:T:v --long config:,help,internal,ignore-not-found,log:,logfile:exchange-key:,timetravel:,version -n 'taler-auditor' -- "$@"`
if [ $? != 0 ] ;
then
@ -43,6 +44,7 @@ DEBUG=false
MEMORY=
DEBUGFILE=
JAVA_MISC_OPT=
INF=
while true; do
case "$1" in
-c | --config ) shift 2 ;;
@ -51,6 +53,7 @@ while true; do
exit 0
;;
-i | --internal ) shift ;;
-I | --ignore-not-found ) INF="-I"; shift ;;
-L | --log ) shift 2;;
-l | --logfile ) shift ;;
-m | --exchange-key ) shift 2 ;;
@ -74,16 +77,20 @@ done
}
# End of function 'optcheck'
optcheck "$@"
# Remove "-I" from $@ if present, store result in $ARGS.
ARGS=("$@")
ARGS=(${ARGS[@]/$INF})
DIR=`mktemp -d reportXXXXXX`
for n in aggregation coins deposits reserves wire
for n in aggregation coins deposits reserves
do
taler-helper-auditor-$n "$@" > ${DIR}/$n.json
taler-helper-auditor-$n ${ARGS[*]} > ${DIR}/$n.json
done
taler-helper-auditor-wire $INF ${ARGS[*]} > ${DIR}/wire.json
taler-helper-auditor-render.py \
${DIR}/aggregation.json \
${DIR}/coins.json \

View File

@ -304,6 +304,12 @@ static struct GNUNET_CURL_RescheduleContext *rc;
*/
static int internal_checks;
/**
* Should we ignore if the bank does not know our bank
* account?
*/
static int ignore_account_404;
/* ***************************** Shutdown **************************** */
/**
@ -1166,7 +1172,7 @@ check_rc_matches (void *cls,
* @param value the `struct ReserveOutInfo` to report
* @return #GNUNET_OK
*/
static int
static enum GNUNET_GenericReturnValue
complain_out_not_found (void *cls,
const struct GNUNET_HashCode *key,
void *value)
@ -1275,7 +1281,7 @@ check_exchange_wire_out (struct WireAccount *wa)
* @param json original response in JSON format
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/
static int
static enum GNUNET_GenericReturnValue
history_debit_cb (void *cls,
unsigned int http_status_code,
enum TALER_ErrorCode ec,
@ -1291,7 +1297,9 @@ history_debit_cb (void *cls,
if (NULL == details)
{
wa->dhh = NULL;
if (TALER_EC_NONE != ec)
if ( (TALER_EC_NONE != ec) &&
( (! ignore_account_404) ||
(MHD_HTTP_NOT_FOUND != http_status_code) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching debit history of account %s: %u/%u!\n",
@ -1584,7 +1592,9 @@ history_credit_cb (void *cls,
if (NULL == details)
{
wa->chh = NULL;
if (TALER_EC_NONE != ec)
if ( (TALER_EC_NONE != ec) &&
( (! ignore_account_404) ||
(MHD_HTTP_NOT_FOUND != http_status) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching credit history of account %s: %u/%s!\n",
@ -2177,6 +2187,10 @@ main (int argc,
"internal",
"perform checks only applicable for exchange-internal audits",
&internal_checks),
GNUNET_GETOPT_option_flag ('I',
"ignore-not-found",
"continue, even if the bank account of the exchange was not found",
&ignore_account_404),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",

View File

@ -159,6 +159,11 @@ struct Account
*/
char *account_name;
/**
* Receiver name for payto:// URIs.
*/
char *receiver_name;
/**
* Current account balance.
*/
@ -618,11 +623,14 @@ lp_expiration_thread (void *cls)
*
* @param[in,out] h bank to lookup account at
* @param name account name to resolve
* @return account handle (never NULL)
* @param receiver_name receiver name in payto:// URI,
* NULL if the account must already exist
* @return account handle, NULL if account does not yet exist
*/
static struct Account *
lookup_account (struct TALER_FAKEBANK_Handle *h,
const char *name)
const char *name,
const char *receiver_name)
{
struct GNUNET_HashCode hc;
size_t slen;
@ -641,8 +649,15 @@ lookup_account (struct TALER_FAKEBANK_Handle *h,
&hc);
if (NULL == account)
{
if (NULL == receiver_name)
{
GNUNET_assert (0 ==
pthread_mutex_unlock (&h->accounts_lock));
return NULL;
}
account = GNUNET_new (struct Account);
account->account_name = GNUNET_strdup (name);
account->receiver_name = GNUNET_strdup (receiver_name);
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (h->currency,
&account->balance));
@ -724,9 +739,31 @@ TALER_FAKEBANK_check_debit (struct TALER_FAKEBANK_Handle *h,
strcasecmp (want_amount->currency,
h->currency));
debit_account = lookup_account (h,
want_debit);
want_debit,
NULL);
credit_account = lookup_account (h,
want_credit);
want_credit,
NULL);
if (NULL == debit_account)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted: %s->%s (%s) from exchange %s (DEBIT), but debit account does not even exist!\n",
want_debit,
want_credit,
TALER_amount2s (want_amount),
exchange_base_url);
return GNUNET_SYSERR;
}
if (NULL == credit_account)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted: %s->%s (%s) from exchange %s (DEBIT), but credit account does not even exist!\n",
want_debit,
want_credit,
TALER_amount2s (want_amount),
exchange_base_url);
return GNUNET_SYSERR;
}
for (struct Transaction *t = debit_account->out_tail;
NULL != t;
t = t->prev_out)
@ -770,9 +807,31 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h,
GNUNET_assert (0 == strcasecmp (want_amount->currency,
h->currency));
debit_account = lookup_account (h,
want_debit);
want_debit,
NULL);
credit_account = lookup_account (h,
want_credit);
want_credit,
NULL);
if (NULL == debit_account)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted:\n%s -> %s (%s) with subject %s (CREDIT) but debit account is unknown.\n",
want_debit,
want_credit,
TALER_amount2s (want_amount),
TALER_B2S (reserve_pub));
return GNUNET_SYSERR;
}
if (NULL == credit_account)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted:\n%s -> %s (%s) with subject %s (CREDIT) but credit account is unknown.\n",
want_debit,
want_credit,
TALER_amount2s (want_amount),
TALER_B2S (reserve_pub));
return GNUNET_SYSERR;
}
for (struct Transaction *t = credit_account->in_tail;
NULL != t;
t = t->prev_in)
@ -1012,8 +1071,10 @@ make_transfer (
url_len = strlen (exchange_base_url);
GNUNET_assert (url_len < MAX_URL_LEN);
debit_acc = lookup_account (h,
debit_account,
debit_account);
credit_acc = lookup_account (h,
credit_account,
credit_account);
if (NULL != request_uid)
{
@ -1132,10 +1193,11 @@ make_admin_transfer (
credit_account,
strlen ("payto://")));
debit_acc = lookup_account (h,
debit_account,
debit_account);
credit_acc = lookup_account (h,
credit_account,
credit_account);
GNUNET_assert (0 ==
pthread_mutex_lock (&h->rpubs_lock));
t = GNUNET_CONTAINER_multipeermap_get (h->rpubs,
@ -1217,6 +1279,7 @@ free_account (void *cls,
(void) key;
GNUNET_assert (NULL == account->lp_head);
GNUNET_free (account->account_name);
GNUNET_free (account->receiver_name);
GNUNET_free (account);
return GNUNET_OK;
}
@ -1567,7 +1630,7 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
return (GNUNET_NO == ret) ? MHD_YES : MHD_NO;
}
{
int ret;
enum GNUNET_GenericReturnValue ret;
credit = TALER_xtalerbank_account_from_payto (credit_account);
if (NULL == credit)
@ -1961,10 +2024,19 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
if (&special_ptr == *con_cls)
ha.lp_timeout = GNUNET_TIME_UNIT_ZERO;
acc = lookup_account (h,
account,
NULL);
if (NULL == acc)
{
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_BANK_UNKNOWN_ACCOUNT,
account);
}
GNUNET_asprintf (&debit_payto,
"payto://x-taler-bank/localhost/%s",
account);
"payto://x-taler-bank/localhost/%s?receiver-name=%s",
account,
acc->receiver_name);
history = json_array ();
if (NULL == history)
{
@ -2085,8 +2157,10 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
continue;
}
GNUNET_asprintf (&credit_payto,
"payto://x-taler-bank/localhost/%s",
pos->credit_account->account_name);
"payto://x-taler-bank/localhost/%s?receiver-name=%s",
pos->credit_account->account_name,
pos->credit_account->receiver_name);
trans = GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row_id",
pos->row_id),
@ -2180,12 +2254,22 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
ha.lp_timeout = GNUNET_TIME_UNIT_ZERO;
*con_cls = &special_ptr;
acc = lookup_account (h,
account,
NULL);
if (NULL == acc)
{
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_BANK_UNKNOWN_ACCOUNT,
account);
}
history = json_array ();
GNUNET_assert (NULL != history);
GNUNET_asprintf (&credit_payto,
"payto://x-taler-bank/localhost/%s",
account);
"payto://x-taler-bank/localhost/%s?receiver-name=%s",
account,
acc->receiver_name);
GNUNET_assert (0 ==
pthread_mutex_lock (&h->big_lock));
if (! ha.have_start)
@ -2289,8 +2373,9 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
continue;
}
GNUNET_asprintf (&debit_payto,
"payto://x-taler-bank/localhost/%s",
pos->debit_account->account_name);
"payto://x-taler-bank/localhost/%s?receiver-name=%s",
pos->debit_account->account_name,
pos->debit_account->receiver_name);
trans = GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row_id",
pos->row_id),

View File

@ -49,7 +49,7 @@ echo -n "Making wire transfer to exchange ..."
taler-exchange-wire-gateway-client \
-b http://localhost:8899/exchange/ \
-S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \
-D payto://x-taler-bank/localhost:8899/user \
-D payto://x-taler-bank/localhost:8899/user?receiver-name=user \
-a TESTKUDOS:4 > /dev/null
echo " OK"
@ -64,8 +64,9 @@ echo -n "Making wire transfer from exchange..."
./taler-exchange-wire-gateway-client \
-b http://localhost:8899/exchange/ \
-S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \
-C payto://x-taler-bank/localhost:8899/merchant \
-a TESTKUDOS:2 > /dev/null
-C payto://x-taler-bank/localhost:8899/merchant?receiver-name=merchant \
-a TESTKUDOS:2 \
-L DEBUG > /dev/null
echo " OK"

View File

@ -623,8 +623,9 @@ history_cb (void *cls,
if (NULL == details)
{
wa->hh = NULL;
if ( (TALER_EC_NONE != ec) ||
(MHD_HTTP_OK != http_status) )
if ( (MHD_HTTP_NO_CONTENT != http_status) &&
( (TALER_EC_NONE != ec) ||
(MHD_HTTP_OK != http_status) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error fetching history: %s (%u)\n",

View File

@ -2756,7 +2756,6 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
op (contract_terms, const json_t) \
op (wire_details, const json_t) \
op (exchange_keys, const json_t) \
op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \
op (exchange_url, const char *) \
op (exchange_bank_account_url, const char *) \
op (taler_uri, const char *) \
@ -2791,6 +2790,7 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
op (age_commitment, const struct TALER_AgeCommitment) \
op (age_commitment_proof, const struct TALER_AgeCommitmentProof) \
op (h_age_commitment, const struct TALER_AgeCommitmentHash) \
op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \
op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \
op (exchange_wd_value, const struct TALER_ExchangeWithdrawValues) \
op (coin_priv, const struct TALER_CoinSpendPrivateKeyP) \

View File

@ -385,6 +385,16 @@ char *
TALER_xtalerbank_account_from_payto (const char *payto);
/**
* Obtain the receiver name from a payto URL.
*
* @param payto an x-taler-bank payto URL
* @return only the receiver name from the @a payto URL, NULL if not an x-taler-bank payto URL
*/
char *
TALER_payto_get_receiver_name (const char *payto);
/**
* Extract the subject value from the URI parameters.
*

View File

@ -139,7 +139,6 @@ check_PROGRAMS = \
test_auditor_api_version_rsa \
test_auditor_api_version_cs \
test_bank_api_with_fakebank \
test_bank_api_with_pybank \
test_bank_api_with_nexus \
test_exchange_api_cs \
test_exchange_api_rsa \
@ -158,8 +157,7 @@ if HAVE_TWISTER
check_PROGRAMS += \
test_exchange_api_twisted_cs \
test_exchange_api_twisted_rsa \
test_bank_api_with_fakebank_twisted \
test_bank_api_with_pybank_twisted
test_bank_api_with_fakebank_twisted
endif
@ -246,15 +244,6 @@ test_bank_api_with_fakebank_LDADD = \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB)
test_bank_api_with_pybank_SOURCES = \
test_bank_api.c
test_bank_api_with_pybank_LDADD = \
libtalertesting.la \
$(top_builddir)/src/lib/libtalerexchange.la \
-lgnunetutil \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB)
test_exchange_api_cs_SOURCES = \
test_exchange_api.c
test_exchange_api_cs_LDADD = \
@ -523,23 +512,6 @@ test_bank_api_with_fakebank_twisted_LDADD = \
-ljansson \
$(XLIB)
test_bank_api_with_pybank_twisted_SOURCES = \
test_bank_api_twisted.c
test_bank_api_with_pybank_twisted_LDADD = \
libtalertesting.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(top_builddir)/src/bank-lib/libtalerfakebank.la \
$(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/json/libtalerjson.la \
libtalertwistertesting.la \
-lgnunettesting \
-lgnunetjson \
-lgnunetcurl \
-lgnunetutil \
-ljansson \
$(XLIB)
test_kyc_api_SOURCES = \
test_kyc_api.c
test_kyc_api_LDADD = \
@ -565,8 +537,6 @@ EXTRA_DIST = \
test_auditor_api_expire_reserve_now-rsa.conf \
test_bank_api_fakebank.conf \
test_bank_api_fakebank_twisted.conf \
test_bank_api_pybank.conf \
test_bank_api_pybank_twisted.conf \
test_exchange_api_home/.config/taler/account-2.json \
test_exchange_api_home/.local/share/taler/exchange-offline/master.priv \
test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \

View File

@ -69,7 +69,7 @@ LEGAL_RESERVE_EXPIRATION_TIME = 7 years
[exchange-account-1]
# What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -57,7 +57,7 @@ PORT = 8083
[exchange-account-1]
# What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -56,7 +56,7 @@ CONFIG = "postgres:///talercheck"
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
@ -68,7 +68,7 @@ HTTP_PORT = 8082
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -57,7 +57,7 @@ CONFIG = "postgres:///talercheck"
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
@ -69,7 +69,7 @@ HTTP_PORT = 8082
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -657,7 +657,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -4,7 +4,7 @@
currency = KUDOS
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/2
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8081/2/"

View File

@ -28,10 +28,10 @@ http_port = 8081
database = postgres:///talercheck
[exchange-account-1]
PAYTO_URI = payto://x-taler-bank/localhost:8081/1
PAYTO_URI = "payto://x-taler-bank/localhost:8081/1?receiver-name=1"
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost:8081/2
PAYTO_URI = "payto://x-taler-bank/localhost:8081/2?receiver-name=2"
[auditor]
BASE_URL = "http://localhost:8083/"

View File

@ -1,21 +0,0 @@
# This file is in the public domain.
[taler]
currency = KUDOS
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/Exchange
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8081/taler-wire-gateway/Exchange/"
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
[bank]
SERVE = http
HTTP_PORT = 8081
DATABASE = postgres:///talercheck
[auditor]
BASE_URL = "http://localhost:8083/"

View File

@ -1,43 +0,0 @@
[twister]
# HTTP listen port for twister
HTTP_PORT = 8888
SERVE = tcp
# HTTP Destination for twister. The test-Webserver needs
# to listen on the port used here. Note: no trailing '/'!
DESTINATION_BASE_URL = "http://localhost:8081"
# Control port for TCP
# PORT = 8889
HOSTNAME = localhost
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
# Control port for UNIX
UNIXPATH = /tmp/taler-service-twister.sock
UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES
[auditor]
BASE_URL = "http://localhost:8083/"
[taler]
currency = KUDOS
[bank]
serve = http
http_port = 8081
database = postgres:///talercheck
[exchange-account-1]
PAYTO_URI = payto://x-taler-bank/localhost/1
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/Exchange
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8888/taler-wire-gateway/Exchange/"
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x

View File

@ -64,7 +64,7 @@ CONFIG = "postgres:///talercheck"
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
# ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
@ -72,7 +72,7 @@ WIRE_GATEWAY_URL = "http://localhost:9081/42/"
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -65,7 +65,7 @@ CONFIG = "postgres:///talercheck"
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
# ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
@ -73,7 +73,7 @@ WIRE_GATEWAY_URL = "http://localhost:9081/42/"
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -1170,7 +1170,7 @@ run (void *cls,
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
config_file),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -56,13 +56,13 @@ CONFIG = "postgres:///talercheck"
CONFIG = "postgres:///talercheck"
[exchange-account-1]
PAYTO_URI = payto://x-taler-bank/localhost/42
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9082/42/"
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/2
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -56,13 +56,13 @@ CONFIG = "postgres:///talercheck"
CONFIG = "postgres:///talercheck"
[exchange-account-1]
PAYTO_URI = payto://x-taler-bank/localhost/42
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9082/42/"
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/2
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -63,7 +63,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",

View File

@ -64,7 +64,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -67,7 +67,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -48,14 +48,14 @@ CONFIG = "postgres:///talercheck"
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9081/42/"
WIRE_GATEWAY_AUTH_METHOD = NONE
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/2
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -48,14 +48,14 @@ CONFIG = "postgres:///talercheck"
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9081/42/"
WIRE_GATEWAY_AUTH_METHOD = NONE
[exchange-account-2]
PAYTO_URI = payto://x-taler-bank/localhost/2
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -243,7 +243,7 @@ run (void *cls,
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -117,31 +117,31 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/42",
"payto://x-taler-bank/localhost/42?receiver-name=42",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account-idempotent",
"payto://x-taler-bank/localhost/42",
"payto://x-taler-bank/localhost/42?receiver-name=42",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account-another",
"payto://x-taler-bank/localhost/43",
"payto://x-taler-bank/localhost/43?receiver-name=43",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account-bad-signature",
"payto://x-taler-bank/localhost/44",
"payto://x-taler-bank/localhost/44?receiver-name=44",
MHD_HTTP_FORBIDDEN,
true),
TALER_TESTING_cmd_wire_del ("del-wire-account-not-found",
"payto://x-taler-bank/localhost/44",
"payto://x-taler-bank/localhost/44?receiver-name=44",
MHD_HTTP_NOT_FOUND,
false),
TALER_TESTING_cmd_wire_del ("del-wire-account-bad-signature",
"payto://x-taler-bank/localhost/43",
"payto://x-taler-bank/localhost/43?receiver-name=43",
MHD_HTTP_FORBIDDEN,
true),
TALER_TESTING_cmd_wire_del ("del-wire-account-ok",
"payto://x-taler-bank/localhost/43",
"payto://x-taler-bank/localhost/43?receiver-name=43",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",

View File

@ -365,7 +365,7 @@ run (void *cls,
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
config_file),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees",

View File

@ -216,7 +216,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -74,7 +74,7 @@ CONFIG = "postgres:///talercheck"
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42"
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
@ -86,7 +86,7 @@ HTTP_PORT = 8082
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2"
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES

View File

@ -187,17 +187,17 @@ run (void *cls,
ec.exchange_url,
"EUR:0.89",
bc.exchange_payto,
"payto://x-taler-bank/localhost/4"),
"payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
ec.exchange_url,
"EUR:0.89",
bc.exchange_payto,
"payto://x-taler-bank/localhost/4"),
"payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
ec.exchange_url,
"EUR:0.89",
bc.exchange_payto,
"payto://x-taler-bank/localhost/5"),
"payto://x-taler-bank/localhost/5?receiver-name=5"),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
/* checking that aggregator waits for the deadline. */

View File

@ -91,7 +91,7 @@ run (void *cls,
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",

View File

@ -68,6 +68,7 @@ auditor_run (void *cls,
"taler-auditor",
"taler-auditor",
"-c", ks->config_filename,
"-I",
NULL);
if (NULL == ks->auditor_proc)
{

View File

@ -433,10 +433,12 @@ admin_add_incoming_traits (void *cls,
TALER_TESTING_make_trait_exchange_bank_account_url (
&fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
TALER_TESTING_make_trait_timestamp (0,
&fts->timestamp),
TALER_TESTING_make_trait_reserve_priv (&fts->reserve_priv),
TALER_TESTING_make_trait_reserve_pub (&fts->reserve_pub),
TALER_TESTING_make_trait_reserve_history (&fts->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&fts->reserve_history),
TALER_TESTING_trait_end ()
};
@ -457,7 +459,8 @@ admin_add_incoming_traits (void *cls,
TALER_TESTING_make_trait_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
TALER_TESTING_make_trait_reserve_pub (&fts->reserve_pub),
TALER_TESTING_make_trait_reserve_history (&fts->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&fts->reserve_history),
TALER_TESTING_trait_end ()
};

View File

@ -311,7 +311,7 @@ build_history (struct TALER_TESTING_Interpreter *is,
* @param details the expected transaction details.
* @return #GNUNET_OK if the transaction is what we expect.
*/
static int
static enum GNUNET_GenericReturnValue
check_result (struct History *h,
unsigned int total,
unsigned int off,
@ -389,6 +389,13 @@ history_cb (void *cls,
if (NULL == details)
{
hs->hh = NULL;
if ( (MHD_HTTP_NOT_FOUND == http_status) &&
(0 == hs->total) )
{
/* not found is OK for empty history */
TALER_TESTING_interpreter_next (is);
return GNUNET_OK;
}
if ( (hs->results_obtained != hs->total) ||
(hs->failed) ||
(MHD_HTTP_NO_CONTENT != http_status) )
@ -422,7 +429,8 @@ history_cb (void *cls,
}
/* check current element */
if (GNUNET_OK != check_result (hs->h,
if (GNUNET_OK !=
check_result (hs->h,
hs->total,
hs->results_obtained,
details))
@ -439,6 +447,8 @@ history_cb (void *cls,
if (NULL != acc)
free (acc);
hs->failed = true;
hs->hh = NULL;
TALER_TESTING_interpreter_fail (is);
return GNUNET_SYSERR;
}
hs->results_obtained++;

View File

@ -391,6 +391,13 @@ history_cb (void *cls,
if (NULL == details)
{
hs->hh = NULL;
if ( (MHD_HTTP_NOT_FOUND == http_status) &&
(0 == hs->total) )
{
/* not found is OK for empty history */
TALER_TESTING_interpreter_next (is);
return GNUNET_OK;
}
if ( (hs->results_obtained != hs->total) ||
(GNUNET_YES == hs->failed) ||
(MHD_HTTP_NO_CONTENT != http_status) )
@ -424,7 +431,8 @@ history_cb (void *cls,
}
/* check current element */
if (GNUNET_OK != check_result (hs->h,
if (GNUNET_OK !=
check_result (hs->h,
hs->total,
hs->results_obtained,
details))
@ -441,6 +449,8 @@ history_cb (void *cls,
if (NULL != acc)
free (acc);
hs->failed = GNUNET_YES;
hs->hh = NULL;
TALER_TESTING_interpreter_fail (is);
return GNUNET_SYSERR;
}
hs->results_obtained++;

View File

@ -87,8 +87,6 @@ struct CoinState
/**
* Reserve history entry that corresponds to this coin.
* Will be of type #TALER_EXCHANGE_RTT_WITHDRAWAL.
*
* FIXME: how to export one per coin?
*/
struct TALER_EXCHANGE_ReserveHistoryEntry reserve_history;
@ -401,8 +399,8 @@ batch_withdraw_traits (void *cls,
struct CoinState *cs = &ws->coins[index];
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
// FIXME: bug!
TALER_TESTING_make_trait_reserve_history (&cs->reserve_history),
TALER_TESTING_make_trait_reserve_history (index,
&cs->reserve_history),
TALER_TESTING_make_trait_coin_priv (index,
&cs->coin_priv),
TALER_TESTING_make_trait_planchet_secrets (index,

View File

@ -169,7 +169,8 @@ closer_traits (void *cls,
struct TALER_TESTING_Trait xtraits[] = {
TALER_TESTING_make_trait_process (&as->closer_proc),
TALER_TESTING_make_trait_reserve_pub (&as->reserve_pub),
TALER_TESTING_make_trait_reserve_history (&as->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&as->reserve_history),
TALER_TESTING_trait_end ()
};

View File

@ -230,7 +230,8 @@ insert_deposit_run (void *cls,
TALER_blinded_denom_sig_free (&bds);
}
GNUNET_asprintf (&deposit.receiver_wire_account,
"payto://x-taler-bank/localhost/%s",
"payto://x-taler-bank/localhost/%s?receiver-name=%s",
ids->merchant_account,
ids->merchant_account);
memset (&deposit.wire_salt,
46,

View File

@ -396,7 +396,8 @@ deposit_traits (void *cls,
struct PurseDepositState *ds = cls;
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&ds->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&ds->reserve_history),
TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
TALER_TESTING_trait_end ()

View File

@ -350,7 +350,8 @@ merge_traits (void *cls,
struct PurseMergeState *ds = cls;
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&ds->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&ds->reserve_history),
TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
TALER_TESTING_make_trait_timestamp (0,
&ds->merge_timestamp),

View File

@ -328,7 +328,8 @@ recoup_traits (void *cls,
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_reserve_pub (&ps->reserve_pub),
TALER_TESTING_make_trait_reserve_history (&ps->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&ps->reserve_history),
TALER_TESTING_trait_end ()
};

View File

@ -95,7 +95,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_TESTING_Command *cmd,
unsigned int history_length,
const struct TALER_EXCHANGE_ReserveHistoryEntry *history,
int *found)
bool *found)
{
if (TALER_TESTING_cmd_is_batch (cmd))
{
@ -134,7 +134,6 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
else
{
const struct TALER_ReservePublicKeyP *rp;
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd,
@ -144,11 +143,17 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
GNUNET_memcmp (rp,
reserve_pub))
return GNUNET_OK; /* command affects some _other_ reserve */
for (unsigned int j = 0; true; j++)
{
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_history (cmd,
j,
&he))
{
/* NOTE: only for debugging... */
if (0 == j)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Command `%s' has the reserve_pub trait, but does not reserve history trait\n",
cmd->label);
@ -162,16 +167,18 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
TALER_TESTING_history_entry_cmp (he,
&history[i]))
{
found[i] = GNUNET_YES;
found[i] = true;
return GNUNET_OK;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Command `%s' reserve history entry not found\n",
cmd->label);
"Command `%s' reserve history entry #%u not found\n",
cmd->label,
j);
return GNUNET_SYSERR;
}
}
}
/**
@ -237,7 +244,7 @@ reserve_history_cb (void *cls,
return;
}
{
int found[rs->details.ok.history_len];
bool found[rs->details.ok.history_len];
memset (found,
0,
@ -342,7 +349,8 @@ history_traits (void *cls,
struct HistoryState *hs = cls;
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&hs->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&hs->reserve_history),
TALER_TESTING_trait_end ()
};

View File

@ -126,7 +126,6 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
else
{
const struct TALER_ReservePublicKeyP *rp;
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_pub (cmd,
@ -136,8 +135,13 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
GNUNET_memcmp (rp,
reserve_pub))
return GNUNET_OK; /* command affects some _other_ reserve */
for (unsigned int j = 0; true; j++)
{
const struct TALER_EXCHANGE_ReserveHistoryEntry *he;
if (GNUNET_OK !=
TALER_TESTING_get_trait_reserve_history (cmd,
j,
&he))
{
/* NOTE: only for debugging... */
@ -154,16 +158,18 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
TALER_TESTING_history_entry_cmp (he,
&history[i]))
{
found[i] = GNUNET_YES;
found[i] = true;
return GNUNET_OK;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Command `%s' reserve history entry not found\n",
cmd->label);
"Command `%s' reserve history entry #%u not found\n",
cmd->label,
j);
return GNUNET_SYSERR;
}
}
}
/**

View File

@ -521,7 +521,8 @@ withdraw_traits (void *cls,
struct WithdrawState *ws = cls;
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&ws->reserve_history),
TALER_TESTING_make_trait_reserve_history (0,
&ws->reserve_history),
TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
&ws->coin_priv),
TALER_TESTING_make_trait_planchet_secret (&ws->ps),

View File

@ -563,8 +563,8 @@ TALER_TESTING_prepare_bank (const char *config_filename,
}
GNUNET_CONFIGURATION_destroy (cfg);
bc->exchange_payto = exchange_payto_uri;
bc->user42_payto = "payto://x-taler-bank/localhost/42";
bc->user43_payto = "payto://x-taler-bank/localhost/43";
bc->user42_payto = "payto://x-taler-bank/localhost/42?receiver-name=42";
bc->user43_payto = "payto://x-taler-bank/localhost/43?receiver-name=43";
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Using pybank %s on port %u\n",
bc->exchange_auth.wire_gateway_url,
@ -655,8 +655,8 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
* don't have any auth. */
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
bc->exchange_payto = exchange_payto_uri;
bc->user42_payto = "payto://x-taler-bank/localhost/42";
bc->user43_payto = "payto://x-taler-bank/localhost/43";
bc->user42_payto = "payto://x-taler-bank/localhost/42?receiver-name=42";
bc->user43_payto = "payto://x-taler-bank/localhost/43?receiver-name=43";
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",
bc->exchange_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "user42_payto: %s\n",

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2019-2021 Taler Systems SA
Copyright (C) 2019-2022 Taler Systems SA
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
@ -233,6 +233,26 @@ TALER_payto_validate (const char *payto_uri)
}
char *
TALER_payto_get_receiver_name (const char *payto)
{
char *err;
err = TALER_payto_validate (payto);
if (NULL != err)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Invalid payto://-URI `%s': %s\n",
payto,
err);
GNUNET_free (err);
return NULL;
}
return payto_get_key (payto,
"receiver-name=");
}
void
TALER_payto_hash (const char *payto,
struct TALER_PaytoHashP *h_payto)