start with exchange management test

This commit is contained in:
Christian Grothoff 2020-12-01 09:19:58 +01:00
parent 65915731a9
commit 06b8ed9ba8
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
16 changed files with 415 additions and 714 deletions

View File

@ -4,7 +4,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
pkgcfgdir = $(prefix)/share/taler/config.d/ pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \ pkgcfg_DATA = \
coins.conf coins.conf \
exchange-offline.conf
if USE_COVERAGE if USE_COVERAGE
AM_CFLAGS = --coverage -O0 AM_CFLAGS = --coverage -O0

View File

@ -0,0 +1,6 @@
# This file is in the public domain.
#
[exchange-offline]
# Where do we store the offline master private key of the exchange?
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv

View File

@ -416,6 +416,36 @@ struct TALER_TESTING_Interpreter
*/ */
struct GNUNET_OS_Process *exchanged; struct GNUNET_OS_Process *exchanged;
/**
* Public key of the auditor.
*/
struct TALER_AuditorPublicKeyP auditor_pub;
/**
* Private key of the auditor.
*/
struct TALER_AuditorPrivateKeyP auditor_priv;
/**
* Private offline signing key.
*/
struct TALER_MasterPrivateKeyP master_priv;
/**
* Public offline signing key.
*/
struct TALER_MasterPublicKeyP master_pub;
/**
* URL of the auditor (as per configuration).
*/
char *auditor_url;
/**
* URL of the exchange (as per configuration).
*/
char *exchange_url;
/** /**
* #GNUNET_OK if key state should be reloaded. NOTE: this * #GNUNET_OK if key state should be reloaded. NOTE: this
* field can be removed because a new "send signal" command * field can be removed because a new "send signal" command

View File

@ -7,3 +7,4 @@ test_taler_exchange_aggregator-postgres
test_taler_exchange_wirewatch-postgres test_taler_exchange_wirewatch-postgres
test_exchange_api_revocation test_exchange_api_revocation
report* report*
test_exchange_management_api

View File

@ -134,6 +134,7 @@ check_PROGRAMS = \
test_exchange_api_keys_cherry_picking \ test_exchange_api_keys_cherry_picking \
test_exchange_api_revocation \ test_exchange_api_revocation \
test_exchange_api_overlapping_keys_bug \ test_exchange_api_overlapping_keys_bug \
test_exchange_management_api \
test_taler_exchange_aggregator-postgres \ test_taler_exchange_aggregator-postgres \
test_taler_exchange_wirewatch-postgres test_taler_exchange_wirewatch-postgres
if HAVE_TWISTER if HAVE_TWISTER
@ -216,6 +217,15 @@ test_exchange_api_LDADD = \
-ljansson \ -ljansson \
$(XLIB) $(XLIB)
test_exchange_management_api_SOURCES = \
test_exchange_management_api.c
test_exchange_management_api_LDADD = \
libtalertesting.la \
$(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
$(XLIB)
test_exchange_api_revocation_SOURCES = \ test_exchange_api_revocation_SOURCES = \
test_exchange_api_revocation.c test_exchange_api_revocation.c
test_exchange_api_revocation_LDADD = \ test_exchange_api_revocation_LDADD = \

View File

@ -17,7 +17,6 @@ BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to # HTTP port the auditor listens to
PORT = 8083 PORT = 8083
[exchange] [exchange]
TERMS_ETAG = 0 TERMS_ETAG = 0

View File

@ -0,0 +1,121 @@
/*
This file is part of TALER
Copyright (C) 2020 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 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 General Public License for more details.
You should have received a copy of the GNU General Public
License along with TALER; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
/**
* @file testing/test_exchange_management_api.c
* @brief testcase to test exchange's HTTP /management/ API
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_util.h"
#include "taler_exchange_service.h"
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
#include "taler_testing_lib.h"
/**
* Configuration file we use. One (big) configuration is used
* for the various components for this test.
*/
#define CONFIG_FILE "test_exchange_api.conf"
/**
* Exchange configuration data.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Main function that will tell the interpreter what commands to
* run.
*
* @param cls closure
* @param is interpreter we use to run commands
*/
static void
run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_end ()
};
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
}
int
main (int argc,
char *const *argv)
{
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-exchange-management-api",
"INFO",
NULL);
/* Check fakebank port is available and get config */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (CONFIG_FILE);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
CONFIG_FILE))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
}
/* end of test_exchange_management_api.c */

View File

@ -102,28 +102,13 @@ auditor_add_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct AuditorAddState *ds = cls; struct AuditorAddState *ds = cls;
struct TALER_AuditorPublicKeyP auditor_pub;
char *auditor_url;
char *exchange_url;
struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
struct TALER_MasterSignatureP master_sig;
(void) cmd; (void) cmd;
now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&now); (void) GNUNET_TIME_round_abs (&now);
ds->is = is; ds->is = is;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"BASE_URL",
&auditor_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (ds->bad_sig) if (ds->bad_sig)
{ {
memset (&master_sig, memset (&master_sig,
@ -132,89 +117,6 @@ auditor_add_run (void *cls,
} }
else else
{ {
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
struct TALER_AuditorPrivateKeyP auditor_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
GNUNET_free (fn);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"AUDITOR_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"AUDITOR_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for auditor private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&auditor_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load auditor private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
GNUNET_free (fn);
GNUNET_CRYPTO_eddsa_key_get_public (&auditor_priv.eddsa_priv,
&auditor_pub.eddsa_pub);
/* now sign */ /* now sign */
{ {
@ -222,43 +124,28 @@ auditor_add_run (void *cls,
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_AUDITOR), .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_AUDITOR),
.purpose.size = htonl (sizeof (kv)), .purpose.size = htonl (sizeof (kv)),
.start_date = GNUNET_TIME_absolute_hton (now), .start_date = GNUNET_TIME_absolute_hton (now),
.auditor_pub = auditor_pub, .auditor_pub = is->auditor_pub,
}; };
GNUNET_CRYPTO_hash (auditor_url, GNUNET_CRYPTO_hash (is->auditor_url,
strlen (auditor_url) + 1, strlen (is->auditor_url) + 1,
&kv.h_auditor_url); &kv.h_auditor_url);
/* Finally sign ... */ /* Finally sign ... */
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
} }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
GNUNET_free (auditor_url);
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_management_enable_auditor ( ds->dh = TALER_EXCHANGE_management_enable_auditor (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
&auditor_pub, &is->auditor_pub,
auditor_url, is->auditor_url,
"test-case auditor", /* human-readable auditor name */ "test-case auditor", /* human-readable auditor name */
now, now,
&master_sig, &master_sig,
&auditor_add_cb, &auditor_add_cb,
ds); ds);
GNUNET_free (exchange_url);
GNUNET_free (auditor_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -107,12 +107,8 @@ auditor_add_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct AuditorAddDenomSigState *ds = cls; struct AuditorAddDenomSigState *ds = cls;
char *exchange_url;
struct TALER_AuditorPrivateKeyP auditor_priv;
struct TALER_AuditorPublicKeyP auditor_pub;
struct TALER_AuditorSignatureP auditor_sig; struct TALER_AuditorSignatureP auditor_sig;
struct GNUNET_HashCode h_denom_pub; struct GNUNET_HashCode h_denom_pub;
char *fn;
const struct TALER_EXCHANGE_DenomPublicKey *dk; const struct TALER_EXCHANGE_DenomPublicKey *dk;
(void) cmd; (void) cmd;
@ -134,33 +130,6 @@ auditor_add_run (void *cls,
0, 0,
&dk)); &dk));
} }
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for auditor private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&auditor_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load auditor private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
GNUNET_CRYPTO_eddsa_key_get_public (&auditor_priv.eddsa_priv,
&auditor_pub.eddsa_pub);
ds->is = is; ds->is = is;
if (ds->bad_sig) if (ds->bad_sig)
{ {
@ -169,61 +138,6 @@ auditor_add_run (void *cls,
sizeof (auditor_sig)); sizeof (auditor_sig));
} }
else else
{
struct TALER_MasterPrivateKeyP master_priv;
char *auditor_url;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
GNUNET_free (auditor_url);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"BASE_URL",
&auditor_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
/* now sign */
{ {
struct TALER_ExchangeKeyValidityPS kv = { struct TALER_ExchangeKeyValidityPS kv = {
.purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS), .purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS),
@ -246,41 +160,24 @@ auditor_add_run (void *cls,
&dk->fee_refresh); &dk->fee_refresh);
TALER_amount_hton (&kv.fee_refund, TALER_amount_hton (&kv.fee_refund,
&dk->fee_refund); &dk->fee_refund);
GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&is->master_priv.eddsa_priv,
&kv.master.eddsa_pub); &kv.master.eddsa_pub);
GNUNET_CRYPTO_hash (auditor_url, GNUNET_CRYPTO_hash (is->auditor_url,
strlen (auditor_url) + 1, strlen (is->auditor_url) + 1,
&kv.auditor_url_hash); &kv.auditor_url_hash);
/* Finally sign ... */ /* Finally sign ... */
GNUNET_CRYPTO_eddsa_sign (&auditor_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->auditor_priv.eddsa_priv,
&kv, &kv,
&auditor_sig.eddsa_sig); &auditor_sig.eddsa_sig);
} }
GNUNET_free (auditor_url);
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_add_auditor_denomination ( ds->dh = TALER_EXCHANGE_add_auditor_denomination (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
&h_denom_pub, &h_denom_pub,
&auditor_pub, &is->auditor_pub,
&auditor_sig, &auditor_sig,
&denom_sig_add_cb, &denom_sig_add_cb,
ds); ds);
GNUNET_free (exchange_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -102,8 +102,6 @@ auditor_del_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct AuditorDelState *ds = cls; struct AuditorDelState *ds = cls;
struct TALER_AuditorPublicKeyP auditor_pub;
char *exchange_url;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
@ -118,122 +116,27 @@ auditor_del_run (void *cls,
sizeof (master_sig)); sizeof (master_sig));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
struct TALER_AuditorPrivateKeyP auditor_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"AUDITOR_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"AUDITOR_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for auditor private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&auditor_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load auditor private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
GNUNET_CRYPTO_eddsa_key_get_public (&auditor_priv.eddsa_priv,
&auditor_pub.eddsa_pub);
/* now sign */
{ {
struct TALER_MasterDelAuditorPS kv = { struct TALER_MasterDelAuditorPS kv = {
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_AUDITOR), .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_AUDITOR),
.purpose.size = htonl (sizeof (kv)), .purpose.size = htonl (sizeof (kv)),
.end_date = GNUNET_TIME_absolute_hton (now), .end_date = GNUNET_TIME_absolute_hton (now),
.auditor_pub = auditor_pub, .auditor_pub = is->auditor_pub,
}; };
/* Finally sign ... */ /* Finally sign ... */
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_management_disable_auditor ( ds->dh = TALER_EXCHANGE_management_disable_auditor (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
&auditor_pub, &is->auditor_pub,
now, now,
&master_sig, &master_sig,
&auditor_del_cb, &auditor_del_cb,
ds); ds);
GNUNET_free (exchange_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -159,7 +159,6 @@ revoke_run (void *cls,
struct RevokeState *rs = cls; struct RevokeState *rs = cls;
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
char *exchange_url;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
rs->is = is; rs->is = is;
@ -187,47 +186,6 @@ revoke_run (void *cls,
sizeof (master_sig)); sizeof (master_sig));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (rs->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (rs->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (rs->is);
return;
}
GNUNET_free (fn);
/* now sign */
{ {
struct TALER_MasterDenominationKeyRevocationPS kv = { struct TALER_MasterDenominationKeyRevocationPS kv = {
.purpose.purpose = htonl ( .purpose.purpose = htonl (
@ -236,31 +194,17 @@ revoke_run (void *cls,
.h_denom_pub = denom_pub->h_key .h_denom_pub = denom_pub->h_key
}; };
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (rs->is);
return;
}
rs->kh = TALER_EXCHANGE_management_revoke_denomination_key ( rs->kh = TALER_EXCHANGE_management_revoke_denomination_key (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
&denom_pub->h_key, &denom_pub->h_key,
&master_sig, &master_sig,
&success_cb, &success_cb,
rs); rs);
GNUNET_free (exchange_url);
if (NULL == rs->kh) if (NULL == rs->kh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -159,7 +159,6 @@ revoke_run (void *cls,
struct RevokeState *rs = cls; struct RevokeState *rs = cls;
const struct TALER_TESTING_Command *coin_cmd; const struct TALER_TESTING_Command *coin_cmd;
const struct TALER_ExchangePublicKeyP *exchange_pub; const struct TALER_ExchangePublicKeyP *exchange_pub;
char *exchange_url;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
rs->is = is; rs->is = is;
@ -187,47 +186,6 @@ revoke_run (void *cls,
sizeof (master_sig)); sizeof (master_sig));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (rs->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (rs->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (rs->is);
return;
}
GNUNET_free (fn);
/* now sign */
{ {
struct TALER_MasterSigningKeyRevocationPS kv = { struct TALER_MasterSigningKeyRevocationPS kv = {
.purpose.purpose = htonl ( .purpose.purpose = htonl (
@ -236,31 +194,17 @@ revoke_run (void *cls,
.exchange_pub = *exchange_pub .exchange_pub = *exchange_pub
}; };
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (rs->is);
return;
}
rs->kh = TALER_EXCHANGE_management_revoke_signing_key ( rs->kh = TALER_EXCHANGE_management_revoke_signing_key (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
exchange_pub, exchange_pub,
&master_sig, &master_sig,
&success_cb, &success_cb,
rs); rs);
GNUNET_free (exchange_url);
if (NULL == rs->kh) if (NULL == rs->kh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -117,7 +117,6 @@ wire_add_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct WireFeeState *ds = cls; struct WireFeeState *ds = cls;
char *exchange_url;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Absolute start_time; struct GNUNET_TIME_Absolute start_time;
@ -152,47 +151,6 @@ wire_add_run (void *cls,
sizeof (master_sig)); sizeof (master_sig));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
/* now sign */
{ {
struct TALER_MasterWireFeePS kv = { struct TALER_MasterWireFeePS kv = {
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES), .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES),
@ -208,26 +166,13 @@ wire_add_run (void *cls,
&wire_fee); &wire_fee);
TALER_amount_hton (&kv.closing_fee, TALER_amount_hton (&kv.closing_fee,
&closing_fee); &closing_fee);
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_management_set_wire_fees ( ds->dh = TALER_EXCHANGE_management_set_wire_fees (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
ds->wire_method, ds->wire_method,
start_time, start_time,
end_time, end_time,
@ -236,7 +181,6 @@ wire_add_run (void *cls,
&master_sig, &master_sig,
&wire_add_cb, &wire_add_cb,
ds); ds);
GNUNET_free (exchange_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -107,7 +107,6 @@ wire_add_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct WireAddState *ds = cls; struct WireAddState *ds = cls;
char *exchange_url;
struct TALER_MasterSignatureP master_sig1; struct TALER_MasterSignatureP master_sig1;
struct TALER_MasterSignatureP master_sig2; struct TALER_MasterSignatureP master_sig2;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
@ -126,47 +125,6 @@ wire_add_run (void *cls,
sizeof (master_sig2)); sizeof (master_sig2));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
/* now sign */
{ {
struct TALER_MasterAddWirePS kv = { struct TALER_MasterAddWirePS kv = {
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE), .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE),
@ -181,36 +139,22 @@ wire_add_run (void *cls,
TALER_exchange_wire_signature_hash (ds->payto_uri, TALER_exchange_wire_signature_hash (ds->payto_uri,
&kv.h_wire); &kv.h_wire);
wd.h_wire_details = kv.h_wire; wd.h_wire_details = kv.h_wire;
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig1.eddsa_signature); &master_sig1.eddsa_signature);
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&wd, &wd,
&master_sig2.eddsa_signature); &master_sig2.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_management_enable_wire ( ds->dh = TALER_EXCHANGE_management_enable_wire (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
ds->payto_uri, ds->payto_uri,
now, now,
&master_sig1, &master_sig1,
&master_sig2, &master_sig2,
&wire_add_cb, &wire_add_cb,
ds); ds);
GNUNET_free (exchange_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -107,7 +107,6 @@ wire_del_run (void *cls,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct WireDelState *ds = cls; struct WireDelState *ds = cls;
char *exchange_url;
struct TALER_MasterSignatureP master_sig; struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute now;
@ -122,47 +121,6 @@ wire_del_run (void *cls,
sizeof (master_sig)); sizeof (master_sig));
} }
else else
{
char *fn;
struct TALER_MasterPrivateKeyP master_priv;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
TALER_TESTING_interpreter_next (ds->is);
return;
}
GNUNET_free (fn);
/* now sign */
{ {
struct TALER_MasterDelWirePS kv = { struct TALER_MasterDelWirePS kv = {
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_WIRE), .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_WIRE),
@ -172,32 +130,18 @@ wire_del_run (void *cls,
TALER_exchange_wire_signature_hash (ds->payto_uri, TALER_exchange_wire_signature_hash (ds->payto_uri,
&kv.h_wire); &kv.h_wire);
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_sign (&is->master_priv.eddsa_priv,
&kv, &kv,
&master_sig.eddsa_signature); &master_sig.eddsa_signature);
} }
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
TALER_TESTING_interpreter_next (ds->is);
return;
}
ds->dh = TALER_EXCHANGE_management_disable_wire ( ds->dh = TALER_EXCHANGE_management_disable_wire (
is->ctx, is->ctx,
exchange_url, is->exchange_url,
ds->payto_uri, ds->payto_uri,
now, now,
&master_sig, &master_sig,
&wire_del_cb, &wire_del_cb,
ds); ds);
GNUNET_free (exchange_url);
if (NULL == ds->dh) if (NULL == ds->dh)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -750,6 +750,124 @@ main_wrapper_exchange_connect (void *cls)
} }
/**
* Load the exchange and auditor key material into @a is.
*
* @param[in,out] is state to initialize
*/
static int
load_keys (struct TALER_TESTING_Interpreter *is)
{
char *fn;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"exchange-offline",
"MASTER_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange-offline",
"MASTER_PRIV_FILE");
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for master private key file `%s'\n",
fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR ==
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&is->master_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load master private key from `%s'\n",
fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
GNUNET_free (fn);
GNUNET_CRYPTO_eddsa_key_get_public (&is->master_priv.eddsa_priv,
&is->master_pub.eddsa_pub);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"AUDITOR_PRIV_FILE",
&fn))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"AUDITOR_PRIV_FILE");
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create_for_file (fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup directory for auditor private key file `%s'\n",
fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR ==
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&is->auditor_priv.eddsa_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not load auditor private key from `%s'\n",
fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
GNUNET_free (fn);
GNUNET_CRYPTO_eddsa_key_get_public (&is->auditor_priv.eddsa_priv,
&is->auditor_pub.eddsa_pub);
return GNUNET_OK;
}
/**
* Load the exchange and auditor URLs from the configuration into @a is.
*
* @param[in,out] is state to initialize
*/
static int
load_urls (struct TALER_TESTING_Interpreter *is)
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (is->cfg,
"auditor",
"BASE_URL",
&is->auditor_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"BASE_URL");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (is->cfg,
"exchange",
"BASE_URL",
&is->exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
GNUNET_free (is->auditor_url);
return GNUNET_SYSERR;
}
return GNUNET_OK;
}
/** /**
* Install signal handlers plus schedules the main wrapper * Install signal handlers plus schedules the main wrapper
* around the "run" method. * around the "run" method.
@ -790,6 +908,12 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb,
sizeof (is)); sizeof (is));
is.exchanged = exchanged; is.exchanged = exchanged;
is.cfg = cfg; is.cfg = cfg;
if (GNUNET_OK !=
load_keys (&is))
return GNUNET_SYSERR;
if (GNUNET_OK !=
load_urls (&is))
return GNUNET_SYSERR;
sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE);
GNUNET_assert (NULL != sigpipe); GNUNET_assert (NULL != sigpipe);
shc_chld = GNUNET_SIGNAL_handler_install shc_chld = GNUNET_SIGNAL_handler_install
@ -802,8 +926,8 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb,
GNUNET_assert (NULL != is.ctx); GNUNET_assert (NULL != is.ctx);
is.rc = GNUNET_CURL_gnunet_rc_create (is.ctx); is.rc = GNUNET_CURL_gnunet_rc_create (is.ctx);
/* Blocking */
/* Blocking */
if (GNUNET_YES == exchange_connect) if (GNUNET_YES == exchange_connect)
GNUNET_SCHEDULER_run (&main_wrapper_exchange_connect, GNUNET_SCHEDULER_run (&main_wrapper_exchange_connect,
&main_ctx); &main_ctx);
@ -816,6 +940,8 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb,
GNUNET_SIGNAL_handler_uninstall (shc_chld); GNUNET_SIGNAL_handler_uninstall (shc_chld);
GNUNET_DISK_pipe_close (sigpipe); GNUNET_DISK_pipe_close (sigpipe);
sigpipe = NULL; sigpipe = NULL;
GNUNET_free (is.auditor_url);
GNUNET_free (is.exchange_url);
return is.result; return is.result;
} }