[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 103/151: add logic to parse new_check field
From: |
gnunet |
Subject: |
[taler-exchange] 103/151: add logic to parse new_check field |
Date: |
Tue, 30 Jul 2024 23:37:53 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 285ba92711f4998966b7be3615823c50a6ebcdd1
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jul 20 16:33:31 2024 +0200
add logic to parse new_check field
---
src/include/taler_kyclogic_lib.h | 10 ++++--
src/kyclogic/kyclogic_api.c | 44 +++++++++++++++++++++++++
src/kyclogic/taler-exchange-kyc-tester.c | 56 +++++++++++++++++++++-----------
3 files changed, 88 insertions(+), 22 deletions(-)
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 8aeb6a011..db62e41ee 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -514,12 +514,16 @@ struct TALER_KYCLOGIC_KycCheckContext
* Obtain the provider logic for a given set of @a lrs
* and a specific @a kyc_rule from @a lrs that was
* triggered and the choosen @a measure_name from the
- * list of measures of that @a kyc_rule.
+ * list of measures of that @a kyc_rule. Can also be
+ * used to obtain the "current" check of a @a lrs if
+ * no trigger has been hit.
*
* @param lrs rule set
* @param kyc_rule rule that was triggered
- * @param measure_name selected measure
- * @param[out] kcc set to check to run
+ * @param measure_name selected measure,
+ * NULL to return the "new_check" set by the @a lrs
+ * @param[out] kcc set to check to run;
+ * kcc->check will be NULL if the "skip" check is used
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
enum GNUNET_GenericReturnValue
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index 79e0ab6cc..4656c1e18 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -175,6 +175,13 @@ struct TALER_KYCLOGIC_LegitimizationRuleSet
*/
char *successor_measure;
+ /**
+ * Name of the check that becomes active when this
+ * measure is triggered.
+ * NULL for no check (allowed, but should be rare).
+ */
+ char *new_check;
+
/**
* Array of the rules.
*/
@@ -385,6 +392,7 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
struct GNUNET_TIME_Timestamp expiration_time;
const char *successor_measure = NULL;
const json_t *jrules;
+ const char *new_check = NULL;
const json_t *jcustom_measures = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp (
@@ -395,6 +403,11 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
"successor_measure",
&successor_measure),
NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string (
+ "new_check",
+ &new_check),
+ NULL),
GNUNET_JSON_spec_array_const ("rules",
&jrules),
GNUNET_JSON_spec_mark_optional (
@@ -419,6 +432,10 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
= (NULL == successor_measure)
? NULL
: GNUNET_strdup (successor_measure);
+ lrs->new_check
+ = (NULL == new_check)
+ ? NULL
+ : GNUNET_strdup (new_check);
lrs->num_kyc_rules
= (unsigned int) json_array_size (jrules);
if (((size_t) lrs->num_kyc_rules) !=
@@ -605,6 +622,7 @@ TALER_KYCLOGIC_rules_free (struct
TALER_KYCLOGIC_LegitimizationRuleSet *lrs)
GNUNET_free (lrs->kyc_rules);
GNUNET_free (lrs->custom_measures);
GNUNET_free (lrs->successor_measure);
+ GNUNET_free (lrs->new_check);
GNUNET_free (lrs);
}
@@ -2230,6 +2248,23 @@ TALER_KYCLOGIC_requirements_to_check (
bool found = false;
const struct TALER_KYCLOGIC_Measure *measure = NULL;
+ if (NULL == measure_name)
+ {
+ /* No measure selected, return the "new_check" */
+ if (0 != strcasecmp (lrs->new_check,
+ "SKIP"))
+ {
+ kcc->check = find_check (lrs->new_check);
+ GNUNET_break (NULL != kcc->check);
+ }
+ else
+ {
+ kcc->check =NULL;
+ }
+ kcc->prog_name = measure->prog_name;
+ kcc->context = measure->context;
+ return GNUNET_OK;
+ }
for (unsigned int i = 0; i<kyc_rule->num_measures; i++)
{
if (0 != strcmp (measure_name,
@@ -2263,6 +2298,15 @@ TALER_KYCLOGIC_requirements_to_check (
return GNUNET_SYSERR;
}
+ if (0 == strcasecmp (measure->check_name,
+ "SKIP"))
+ {
+ kcc->check = NULL;
+ kcc->prog_name = measure->prog_name;
+ kcc->context = measure->context;
+ return GNUNET_OK;
+ }
+
for (unsigned int i = 0; i<num_kyc_checks; i++)
if (0 == strcmp (measure->check_name,
kyc_checks[i]->check_name))
diff --git a/src/kyclogic/taler-exchange-kyc-tester.c
b/src/kyclogic/taler-exchange-kyc-tester.c
index 51c19efb1..841fe939a 100644
--- a/src/kyclogic/taler-exchange-kyc-tester.c
+++ b/src/kyclogic/taler-exchange-kyc-tester.c
@@ -282,6 +282,11 @@ static int print_h_payto;
*/
static int run_webservice;
+/**
+ * -M command-line option.
+ */
+static int list_measures;
+
/**
* Value to return from main()
*/
@@ -1614,10 +1619,10 @@ run (void *cls,
{
struct TALER_KYCLOGIC_KycCheckContext kcc;
- if (NULL == measure)
+ if (0 != list_measures)
{
// FIXME: print rule with possible measures!
-
+ GNUNET_break (0);
global_ret = EXIT_SUCCESS;
GNUNET_SCHEDULER_shutdown ();
return;
@@ -1636,6 +1641,14 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
+ if (NULL == kcc.check)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ "SKIP check selected, nothing to do here\n");
+ global_ret = EXIT_SUCCESS;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
switch (kcc.check->type)
{
case TALER_KYCLOGIC_CT_INFO:
@@ -1742,6 +1755,11 @@ main (int argc,
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_help (
"tool to test KYC provider integrations"),
+ GNUNET_GETOPT_option_flag (
+ 'M',
+ "list-measures",
+ "list available measures",
+ &list_measures),
GNUNET_GETOPT_option_string (
'm',
"measure",
@@ -1754,6 +1772,11 @@ main (int argc,
"OPERATION_TYPE",
"name of the operation that triggers legitimization (WITHDRAW, DEPOSIT,
etc.)",
&operation_s),
+ GNUNET_GETOPT_option_flag (
+ 'P',
+ "print-payto-hash",
+ "output the hash of the payto://-URI",
+ &print_h_payto),
GNUNET_GETOPT_option_base32_fixed_size (
'p',
"payto-hash",
@@ -1761,41 +1784,36 @@ main (int argc,
"base32 encoding of the hash of a payto://-URI to use for the account
(otherwise a random value will be used)",
&cmd_line_h_payto,
sizeof (cmd_line_h_payto)),
- GNUNET_GETOPT_option_flag (
- 'P',
- "print-payto-hash",
- "output the hash of the payto://-URI",
- &print_h_payto),
- GNUNET_GETOPT_option_uint (
- 'r',
- "rowid",
- "NUMBER",
- "override row ID to use in simulation (default: 42)",
- &kyc_row_id),
GNUNET_GETOPT_option_string (
'R',
"ruleset",
"JSON",
"use the given legitimization rule set (otherwise defaults from
configuration are used)",
&lrs_s),
+ GNUNET_GETOPT_option_uint (
+ 'r',
+ "rowid",
+ "NUMBER",
+ "override row ID to use in simulation (default: 42)",
+ &kyc_row_id),
TALER_getopt_get_amount (
't',
"trigger",
"AMOUNT",
"threshold crossed that would trigger some legitimization rule",
&trigger_amount),
- GNUNET_GETOPT_option_string (
- 'u',
- "user",
- "ID",
- "use the given provider user ID (overridden if -i is also used)",
- &cmd_provider_user_id),
GNUNET_GETOPT_option_string (
'U',
"legitimization",
"ID",
"use the given provider legitimization ID (overridden if -i is also
used)",
&cmd_provider_legitimization_id),
+ GNUNET_GETOPT_option_string (
+ 'u',
+ "user",
+ "ID",
+ "use the given provider user ID (overridden if -i is also used)",
+ &cmd_provider_user_id),
GNUNET_GETOPT_option_flag (
'w',
"run-webservice",
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 07/151: implement new configuration parser, (continued)
- [taler-exchange] 07/151: implement new configuration parser, gnunet, 2024/07/30
- [taler-exchange] 17/151: fix taler-exchange-kyc-tester FTBFS, gnunet, 2024/07/30
- [taler-exchange] 15/151: get exchange_api_lookup_aml_decisions.c to build again, gnunet, 2024/07/30
- [taler-exchange] 50/151: -fix linker issue, gnunet, 2024/07/30
- [taler-exchange] 42/151: implement more basic KYCLOGIC functions, gnunet, 2024/07/30
- [taler-exchange] 14/151: get exchange_api_kyc_check.c to build again, gnunet, 2024/07/30
- [taler-exchange] 86/151: start with wire-gateway API v1 implementation, gnunet, 2024/07/30
- [taler-exchange] 41/151: work all over the place, gnunet, 2024/07/30
- [taler-exchange] 83/151: seems done, gnunet, 2024/07/30
- [taler-exchange] 88/151: implement wad_in_insert, gnunet, 2024/07/30
- [taler-exchange] 103/151: add logic to parse new_check field,
gnunet <=
- [taler-exchange] 66/151: implement get_kyc_statistics, gnunet, 2024/07/30
- [taler-exchange] 109/151: -diagnostic notes, gnunet, 2024/07/30
- [taler-exchange] 20/151: kyclogic API planning, gnunet, 2024/07/30
- [taler-exchange] 102/151: introduce default check, gnunet, 2024/07/30
- [taler-exchange] 96/151: -SQL fixes, gnunet, 2024/07/30
- [taler-exchange] 56/151: work on select_aml_decisions, gnunet, 2024/07/30
- [taler-exchange] 52/151: drop functions after use, gnunet, 2024/07/30
- [taler-exchange] 85/151: set timeout also for curl request, gnunet, 2024/07/30
- [taler-exchange] 46/151: -minor testing fixups, gnunet, 2024/07/30
- [taler-exchange] 55/151: finish request parsing for aml-decisions-get, gnunet, 2024/07/30