Debugging session of withdraw with age restriction

This commit is contained in:
Özgür Kesim 2022-02-07 09:06:51 +01:00
parent 1090389d6f
commit f8b1c3f8db
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
9 changed files with 51 additions and 26 deletions

View File

@ -743,23 +743,13 @@ static struct TALER_AgeMask
load_age_mask (const char*section_name)
{
static const struct TALER_AgeMask null_mask = {0};
struct TALER_AgeMask age_mask = {0};
/* TODO: optimize by putting this into global? */
const struct TALER_Extension *age_ext =
TALER_extensions_get_by_type (TALER_Extension_AgeRestriction);
struct TALER_AgeMask age_mask;
// Get the age mask from the extension, if configured
/* TODO: optimize by putting this into global? */
if (TALER_extensions_is_enabled (age_ext))
age_mask = *(struct TALER_AgeMask *) age_ext->config;
TALER_extensions_init ();
age_mask = TALER_extensions_age_restriction_ageMask ();
if (age_mask.mask == 0)
{
/* Age restriction support is not enabled. Ignore the AGE_RESTRICTED field
* for the particular denomination and simply return the null_mask
*/
return null_mask;
}
if (GNUNET_OK == (GNUNET_CONFIGURATION_have_value (
TEH_cfg,
@ -1771,7 +1761,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
GNUNET_assert (0 == r);
}
// Special case for age restrictions: if enabled, provide the lits of
// Special case for age restrictions: if enabled, provide the list of
// age-restricted denominations.
if (age_restriction_enabled &&
NULL != age_restricted_denoms)
@ -1975,12 +1965,14 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
/* Put the denom into the correct array - denoms or age_restricted_denoms -
* depending on the settings and the properties of the denomination */
if (age_restriction_active &&
(0 != dk->denom_pub.age_mask.mask))
(0 != dk->meta.age_mask.mask))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"got agerestricted denom %p with mask %d\n",
"got agerestricted denom %p (mask %d) with mask %x (%s)\n",
&dk->denom_pub,
dk->denom_pub.age_mask.mask);
dk->denom_pub.age_mask.mask,
dk->meta.age_mask.mask,
TALER_age_mask_to_string (&dk->meta.age_mask));
array = age_restricted_denoms;
}
else
@ -2672,7 +2664,10 @@ load_extension_data (const char *section_name,
TEH_currency);
return GNUNET_SYSERR;
}
meta->age_restrictions = load_age_mask (section_name);
meta->age_mask = load_age_mask (section_name);
if (0 != meta->age_mask.mask)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "XXXX age mask is NON zero: %s!\n",
TALER_age_mask_to_string (&meta->age_mask));
return GNUNET_OK;
}
@ -2799,7 +2794,7 @@ add_future_denomkey_cb (void *cls,
struct FutureBuilderContext *fbc = cls;
struct HelperDenomination *hd = value;
struct TEH_DenominationKey *dk;
struct TALER_EXCHANGEDB_DenominationKeyMetaData meta;
struct TALER_EXCHANGEDB_DenominationKeyMetaData meta = {0};
dk = GNUNET_CONTAINER_multihashmap_get (fbc->ksh->denomkey_map,
h_denom_pub);

View File

@ -3357,10 +3357,10 @@ dominations_cb_helper (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct TALER_EXCHANGEDB_DenominationKeyMetaData meta;
struct TALER_DenominationPublicKey denom_pub;
struct TALER_MasterSignatureP master_sig;
struct TALER_DenominationHash h_denom_pub;
struct TALER_EXCHANGEDB_DenominationKeyMetaData meta = {0};
struct TALER_DenominationPublicKey denom_pub = {0};
struct TALER_MasterSignatureP master_sig = {0};
struct TALER_DenominationHash h_denom_pub = {0};
bool revoked;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("master_sig",

View File

@ -224,6 +224,9 @@ age_restriction_load_taler_config (
if (GNUNET_OK == ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"settings age mask to %x with #groups: %d\n", mask.mask,
__builtin_popcount (mask.mask) - 1);
_config.mask.mask = mask.mask;
_config.num_groups = __builtin_popcount (mask.mask) - 1; /* no underflow, first bit always set */
this->config = &_config;
@ -277,6 +280,10 @@ age_restriction_load_json_config (
this->config_json = jconfig;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"loaded new age restriction config with age groups: %s\n",
TALER_age_mask_to_string (&mask));
return GNUNET_OK;
}
@ -350,6 +357,13 @@ TALER_extensions_age_restriction_enabled ()
}
struct TALER_AgeMask
TALER_extensions_age_restriction_ageMask ()
{
return _config.mask;
}
size_t
TALER_extensions_age_restriction_num_groups ()
{

View File

@ -643,7 +643,7 @@ struct TALER_EXCHANGEDB_DenominationKeyMetaData
* A value of 0 means that the denomination does not support the extension for
* age-restriction.
*/
struct TALER_AgeMask age_restrictions;
struct TALER_AgeMask age_mask;
};

View File

@ -238,6 +238,13 @@ TALER_age_mask_to_string (
bool
TALER_extensions_age_restriction_enabled ();
/**
* Returns the currently set age mask
*/
struct TALER_AgeMask
TALER_extensions_age_restriction_ageMask ();
/**
* Returns the amount of age groups defined. 0 means no age restriction
* enabled.

View File

@ -829,6 +829,9 @@ decode_keys_json (const json_t *resp_obj,
EXITIF (GNUNET_OK !=
TALER_extensions_load_json_config (extensions));
}
/* 4. assuming we might have now a new value for age_mask, set it in key_data */
key_data->age_mask = TALER_extensions_age_restriction_ageMask ();
}
/* parse the denomination keys, merging with the

View File

@ -209,6 +209,7 @@ test_exchange_api_LDADD = \
-lgnunetcurl \
-lgnunetutil \
-ljansson \
-ltalerextensions \
$(XLIB)
test_exchange_management_api_SOURCES = \

View File

@ -33,6 +33,7 @@
#include "taler_bank_service.h"
#include "taler_fakebank_lib.h"
#include "taler_testing_lib.h"
#include "taler_extensions.h"
/**
* Configuration file we use. One (big) configuration is used
@ -983,12 +984,12 @@ run (void *cls,
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
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",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
CONFIG_FILE),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
CONFIG_FILE),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
@ -1042,6 +1043,9 @@ main (int argc,
GNUNET_log_setup ("test-exchange-api",
"INFO",
NULL);
TALER_extensions_init ();
/* Check fakebank port is available and get config */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (CONFIG_FILE,

View File

@ -27,6 +27,7 @@
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_signatures.h"
#include "taler_extensions.h"
#include "taler_testing_lib.h"
/**