(imperfect) test for #4840

This commit is contained in:
Christian Grothoff 2017-09-14 20:52:39 +02:00
parent f440904f1b
commit f346e89ceb
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 193 additions and 22 deletions

View File

@ -80,4 +80,6 @@ EXTRA_DIST = \
test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \
test_exchange_api_home/.config/taler/test.json \
test_exchange_api_home/.config/taler/sepa.json \
test_exchange_api.conf
test_exchange_api.conf \
test_exchange_api_keys_cherry_picking.conf \
test_exchange_api_keys_cherry_picking_extended.conf

View File

@ -812,6 +812,9 @@ keys_completed_cb (void *cls,
kr->url,
response_code);
kd_old = exchange->key_data;
memset (&kd,
0,
sizeof (struct TALER_EXCHANGE_Keys));
vc = TALER_EXCHANGE_VC_PROTOCOL_ERROR;
switch (response_code)
{
@ -823,15 +826,12 @@ keys_completed_cb (void *cls,
response_code = 0;
break;
}
memset (&kd,
0,
sizeof (struct TALER_EXCHANGE_Keys));
/* We keep the denomination keys and auditor signatures from the
previous iteration (/keys cherry picking) */
kd.num_denom_keys = kd_old.num_denom_keys;
kd.denom_keys = GNUNET_new_array (kd.num_denom_keys,
struct TALER_EXCHANGE_DenomPublicKey);
GNUNET_array_grow (kd.denom_keys,
kd.denom_keys_size,
kd.num_denom_keys);
/* First make a shallow copy, we then need another pass for the RSA key... */
memcpy (kd.denom_keys,
kd_old.denom_keys,
@ -857,7 +857,7 @@ keys_completed_cb (void *cls,
for (unsigned int j=0;j<aold->num_denom_keys;j++)
{
/* offsets will map 1:1 */
unsigned int off = kd_old.denom_keys - aold->denom_keys[j];
unsigned int off = aold->denom_keys[j] - kd_old.denom_keys;
GNUNET_assert (off < kd_old.num_denom_keys);
anew->denom_keys[j] = &kd.denom_keys[off];
@ -872,7 +872,6 @@ keys_completed_cb (void *cls,
response_code = 0;
break;
}
exchange->key_data = kd;
json_decref (exchange->key_data_raw);
exchange->key_data_raw = json_deep_copy (resp_obj);
break;
@ -882,6 +881,7 @@ keys_completed_cb (void *cls,
(unsigned int) response_code);
break;
}
exchange->key_data = kd;
if (MHD_HTTP_OK != response_code)
{

View File

@ -117,7 +117,7 @@ struct Command
/**
* Command-line arguments for the process to be run.
*/
char *const*argv;
char *const *argv;
/**
* Process handle.
@ -359,6 +359,10 @@ interpreter_run (void *cls)
{
/* Did not get the expected number of denomination keys! */
GNUNET_break (0);
fprintf (stderr,
"Got %u keys in step %s\n",
is->keys->num_denom_keys,
cmd->label);
fail (is);
return;
}
@ -419,13 +423,8 @@ do_shutdown (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd;
unsigned int i;
fprintf (stderr,
"Executing shutdown at `%s'\n",
is->commands[is->ip].label);
for (i=0;OC_END != (cmd = &is->commands[i])->oc;i++)
for (unsigned int i=0;OC_END != (cmd = &is->commands[i])->oc;i++)
{
switch (cmd->oc)
{
@ -541,10 +540,47 @@ static void
run (void *cls)
{
struct InterpreterState *is;
static char *keyup[] = {
"taler-exchange-keyup",
"-c", "test_exchange_api_keys_cherry_picking_extended.conf",
"-o", "auditor.in",
NULL
};
static char *auditorsign[] = {
"taler-auditor-sign",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-u", "http://auditor/",
"-m", "98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG",
"-r", "auditor.in",
"-o", "test_exchange_api_home/.local/share/taler/auditors/auditor.out",
NULL
};
static struct Command commands[] =
{
/* Test signal handling by itself */
{ .oc = OC_SIGNAL_EXCHANGE },
/* Check we got /keys properly */
{ .oc = OC_CHECK_KEYS,
.details.check_keys.generation = 1,
.details.check_keys.num_denom_keys = 4
},
/* Generate more keys */
{ .oc = OC_RUN_PROCESS,
.details.run_process.binary = "taler-exchange-keyup",
.details.run_process.argv = keyup
},
/* Auditor-sign them */
{ .oc = OC_RUN_PROCESS,
.details.run_process.binary = "taler-auditor-sign",
.details.run_process.argv = auditorsign
},
/* Load new keys into exchange via signal */
{ .oc = OC_SIGNAL_EXCHANGE },
/* Re-download and check /keys */
{ .oc = OC_CHECK_KEYS,
.details.check_keys.generation = 2,
.details.check_keys.num_denom_keys = 8
},
{ .oc = OC_END }
};
@ -640,7 +676,7 @@ main (int argc,
NULL, NULL, NULL,
"taler-exchange-keyup",
"taler-exchange-keyup",
"-c", "test_exchange_api.conf",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-o", "auditor.in",
NULL);
if (NULL == proc)
@ -657,7 +693,7 @@ main (int argc,
NULL, NULL, NULL,
"taler-auditor-sign",
"taler-auditor-sign",
"-c", "test_exchange_api.conf",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-u", "http://auditor/",
"-m", "98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG",
"-r", "auditor.in",
@ -677,7 +713,7 @@ main (int argc,
NULL, NULL, NULL,
"taler-exchange-dbinit",
"taler-exchange-dbinit",
"-c", "test_exchange_api.conf",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-r",
NULL);
if (NULL == proc)
@ -715,7 +751,7 @@ main (int argc,
NULL, NULL, NULL,
"taler-exchange-httpd",
"taler-exchange-httpd",
"-c", "test_exchange_api.conf",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-i",
NULL);
/* give child time to start and bind against the socket */

View File

@ -0,0 +1,128 @@
# This file is in the public domain.
#
[PATHS]
# Persistant data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
[exchange]
# 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
# Base URL of the exchange. Note that the test expects exactly this
# value in the wire transfers.
BASE_URL = "https://exchange.com/"
[exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[auditordb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[exchange-wire-sepa]
# Enable 'sepa' to test SEPA-specific routines.
ENABLE = YES
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
SEPA_RESPONSE_FILE = ${TALER_CONFIG_HOME}/sepa.json
# Fees for the forseeable future...
# If you see this after 2017, update to match the next 10 years...
WIRE-FEE-2017 = EUR:0.01
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
CLOSING-FEE-2017 = 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
[exchange_keys]
# Keep it short so we can prolong later!
LOOKAHEAD_SIGN = 60 s
[exchange-wire-test]
# Enable 'test' for testing of the actual coin operations.
ENABLE = YES
# Fees for the forseeable future...
# If you see this after 2017, update to match the next 10 years...
WIRE-FEE-2017 = EUR:0.01
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
CLOSING-FEE-2017 = 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
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/test.json
# What is the main website of the bank?
BANK_URI = "http://localhost:8082/"
# From which account at the 'bank' should outgoing wire transfers be made?
BANK_ACCOUNT_NUMBER = 2
[coin_eur_ct_1]
value = EUR:0.01
duration_overlap = 5 s
duration_withdraw = 35 s
duration_spend = 40 s
duration_legal = 60 s
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_2]
value = EUR:0.02
duration_overlap = 5 s
duration_withdraw = 35 s
duration_spend = 40 s
duration_legal = 60 s
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024

View File

@ -0,0 +1,5 @@
@INLINE@ test_exchange_api_keys_cherry_picking.conf
[exchange_keys]
# Lengthen over original value (60 s)
LOOKAHEAD_SIGN = 100 s

View File

@ -1424,13 +1424,13 @@ TEH_KS_handler_keys (struct TEH_RequestHandler *rh,
ks.purpose.size = htonl (sizeof (ks));
ks.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET);
ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time);
GNUNET_CRYPTO_hash_context_finish (key_state->hash_context,
GNUNET_CRYPTO_hash_context_finish (rbc.hash_context,
&ks.hc);
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv,
&ks.purpose,
&sig.eddsa_signature));
keys = json_pack ("{s:s, s:o, s:O, s:o, s:O, s:o, s:o}",
keys = json_pack ("{s:s, s:o, s:O, s:o, s:O, s:o, s:o, s:o, s:o}",
"version", TALER_PROTOCOL_VERSION,
"master_public_key", GNUNET_JSON_from_data_auto (&TEH_master_public_key),
"signkeys", key_state->sign_keys_array,