aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-07-28 18:01:49 +0200
committerChristian Grothoff <christian@grothoff.org>2024-07-29 12:18:50 +0200
commit6c34722457db8ecd0c13db87e6ebf5b8595cd9a0 (patch)
treed2e32678e01a6fb720be590366a4932f2e50844a
parent069f30ba323b952a17e89adfebc23dacf415a1c8 (diff)
-bugfixes
-rw-r--r--src/exchangedb/pg_select_aml_decisions.c66
-rw-r--r--src/include/taler_mhd_lib.h33
-rw-r--r--src/include/taler_testing_lib.h26
-rw-r--r--src/lib/exchange_api_lookup_aml_decisions.c7
-rw-r--r--src/mhd/mhd_parsing.c3
-rw-r--r--src/testing/test_kyc_api.c29
-rw-r--r--src/testing/testing_api_cmd_check_aml_decisions.c160
7 files changed, 178 insertions, 146 deletions
diff --git a/src/exchangedb/pg_select_aml_decisions.c b/src/exchangedb/pg_select_aml_decisions.c
index e7603384c..c817e443f 100644
--- a/src/exchangedb/pg_select_aml_decisions.c
+++ b/src/exchangedb/pg_select_aml_decisions.c
@@ -174,42 +174,44 @@ TEH_PG_select_aml_decisions (
PREPARE (pg,
"select_aml_decisions_inc",
"SELECT"
- " outcome_serial_id"
- ",h_payto"
- ",justification"
- ",decision_time"
- ",expiration_time"
- ",jproperties"
- ",to_investigate"
- ",is_active"
- ",jnew_rules"
- " FROM legitimization_outcomes"
- " WHERE outcome_serial_id > $7"
- " ($1 OR (h_payto = $2)) AND"
- " ($3 OR (investigation = $4)) AND"
- " ($5 OR (active = $6))"
- " ORDER BY outcome_serial_id ASC"
+ " lo.outcome_serial_id"
+ ",lo.h_payto"
+ ",ah.justification"
+ ",lo.decision_time"
+ ",lo.expiration_time"
+ ",lo.jproperties"
+ ",lo.to_investigate"
+ ",lo.is_active"
+ ",lo.jnew_rules"
+ " FROM legitimization_outcomes lo"
+ " LEFT JOIN aml_history ah"
+ " USING (outcome_serial_id)"
+ " WHERE (outcome_serial_id > $7)"
+ " AND ($1 OR (lo.h_payto = $2))"
+ " AND ($3 OR (lo.to_investigate = $4))"
+ " AND ($5 OR (lo.is_active = $6))"
+ " ORDER BY lo.outcome_serial_id ASC"
" LIMIT $8");
PREPARE (pg,
"select_aml_decisions_dec",
"SELECT"
- " outcome_serial_id"
- ",h_payto"
- ",justification"
- ",decision_time"
- ",expiration_time"
- ",jproperties"
- ",to_investigate"
- ",is_active"
- ",jnew_rules"
- " FROM legitimization_outcomes"
- " LEFT JOIN aml_history"
- " ON (outcome_serial_id)"
- " WHERE outcome_serial_id < $7"
- " ($1 OR (h_payto = $2)) AND"
- " ($3 OR (investigation = $4)) AND"
- " ($5 OR (active = $6))"
- " ORDER BY outcome_serial_id DESC"
+ " lo.outcome_serial_id"
+ ",lo.h_payto"
+ ",ah.justification"
+ ",lo.decision_time"
+ ",lo.expiration_time"
+ ",lo.jproperties"
+ ",lo.to_investigate"
+ ",lo.is_active"
+ ",lo.jnew_rules"
+ " FROM legitimization_outcomes lo"
+ " LEFT JOIN aml_history ah"
+ " USING (outcome_serial_id)"
+ " WHERE lo.outcome_serial_id < $7"
+ " AND ($1 OR (lo.h_payto = $2))"
+ " AND ($3 OR (lo.to_investigate = $4))"
+ " AND ($5 OR (lo.is_active = $6))"
+ " ORDER BY lo.outcome_serial_id DESC"
" LIMIT $8");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
stmt,
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index 87a9beafd..3b2833a4a 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -764,21 +764,24 @@ TALER_MHD_parse_request_header_data (struct MHD_Connection *connection,
bool p; \
switch (TALER_MHD_parse_request_arg_data (connection, name, \
val, sizeof (*val), &p)) \
- { \
- case GNUNET_SYSERR: \
- GNUNET_break (0); \
- return MHD_NO; \
- case GNUNET_NO: \
- GNUNET_break_op (0); \
- return MHD_YES; \
- case GNUNET_OK: \
- if (required & (! p)) \
- return TALER_MHD_reply_with_error ( \
- connection, \
- MHD_HTTP_BAD_REQUEST, \
- TALER_EC_GENERIC_PARAMETER_MISSING, \
- name); \
- required = p; \
+ { \
+ case GNUNET_SYSERR: \
+ GNUNET_break (0); \
+ return MHD_NO; \
+ case GNUNET_NO: \
+ GNUNET_break_op (0); \
+ return MHD_YES; \
+ case GNUNET_OK: \
+ if (required & (! p)) \
+ { \
+ GNUNET_break_op (0); \
+ return TALER_MHD_reply_with_error ( \
+ connection, \
+ MHD_HTTP_BAD_REQUEST, \
+ TALER_EC_GENERIC_PARAMETER_MISSING, \
+ name); \
+ } \
+ required = p; \
break; \
} \
} while (0)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 37a4afa4d..28bafb33d 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -2501,31 +2501,16 @@ TALER_TESTING_cmd_take_aml_decision (
/**
- * Fetch AML decision.
+ * Fetch and check AML decision.
*
* @param label command label
* @param ref_officer command that previously created an
* officer
* @param ref_operation command that previously created an
- * h_payto which to make an AML decision about
- * @param expected_http_status expected HTTP response status
- * @return the command
- */
-struct TALER_TESTING_Command
-TALER_TESTING_cmd_check_aml_decision (
- const char *label,
- const char *ref_officer,
- const char *ref_operation,
- unsigned int expected_http_status);
-
-
-/**
- * Fetch AML decisions.
- *
- * @param label command label
- * @param ref_officer command that previously created an
- * officer
- * @param filter AML state to filter by
+ * h_payto which to make an AML decision about;
+ * If it has also a justification trait,
+ * we check that this is the current justification
+ * for the latest AML decision.
* @param expected_http_status expected HTTP response status
* @return the command
*/
@@ -2533,6 +2518,7 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_check_aml_decisions (
const char *label,
const char *ref_officer,
+ const char *ref_operation,
unsigned int expected_http_status);
diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c
index 3259ae768..26321d392 100644
--- a/src/lib/exchange_api_lookup_aml_decisions.c
+++ b/src/lib/exchange_api_lookup_aml_decisions.c
@@ -427,6 +427,9 @@ handle_lookup_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_BAD_REQUEST:
+ json_dumpf (j,
+ stderr,
+ JSON_INDENT (2));
lr.hr.ec = TALER_JSON_get_error_code (j);
lr.hr.hint = TALER_JSON_get_error_hint (j);
/* This should never happen, either us or the exchange is buggy
@@ -513,14 +516,14 @@ TALER_EXCHANGE_lookup_aml_decisions (
{
char limit_s[24];
char offset_s[24];
- char payto_s[sizeof (h_payto) * 2];
+ char payto_s[sizeof (*h_payto) * 2];
char *end;
if (NULL != h_payto)
{
end = GNUNET_STRINGS_data_to_string (
h_payto,
- sizeof (h_payto),
+ sizeof (*h_payto),
payto_s,
sizeof (payto_s));
*end = '\0';
diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c
index 1f50edd92..dd1864939 100644
--- a/src/mhd/mhd_parsing.c
+++ b/src/mhd/mhd_parsing.c
@@ -127,12 +127,15 @@ parse_request_data (
strlen (str),
out_data,
out_size))
+ {
+ GNUNET_break_op (0);
return (MHD_NO ==
TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
param_name))
? GNUNET_SYSERR : GNUNET_NO;
+ }
*present = true;
return GNUNET_OK;
}
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index 5a18eb479..2346fe431 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -550,24 +550,35 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
struct TALER_TESTING_Command aml[] = {
- /* Trigger something upon which an AML officer could act */
- TALER_TESTING_cmd_wallet_kyc_get (
- "wallet-trigger-kyc-for-aml",
- NULL,
- "EUR:1000",
- MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
TALER_TESTING_cmd_set_officer (
"create-aml-officer-1",
NULL,
"Peter Falk",
true,
false),
-#if FIXME
TALER_TESTING_cmd_check_aml_decisions (
"check-decisions-none-normal",
"create-aml-officer-1",
- TALER_AML_NORMAL,
+ NULL,
MHD_HTTP_NO_CONTENT),
+ /* Trigger something upon which an AML officer could act */
+ TALER_TESTING_cmd_wallet_kyc_get (
+ "wallet-trigger-kyc-for-aml",
+ NULL,
+ "EUR:1000",
+ MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
+ /* Note: the above created a legitimization_measure, but NOT
+ an actual *decision*, hence nothing shows up here!
+ Design question: is that OK? Don't we need _some_ way
+ to expose this to AML staff? */
+#if FIXME
+ TALER_TESTING_cmd_check_aml_decisions (
+ "check-decisions-wallet-pending",
+ "create-aml-officer-1",
+ "wallet-trigger-kyc-for-aml",
+ MHD_HTTP_OK),
+#endif
+#if FIXME
TALER_TESTING_cmd_check_aml_decisions (
"check-decisions-none-pending",
"create-aml-officer-1",
@@ -702,6 +713,7 @@ run (void *cls,
NULL,
true,
true),
+#if DISABLED || 1
TALER_TESTING_cmd_batch (
"withdraw",
withdraw),
@@ -726,6 +738,7 @@ 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_check_aml_decisions.c b/src/testing/testing_api_cmd_check_aml_decisions.c
index ba019df3c..74ad5f66f 100644
--- a/src/testing/testing_api_cmd_check_aml_decisions.c
+++ b/src/testing/testing_api_cmd_check_aml_decisions.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2023, 2024 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
@@ -30,7 +30,7 @@
/**
- * State for a "check_aml_decision" CMD.
+ * State for a "check_aml_decisions" CMD.
*/
struct AmlCheckState
{
@@ -51,7 +51,10 @@ struct AmlCheckState
const char *ref_officer;
/**
- * Reference to command to the previous set AML status operation.
+ * Reference to a command with a trait of a payto-URI for an account we want
+ * to get the status on; NULL to match all accounts. If it has also a
+ * justification trait, we check that this is the current justification for
+ * the latest AML decision.
*/
const char *ref_operation;
@@ -71,8 +74,9 @@ struct AmlCheckState
* @param adr response details
*/
static void
-check_aml_decision_cb (void *cls,
- const struct TALER_EXCHANGE_AmlDecisionsResponse *adr)
+check_aml_decisions_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_AmlDecisionsResponse *adr)
{
struct AmlCheckState *ds = cls;
@@ -90,41 +94,47 @@ check_aml_decision_cb (void *cls,
const char *justification;
const struct TALER_EXCHANGE_AmlDecision *oldest = NULL;
- ref = TALER_TESTING_interpreter_lookup_command (ds->is,
- ds->ref_operation);
- if (NULL == ref)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ds->is);
- return;
- }
- GNUNET_assert (
- GNUNET_OK ==
- TALER_TESTING_get_trait_aml_justification (ref,
- &justification));
- for (unsigned int i = 0; i<adr->details.ok.decisions_length; i++)
+ if (NULL != ds->ref_operation)
{
- const struct TALER_EXCHANGE_AmlDecision *aml_history
- = &adr->details.ok.decisions[i];
+ ref = TALER_TESTING_interpreter_lookup_command (
+ ds->is,
+ ds->ref_operation);
+ if (NULL == ref)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+ if (GNUNET_OK ==
+ TALER_TESTING_get_trait_aml_justification (
+ ref,
+ &justification))
+ {
+ for (unsigned int i = 0; i<adr->details.ok.decisions_length; i++)
+ {
+ const struct TALER_EXCHANGE_AmlDecision *aml_history
+ = &adr->details.ok.decisions[i];
- if ( (NULL == oldest) ||
- (GNUNET_TIME_timestamp_cmp (oldest->decision_time,
- >,
- aml_history->decision_time)) )
- oldest = aml_history;
- }
- if (NULL == oldest)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ds->is);
- return;
- }
- if (0 != strcmp (oldest->justification,
- justification) )
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ds->is);
- return;
+ if ( (NULL == oldest) ||
+ (GNUNET_TIME_timestamp_cmp (oldest->decision_time,
+ >,
+ aml_history->decision_time)) )
+ oldest = aml_history;
+ }
+ if (NULL == oldest)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+ if (0 != strcmp (oldest->justification,
+ justification) )
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+ }
}
}
TALER_TESTING_interpreter_next (ds->is);
@@ -139,9 +149,10 @@ check_aml_decision_cb (void *cls,
* @param is the interpreter state.
*/
static void
-check_aml_decision_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
+check_aml_decisions_run (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
{
struct AmlCheckState *ds = cls;
const struct TALER_PaytoHashP *h_payto;
@@ -154,32 +165,41 @@ check_aml_decision_run (void *cls,
{
const struct TALER_TESTING_Command *exchange_cmd;
- exchange_cmd = TALER_TESTING_interpreter_get_command (is,
- "exchange");
+ exchange_cmd
+ = TALER_TESTING_interpreter_get_command (
+ is,
+ "exchange");
if (NULL == exchange_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
- GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_exchange_url (exchange_cmd,
- &exchange_url));
+ GNUNET_assert (
+ GNUNET_OK ==
+ TALER_TESTING_get_trait_exchange_url (exchange_cmd,
+ &exchange_url));
}
- ref = TALER_TESTING_interpreter_lookup_command (is,
- ds->ref_operation);
- if (NULL == ref)
+ if (NULL != ds->ref_operation)
{
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (is);
- return;
+ ref = TALER_TESTING_interpreter_lookup_command (
+ is,
+ ds->ref_operation);
+ if (NULL == ref)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_h_payto (
+ ref,
+ &h_payto));
}
- GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_h_payto (ref,
- &h_payto));
- ref = TALER_TESTING_interpreter_lookup_command (is,
- ds->ref_officer);
+ ref = TALER_TESTING_interpreter_lookup_command (
+ is,
+ ds->ref_officer);
if (NULL == ref)
{
GNUNET_break (0);
@@ -187,18 +207,19 @@ check_aml_decision_run (void *cls,
return;
}
GNUNET_assert (GNUNET_OK ==
- TALER_TESTING_get_trait_officer_priv (ref,
- &officer_priv));
+ TALER_TESTING_get_trait_officer_priv (
+ ref,
+ &officer_priv));
ds->dh = TALER_EXCHANGE_lookup_aml_decisions (
TALER_TESTING_interpreter_get_context (is),
exchange_url,
- h_payto,
+ h_payto, /* NULL to return all */
TALER_EXCHANGE_YNA_ALL,
TALER_EXCHANGE_YNA_ALL,
- UINT64_MAX,
- -1,
+ UINT64_MAX, /* offset */
+ -1, /* limit */
officer_priv,
- &check_aml_decision_cb,
+ &check_aml_decisions_cb,
ds);
if (NULL == ds->dh)
{
@@ -217,8 +238,9 @@ check_aml_decision_run (void *cls,
* @param cmd the command which is being cleaned up.
*/
static void
-check_aml_decision_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
+check_aml_decisions_cleanup (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
struct AmlCheckState *ds = cls;
@@ -234,7 +256,7 @@ check_aml_decision_cleanup (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_check_aml_decision (
+TALER_TESTING_cmd_check_aml_decisions (
const char *label,
const char *ref_officer,
const char *ref_operation,
@@ -250,8 +272,8 @@ TALER_TESTING_cmd_check_aml_decision (
struct TALER_TESTING_Command cmd = {
.cls = ds,
.label = label,
- .run = &check_aml_decision_run,
- .cleanup = &check_aml_decision_cleanup
+ .run = &check_aml_decisions_run,
+ .cleanup = &check_aml_decisions_cleanup
};
return cmd;
@@ -259,4 +281,4 @@ TALER_TESTING_cmd_check_aml_decision (
}
-/* end of testing_api_cmd_check_aml_decision.c */
+/* end of testing_api_cmd_check_aml_decisions.c */