Compare commits

...

2 Commits

Author SHA1 Message Date
fea5bee835
-fix api call 2022-01-11 15:25:22 +01:00
d7342c17c6
added test for retrieval of extension config 2022-01-11 15:24:43 +01:00
4 changed files with 60 additions and 5 deletions

View File

@ -171,6 +171,7 @@ extension_update_event_cb (void *cls,
// Get the config from the database as string // Get the config from the database as string
{ {
char *config_str; char *config_str;
struct TALER_MasterSignatureP config_sig; // ignored
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct TALER_Extension *extension; struct TALER_Extension *extension;
json_error_t err; json_error_t err;
@ -182,7 +183,8 @@ extension_update_event_cb (void *cls,
qs = TEH_plugin->get_extension_config (TEH_plugin->cls, qs = TEH_plugin->get_extension_config (TEH_plugin->cls,
extension->name, extension->name,
&config_str); &config_str,
&config_sig);
if (qs < 0) if (qs < 0)
{ {

View File

@ -2753,7 +2753,10 @@ prepare_statements (struct PostgresClosure *pg)
/* Used in #postgres_get_extension_config */ /* Used in #postgres_get_extension_config */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"get_extension_config", "get_extension_config",
"SELECT (config) FROM extensions" "SELECT "
" config, "
" config_sig "
"FROM extensions"
" WHERE name=$1;", " WHERE name=$1;",
1), 1),
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
@ -11446,7 +11449,8 @@ postgres_set_extension_config (void *cls,
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
postgres_get_extension_config (void *cls, postgres_get_extension_config (void *cls,
const char *extension_name, const char *extension_name,
char **config) char **config,
struct TALER_MasterSignatureP *config_sig)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
@ -11455,6 +11459,7 @@ postgres_get_extension_config (void *cls,
}; };
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("config", config), GNUNET_PQ_result_spec_string ("config", config),
GNUNET_PQ_result_spec_auto_from_type ("config_sig", config_sig),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };

View File

@ -108,6 +108,49 @@ mark_prepare_cb (void *cls,
} }
/**
* Simple check that config retrieval and setting for extensions work
*/
static enum GNUNET_GenericReturnValue
test_extension_config (void)
{
char *config;
struct TALER_MasterSignatureP sig;
memset (&sig, 0x42, sizeof(sig));
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
plugin->get_extension_config (plugin->cls,
"fnord",
&config,
&sig));
sig.eddsa_signature.r[23] = 0x23;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->set_extension_config (plugin->cls,
"fnord",
"bar",
&sig));
memset (&sig, 0, sizeof(sig));
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_extension_config (plugin->cls,
"fnord",
&config,
&sig));
FAILIF (0 != strcmp ("bar", config));
FAILIF (0x23 != sig.eddsa_signature.r[23]);
return GNUNET_OK;
drop:
return GNUNET_SYSERR;
}
/** /**
* Test API relating to persisting the wire plugins preparation data. * Test API relating to persisting the wire plugins preparation data.
* *
@ -1334,6 +1377,10 @@ run (void *cls)
0, 0,
&recoup_cb, &recoup_cb,
NULL)); NULL));
/* simple extension check */
FAILIF (GNUNET_OK !=
test_extension_config ());
RND_BLK (&reserve_pub); RND_BLK (&reserve_pub);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.000010", TALER_string_to_amount (CURRENCY ":1.000010",

View File

@ -4049,7 +4049,8 @@ struct TALER_EXCHANGEDB_Plugin
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*get_extension_config)(void *cls, (*get_extension_config)(void *cls,
const char *extension_name, const char *extension_name,
char **config); char **config,
struct TALER_MasterSignatureP *config_sig);
}; };