add -i option to taler-exchange-keycheck
This commit is contained in:
parent
59a5b1ceb8
commit
bab24a451a
@ -67,6 +67,20 @@ taler_exchange_dbinit_CPPFLAGS = \
|
|||||||
$(POSTGRESQL_CPPFLAGS)
|
$(POSTGRESQL_CPPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Testcases
|
||||||
|
|
||||||
|
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
|
||||||
|
|
||||||
|
check_SCRIPTS = \
|
||||||
|
test_taler_exchange_keyup.sh
|
||||||
|
|
||||||
|
TESTS = \
|
||||||
|
$(check_SCRIPTS)
|
||||||
|
|
||||||
|
# Distribution
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(pkgcfg_DATA) \
|
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
|
||||||
key-helper.c
|
test_taler_exchange_httpd.conf \
|
||||||
|
$(check_SCRIPTS) \
|
||||||
|
$(pkgcfg_DATA)
|
||||||
|
@ -41,6 +41,12 @@ static const struct GNUNET_CONFIGURATION_Handle *kcfg;
|
|||||||
*/
|
*/
|
||||||
static int global_ret;
|
static int global_ret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option -i used to print full denomination key hashes for
|
||||||
|
* denominations of certain amounts.
|
||||||
|
*/
|
||||||
|
static struct TALER_Amount print_dk_amount;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called on each signing key.
|
* Function called on each signing key.
|
||||||
@ -136,6 +142,7 @@ denomkeys_iter (void *cls,
|
|||||||
TALER_EXCHANGEDB_DenominationKey *dki)
|
TALER_EXCHANGEDB_DenominationKey *dki)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
|
struct TALER_Amount value;
|
||||||
|
|
||||||
(void) cls;
|
(void) cls;
|
||||||
if (ntohl (dki->issue.properties.purpose.size) !=
|
if (ntohl (dki->issue.properties.purpose.size) !=
|
||||||
@ -187,6 +194,29 @@ denomkeys_iter (void *cls,
|
|||||||
"Denomination key `%s' (%s) is valid\n",
|
"Denomination key `%s' (%s) is valid\n",
|
||||||
alias,
|
alias,
|
||||||
GNUNET_h2s (&hc));
|
GNUNET_h2s (&hc));
|
||||||
|
TALER_amount_ntoh (&value,
|
||||||
|
&dki->issue.properties.value);
|
||||||
|
if ( (GNUNET_OK ==
|
||||||
|
TALER_amount_cmp_currency (&print_dk_amount,
|
||||||
|
&value)) &&
|
||||||
|
(0 ==
|
||||||
|
TALER_amount_cmp (&print_dk_amount,
|
||||||
|
&value)) )
|
||||||
|
{
|
||||||
|
char *dh;
|
||||||
|
struct GNUNET_TIME_Absolute start;
|
||||||
|
|
||||||
|
start = GNUNET_TIME_absolute_ntoh (dki->issue.properties.start);
|
||||||
|
dh = GNUNET_STRINGS_data_to_string_alloc (&dki->issue.properties.denom_hash,
|
||||||
|
sizeof (struct GNUNET_HashCode));
|
||||||
|
/* output start time first for easy numeric sorting, then
|
||||||
|
the denomination hash, and finally the human-readable start time */
|
||||||
|
printf ("%020llu %s %s\n",
|
||||||
|
(unsigned long long) start.abs_value_us,
|
||||||
|
dh,
|
||||||
|
GNUNET_STRINGS_absolute_time_to_string (start));
|
||||||
|
GNUNET_free (dh);
|
||||||
|
}
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +305,11 @@ main (int argc,
|
|||||||
char *const *argv)
|
char *const *argv)
|
||||||
{
|
{
|
||||||
const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||||
|
TALER_getopt_get_amount ('i',
|
||||||
|
"denomination-info-hash",
|
||||||
|
"AMOUNT",
|
||||||
|
"print full denomination hashes of all denominations with the given AMOUNT value",
|
||||||
|
&print_dk_amount),
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
130
src/exchange-tools/test_taler_exchange_httpd.conf
Normal file
130
src/exchange-tools/test_taler_exchange_httpd.conf
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
[PATHS]
|
||||||
|
# Persistant data storage for the testcase
|
||||||
|
TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
||||||
|
|
||||||
|
[taler]
|
||||||
|
# Currency supported by the exchange (can only be one)
|
||||||
|
CURRENCY = EUR
|
||||||
|
CURRENCY_ROUND_UNIT = EUR:0.01
|
||||||
|
|
||||||
|
[exchange]
|
||||||
|
|
||||||
|
# Directory with our terms of service.
|
||||||
|
TERMS_DIR = ../../contrib/tos
|
||||||
|
|
||||||
|
# Etag / filename for the terms of service.
|
||||||
|
TERMS_ETAG = 0
|
||||||
|
|
||||||
|
|
||||||
|
# Directory with our privacy policy.
|
||||||
|
PRIVACY_DIR = ../../contrib/pp
|
||||||
|
|
||||||
|
# Etag / filename for the privacy policy.
|
||||||
|
PRIVACY_ETAG = 0
|
||||||
|
|
||||||
|
# MAX_REQUESTS = 2
|
||||||
|
# how long is one signkey valid?
|
||||||
|
SIGNKEY_DURATION = 4 weeks
|
||||||
|
|
||||||
|
# how long are the signatures with the signkey valid?
|
||||||
|
LEGAL_DURATION = 2 years
|
||||||
|
|
||||||
|
# how long do we generate denomination and signing keys
|
||||||
|
# ahead of time?
|
||||||
|
LOOKAHEAD_SIGN = 32 weeks 1 day
|
||||||
|
|
||||||
|
# how long do we provide to clients denomination and signing keys
|
||||||
|
# ahead of time?
|
||||||
|
LOOKAHEAD_PROVIDE = 4 weeks 1 day
|
||||||
|
|
||||||
|
# HTTP port the exchange listens to
|
||||||
|
PORT = 8081
|
||||||
|
|
||||||
|
# Master public key used to sign the exchange's various keys
|
||||||
|
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||||
|
|
||||||
|
# How to access our database
|
||||||
|
DB = postgres
|
||||||
|
|
||||||
|
|
||||||
|
[exchangedb]
|
||||||
|
# After how long do we close idle reserves? The exchange
|
||||||
|
# and the auditor must agree on this value. We currently
|
||||||
|
# expect it to be globally defined for the whole system,
|
||||||
|
# as there is no way for wallets to query this value. Thus,
|
||||||
|
# it is only configurable for testing, and should be treated
|
||||||
|
# as constant in production.
|
||||||
|
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
|
||||||
|
|
||||||
|
|
||||||
|
[exchangedb-postgres]
|
||||||
|
CONFIG = "postgres:///talercheck"
|
||||||
|
|
||||||
|
[exchange-account-1]
|
||||||
|
PAYTO_URI = "payto://x-taler-bank/localhost:8082/3"
|
||||||
|
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
|
||||||
|
ENABLE_DEBIT = YES
|
||||||
|
ENABLE_CREDIT = YES
|
||||||
|
TALER_BANK_AUTH_METHOD = NONE
|
||||||
|
|
||||||
|
|
||||||
|
# Wire fees are specified by wire method
|
||||||
|
[fees-x-taler-bank]
|
||||||
|
# Fees for the forseeable future...
|
||||||
|
# If you see this after 2018, update to match the next 10 years...
|
||||||
|
WIRE-FEE-2018 = EUR:0.01
|
||||||
|
WIRE-FEE-2019 = EUR:0.01
|
||||||
|
WIRE-FEE-2020 = EUR:0.01
|
||||||
|
WIRE-FEE-2021 = EUR:0.01
|
||||||
|
WIRE-FEE-2022 = EUR:0.01
|
||||||
|
WIRE-FEE-2023 = EUR:0.01
|
||||||
|
WIRE-FEE-2024 = EUR:0.01
|
||||||
|
WIRE-FEE-2025 = EUR:0.01
|
||||||
|
WIRE-FEE-2026 = EUR:0.01
|
||||||
|
WIRE-FEE-2027 = EUR:0.01
|
||||||
|
|
||||||
|
CLOSING-FEE-2018 = EUR:0.01
|
||||||
|
CLOSING-FEE-2019 = EUR:0.01
|
||||||
|
CLOSING-FEE-2020 = EUR:0.01
|
||||||
|
CLOSING-FEE-2021 = EUR:0.01
|
||||||
|
CLOSING-FEE-2022 = EUR:0.01
|
||||||
|
CLOSING-FEE-2023 = EUR:0.01
|
||||||
|
CLOSING-FEE-2024 = EUR:0.01
|
||||||
|
CLOSING-FEE-2025 = EUR:0.01
|
||||||
|
CLOSING-FEE-2026 = EUR:0.01
|
||||||
|
CLOSING-FEE-2027 = EUR:0.01
|
||||||
|
|
||||||
|
|
||||||
|
# Coins for the tests.
|
||||||
|
[coin_eur_ct_1]
|
||||||
|
value = EUR:0.01
|
||||||
|
duration_withdraw = 7 days
|
||||||
|
duration_spend = 2 years
|
||||||
|
duration_legal = 3 years
|
||||||
|
fee_withdraw = EUR:0.00
|
||||||
|
fee_deposit = EUR:0.00
|
||||||
|
fee_refresh = EUR:0.01
|
||||||
|
fee_refund = EUR:0.01
|
||||||
|
rsa_keysize = 1024
|
||||||
|
|
||||||
|
[coin_eur_ct_10]
|
||||||
|
value = EUR:0.10
|
||||||
|
duration_withdraw = 7 days
|
||||||
|
duration_spend = 2 years
|
||||||
|
duration_legal = 3 years
|
||||||
|
fee_withdraw = EUR:0.01
|
||||||
|
fee_deposit = EUR:0.01
|
||||||
|
fee_refresh = EUR:0.03
|
||||||
|
fee_refund = EUR:0.01
|
||||||
|
rsa_keysize = 1024
|
||||||
|
|
||||||
|
[coin_eur_1]
|
||||||
|
value = EUR:1
|
||||||
|
duration_withdraw = 7 days
|
||||||
|
duration_spend = 2 years
|
||||||
|
duration_legal = 3 years
|
||||||
|
fee_withdraw = EUR:0.01
|
||||||
|
fee_deposit = EUR:0.01
|
||||||
|
fee_refresh = EUR:0.03
|
||||||
|
fee_refund = EUR:0.01
|
||||||
|
rsa_keysize = 1024
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"salt": "AZPRFVJ58NM6M7J5CZQPJAH3EW5DYM52AEZ9Y1C1ER3W94QV8D8TQKF6CK8MYQRA9QMSKDQTGZ306ZS9GQ0M6R01CJ20KPP49WFDZK8",
|
||||||
|
"name": "The exchange",
|
||||||
|
"account_number": 3,
|
||||||
|
"bank_url": "http://localhost:8082/",
|
||||||
|
"type": "test",
|
||||||
|
"sig": "RPQXP9S4P8PQP7HEZQNRSZCT0ATNEP8GW0P5TPM34V5RX86FCD670V44R9NETSYDDKB8SZV7TKY9PAJYTY51D3VDWY9XXQ5BPFRXR28"
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>
|
85
src/exchange-tools/test_taler_exchange_keyup.sh
Executable file
85
src/exchange-tools/test_taler_exchange_keyup.sh
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This file is part of TALER
|
||||||
|
# Copyright (C) 2015-2020 Taler Systems SA
|
||||||
|
#
|
||||||
|
# TALER is free software; you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU Affero General Public License as published by the Free Software
|
||||||
|
# Foundation; either version 3, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License along with
|
||||||
|
# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# This script uses 'curl' to POST various ill-formed requests to the
|
||||||
|
# taler-exchange-httpd. Basically, the goal is to make sure that the
|
||||||
|
# HTTP server survives (and produces the 'correct' error code).
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Clear environment from variables that override config.
|
||||||
|
unset XDG_DATA_HOME
|
||||||
|
unset XDG_CONFIG_HOME
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# Exit, with status code "skip" (no 'real' failure)
|
||||||
|
function exit_skip() {
|
||||||
|
echo $1
|
||||||
|
exit 77
|
||||||
|
}
|
||||||
|
|
||||||
|
# test required commands exist
|
||||||
|
echo "Testing for jq"
|
||||||
|
jq -h > /dev/null || exit_skip "jq required"
|
||||||
|
|
||||||
|
echo -n "Launching exchange ..."
|
||||||
|
PREFIX=
|
||||||
|
# Uncomment this line to run with valgrind...
|
||||||
|
# PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 --log-file=valgrind.%p"
|
||||||
|
|
||||||
|
# Setup database
|
||||||
|
taler-exchange-dbinit -c test_taler_exchange_httpd.conf &> /dev/null
|
||||||
|
# Setup keys.
|
||||||
|
taler-exchange-keyup -c test_taler_exchange_httpd.conf || exit 1
|
||||||
|
# Setup wire accounts.
|
||||||
|
taler-exchange-wire -c test_taler_exchange_httpd.conf > /dev/null || exit 1
|
||||||
|
# Run Exchange HTTPD (in background)
|
||||||
|
$PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf 2> test-exchange.log &
|
||||||
|
|
||||||
|
# Give HTTP time to start
|
||||||
|
|
||||||
|
for n in `seq 1 100`
|
||||||
|
do
|
||||||
|
echo -n "."
|
||||||
|
sleep 0.1
|
||||||
|
OK=1
|
||||||
|
wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null && break
|
||||||
|
OK=0
|
||||||
|
done
|
||||||
|
if [ 1 != $OK ]
|
||||||
|
then
|
||||||
|
echo "Failed to launch exchange"
|
||||||
|
kill -TERM $!
|
||||||
|
wait $!
|
||||||
|
echo Process status: $?
|
||||||
|
exit 77
|
||||||
|
fi
|
||||||
|
echo " DONE"
|
||||||
|
|
||||||
|
# Finally run test...
|
||||||
|
echo -n "Running tests ..."
|
||||||
|
|
||||||
|
# Revoke active denomination key
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo " DONE"
|
||||||
|
# $! is the last backgrounded process, hence the exchange
|
||||||
|
kill -TERM $!
|
||||||
|
wait $!
|
||||||
|
# Return status code from exchange for this script
|
||||||
|
exit $?
|
Loading…
Reference in New Issue
Block a user