commit 8175007a1005aa975a11636d9cad95851b8a3a0d
parent 6d22968e8ec7190f1d85e5f7f30905a0e4be56f0
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 30 Jul 2024 22:46:47 +0200
possibly final test_kyc_api fixes
Diffstat:
6 files changed, 43 insertions(+), 57 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_aml-decisions-get.c b/src/exchange/taler-exchange-httpd_aml-decisions-get.c
@@ -125,6 +125,11 @@ TEH_handler_aml_decisions_get (
TALER_MHD_parse_request_number (rc->connection,
"offset",
&offset);
+ if (offset > INT64_MAX)
+ {
+ GNUNET_break_op (0); /* broken client */
+ offset = INT64_MAX;
+ }
TALER_MHD_parse_request_arg_auto (rc->connection,
"h_payto",
&h_payto,
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
@@ -1467,11 +1467,11 @@ parse_kycte (void *cls,
.val = TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW },
{ .name = "DEPOSIT",
.val = TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT },
- { .name = "P2P-RECEIVE",
+ { .name = "MERGE",
.val = TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE },
- { .name = "WALLET-BALANCE",
+ { .name = "BALANCE",
.val = TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE },
- { .name = "RESERVE-CLOSE",
+ { .name = "CLOSE",
.val = TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE },
{ .name = NULL,
.val = TALER_KYCLOGIC_KYC_TRIGGER_NONE },
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
@@ -575,10 +575,9 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
struct TALER_KYCLOGIC_KycRule *rule
= &lrs->kyc_rules[off];
const json_t *jmeasures;
- const char *operation_type;
struct GNUNET_JSON_Specification ispec[] = {
- GNUNET_JSON_spec_string ("operation_type",
- &operation_type),
+ TALER_JSON_spec_kycte ("operation_type",
+ &rule->trigger),
TALER_JSON_spec_amount_any ("threshold",
&rule->threshold),
GNUNET_JSON_spec_relative_time ("timeframe",
@@ -606,14 +605,6 @@ TALER_KYCLOGIC_rules_parse (const json_t *jlrs)
GNUNET_break_op (0);
goto cleanup;
}
- if (GNUNET_OK !=
- TALER_KYCLOGIC_kyc_trigger_from_string (
- operation_type,
- &rule->trigger))
- {
- GNUNET_break_op (0);
- goto cleanup;
- }
rule->lrs = lrs;
rule->next_measures
= GNUNET_new_array (rule->num_measures,
@@ -795,14 +786,14 @@ TALER_KYCLOGIC_rules_to_limits (const json_t *jrules)
GNUNET_assert (NULL != limits);
json_array_foreach ((json_t *) jrules, idx, rule)
{
- const char *ots;
struct GNUNET_TIME_Relative timeframe;
struct TALER_Amount threshold;
bool exposed = false;
const json_t *jmeasures;
+ enum TALER_KYCLOGIC_KycTriggerEvent operation_type;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("operation_type",
- &ots),
+ TALER_JSON_spec_kycte ("operation_type",
+ &operation_type),
GNUNET_JSON_spec_relative_time ("timeframe",
&timeframe),
TALER_JSON_spec_amount_any ("threshold",
@@ -847,14 +838,18 @@ TALER_KYCLOGIC_rules_to_limits (const json_t *jrules)
}
limit = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("operation_type",
- ots),
- GNUNET_JSON_pack_time_rel ("timeframe",
- timeframe),
- TALER_JSON_pack_amount ("threshold",
- &threshold),
- GNUNET_JSON_pack_bool ("soft_limit",
- ! forbidden));
+ GNUNET_JSON_pack_string (
+ "operation_type",
+ TALER_KYCLOGIC_kyc_trigger2s (operation_type)),
+ GNUNET_JSON_pack_time_rel (
+ "timeframe",
+ timeframe),
+ TALER_JSON_pack_amount (
+ "threshold",
+ &threshold),
+ GNUNET_JSON_pack_bool (
+ "soft_limit",
+ ! forbidden));
GNUNET_assert (0 ==
json_array_append_new (limits,
limit));
@@ -1139,11 +1134,11 @@ TALER_KYCLOGIC_kyc_trigger_from_string (
const char *in;
enum TALER_KYCLOGIC_KycTriggerEvent out;
} map [] = {
- { "withdraw", TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW },
- { "deposit", TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT },
- { "merge", TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE },
- { "balance", TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE },
- { "close", TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE },
+ { "WITHDRAW", TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW },
+ { "DEPOSIT", TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT },
+ { "MERGE", TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE },
+ { "BALANCE", TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE },
+ { "CLOSE", TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE },
{ NULL, 0 }
};
@@ -1171,15 +1166,15 @@ TALER_KYCLOGIC_kyc_trigger2s (
GNUNET_break (0);
return NULL;
case TALER_KYCLOGIC_KYC_TRIGGER_WITHDRAW:
- return "withdraw";
+ return "WITHDRAW";
case TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT:
- return "deposit";
+ return "DEPOSIT";
case TALER_KYCLOGIC_KYC_TRIGGER_P2P_RECEIVE:
- return "merge";
+ return "MERGE";
case TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE:
- return "balance";
+ return "BALANCE";
case TALER_KYCLOGIC_KYC_TRIGGER_RESERVE_CLOSE:
- return "close";
+ return "CLOSE";
}
GNUNET_break (0);
return NULL;
diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c
@@ -542,7 +542,10 @@ TALER_EXCHANGE_lookup_aml_decisions (
"limit",
limit_s,
"offset",
- offset_s,
+ ( ( (limit < 0) && (UINT64_MAX == offset) ) ||
+ ( (limit > 0) && (0 == offset) ) )
+ ? NULL
+ : offset_s,
"h_payto",
NULL != h_payto
? payto_s
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
@@ -633,23 +633,21 @@ run (void *cls,
"{}" /* properties */,
"party time",
MHD_HTTP_NO_CONTENT),
-#if FIXME
TALER_TESTING_cmd_check_aml_decisions (
"check-decisions-one-normal",
"create-aml-officer-1",
"aml-decide",
MHD_HTTP_OK),
TALER_TESTING_cmd_wallet_kyc_get (
+ "wallet-trigger-kyc-for-aml-allowed",
"wallet-trigger-kyc-for-aml",
- NULL,
"EUR:1000",
MHD_HTTP_NO_CONTENT),
TALER_TESTING_cmd_wallet_kyc_get (
+ "wallet-trigger-kyc-for-aml-denied-high",
"wallet-trigger-kyc-for-aml",
- NULL,
"EUR:20000",
MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
-#endif
TALER_TESTING_cmd_sleep (
"sleep-1d",
1),
@@ -685,7 +683,6 @@ run (void *cls,
NULL,
true,
true),
-#if DISABLED || 0
TALER_TESTING_cmd_batch (
"withdraw",
withdraw),
@@ -710,7 +707,6 @@ run (void *cls,
TALER_TESTING_cmd_batch (
"pull",
pull),
-#endif
TALER_TESTING_cmd_batch ("aml",
aml),
TALER_TESTING_cmd_end ()
diff --git a/src/testing/testing_api_cmd_take_aml_decision.c b/src/testing/testing_api_cmd_take_aml_decision.c
@@ -246,7 +246,6 @@ take_aml_decision_run (void *cls,
{
struct TALER_EXCHANGE_AccountRule *rule = &rules[i];
const json_t *jmeasures = NULL;
- const char *ots;
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_relative_time ("timeframe",
&rule->timeframe),
@@ -260,8 +259,8 @@ take_aml_decision_run (void *cls,
GNUNET_JSON_spec_uint32 ("display_priority",
&rule->display_priority),
NULL),
- GNUNET_JSON_spec_string ("operation_type",
- &ots),
+ TALER_JSON_spec_kycte ("operation_type",
+ &rule->operation_type),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_bool ("verboten",
&rule->verboten),
@@ -293,18 +292,6 @@ take_aml_decision_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- if (GNUNET_OK !=
- TALER_KYCLOGIC_kyc_trigger_from_string (ots,
- &rule->operation_type))
- {
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Malformed operation type in rule #%u: %s unknown\n",
- (unsigned int) i,
- ots);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
if (NULL != jmeasures)
{
rule->num_measures