diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-11-03 12:37:29 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-11-05 10:37:38 +0100 |
commit | 7117eee5916e7e8013bb948a8275a4d1c5c67c8b (patch) | |
tree | bb84ba13d847f15419bd83ea430540ae42b03e46 | |
parent | 3f31dd425fad784008f59e0e76e10fbae378f1ce (diff) |
work on tests
-rw-r--r-- | src/exchange/taler-exchange-httpd_common_kyc.c | 30 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_kyc-check.c | 4 | ||||
-rw-r--r-- | src/exchangedb/0007-legitimization_outcomes.sql | 43 | ||||
-rw-r--r-- | src/exchangedb/exchange-0007.sql.in | 1 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql | 15 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_h_payto_by_access_token.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_lookup_pending_legitimization.c | 2 | ||||
-rw-r--r-- | src/util/payto.c | 8 |
8 files changed, 98 insertions, 7 deletions
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c index c7f1cef76..ae516abd4 100644 --- a/src/exchange/taler-exchange-httpd_common_kyc.c +++ b/src/exchange/taler-exchange-httpd_common_kyc.c @@ -34,6 +34,11 @@ */ #define MAX_LEGI_LOOPS 5 +/** + * Enable additional sanity-checks for debugging? + */ +#define EXTRA_CHECK 0 + struct TEH_KycAmlTrigger { @@ -1203,6 +1208,17 @@ setup_legitimization_check ( { struct TEH_LegitimizationCheckHandle *lch; +#if EXTRA_CHECK + { + struct TALER_NormalizedPaytoHashP npt; + + TALER_full_payto_normalize_and_hash (payto_uri, + &npt); + GNUNET_assert (0 == + GNUNET_memcmp (&npt, + h_payto)); + } +#endif lch = GNUNET_new (struct TEH_LegitimizationCheckHandle); lch->scope = *scope; lch->et = et; @@ -1462,6 +1478,20 @@ run_check ( enum GNUNET_DB_QueryStatus qs; /* require kcc.check! */ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Requiring KYC for `%s'\n", + lch->payto_uri.full_payto); +#if EXTRA_CHECK + { + struct TALER_NormalizedPaytoHashP npt; + + TALER_full_payto_normalize_and_hash (lch->payto_uri, + &npt); + GNUNET_assert (0 == + GNUNET_memcmp (&npt, + &lch->h_payto)); + } +#endif qs = TEH_plugin->trigger_kyc_rule_for_account ( TEH_plugin->cls, lch->payto_uri, diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c index f51631f5f..3bd8c1e65 100644 --- a/src/exchange/taler-exchange-httpd_kyc-check.c +++ b/src/exchange/taler-exchange-httpd_kyc-check.c @@ -220,7 +220,9 @@ TEH_handler_kyc_check ( TALER_EC_GENERIC_PATH_SEGMENT_MALFORMED, "h_payto"); } - + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Checking KYC status for normalized payto hash %s\n", + args[0]); TALER_MHD_parse_request_header_auto ( rc->connection, TALER_HTTP_HEADER_ACCOUNT_OWNER_SIGNATURE, diff --git a/src/exchangedb/0007-legitimization_outcomes.sql b/src/exchangedb/0007-legitimization_outcomes.sql new file mode 100644 index 000000000..251fe7f12 --- /dev/null +++ b/src/exchangedb/0007-legitimization_outcomes.sql @@ -0,0 +1,43 @@ +-- +-- This file is part of TALER +-- Copyright (C) 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 the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +CREATE FUNCTION foreign_table_legitimization_outcomes7() +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + table_name TEXT DEFAULT 'legitimization_outcomes'; +BEGIN + + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' DROP CONSTRAINT ' || table_name || '_foreign_key_h_payto'); +END +$$; + + +INSERT INTO exchange_tables + (name + ,version + ,action + ,partitioned + ,by_range) + VALUES + ('legitimization_outcomes7' + ,'exchange-0007' + ,'foreign' + ,TRUE + ,FALSE); diff --git a/src/exchangedb/exchange-0007.sql.in b/src/exchangedb/exchange-0007.sql.in index c71dc75a4..6d634e22c 100644 --- a/src/exchangedb/exchange-0007.sql.in +++ b/src/exchangedb/exchange-0007.sql.in @@ -20,6 +20,7 @@ SELECT _v.register_patch('exchange-0007', NULL, NULL); SET search_path TO exchange; #include "0007-wire_targets.sql" +#include "0007-legitimization_outcomes.sql" COMMIT; diff --git a/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql b/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql index e9a22aa84..c36f0be6f 100644 --- a/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql +++ b/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql @@ -18,7 +18,7 @@ DROP FUNCTION IF EXISTS exchange_do_lookup_kyc_requirement_by_row; CREATE FUNCTION exchange_do_lookup_kyc_requirement_by_row( - IN in_h_payto BYTEA, + IN in_h_normalized_payto BYTEA, OUT out_account_pub BYTEA, -- NULL allowed OUT out_reserve_pub BYTEA, -- NULL allowed OUT out_access_token BYTEA, -- NULL if 'out_not_found' @@ -38,7 +38,7 @@ SELECT access_token ,target_pub INTO my_wtrec FROM wire_targets - WHERE wire_target_h_payto=in_h_payto; + WHERE h_normalized_payto=in_h_normalized_payto; IF NOT FOUND THEN @@ -66,7 +66,7 @@ SELECT jnew_rules ,to_investigate INTO my_lorec FROM legitimization_outcomes - WHERE h_payto=in_h_payto + WHERE h_payto=in_h_normalized_payto AND is_active; IF FOUND @@ -80,8 +80,15 @@ END IF; SELECT reserve_pub INTO out_reserve_pub FROM reserves_in - WHERE wire_source_h_payto=in_h_payto + WHERE wire_source_h_payto + IN (SELECT wire_source_h_payto + FROM wire_targets + WHERE h_normalized_payto=in_h_normalized_payto) ORDER BY execution_date DESC LIMIT 1; +-- FIXME: may want to turn this around and pass *in* the +-- reserve_pub as an argument and then not LIMIT 1 but check +-- if any reserve_pub ever matched (and just return a BOOL +-- to indicate if the kyc-auth is OK). END $$; diff --git a/src/exchangedb/pg_lookup_h_payto_by_access_token.c b/src/exchangedb/pg_lookup_h_payto_by_access_token.c index 1ed2874c5..79a516bf8 100644 --- a/src/exchangedb/pg_lookup_h_payto_by_access_token.c +++ b/src/exchangedb/pg_lookup_h_payto_by_access_token.c @@ -39,7 +39,7 @@ TEH_PG_lookup_h_payto_by_access_token ( }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ( - "wire_target_h_payto", + "h_normalized_payto", h_payto), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/pg_lookup_pending_legitimization.c b/src/exchangedb/pg_lookup_pending_legitimization.c index bc1e6e8df..7c5a036d5 100644 --- a/src/exchangedb/pg_lookup_pending_legitimization.c +++ b/src/exchangedb/pg_lookup_pending_legitimization.c @@ -45,7 +45,7 @@ TEH_PG_lookup_pending_legitimization ( "jmeasures", jmeasures), GNUNET_PQ_result_spec_auto_from_type ( - "wire_target_h_payto", + "h_normalized_payto", h_payto), GNUNET_PQ_result_spec_auto_from_type ( "access_token", diff --git a/src/util/payto.c b/src/util/payto.c index a0034b074..947db3c7d 100644 --- a/src/util/payto.c +++ b/src/util/payto.c @@ -723,6 +723,10 @@ TALER_normalized_payto_hash (const struct TALER_NormalizedPayto npayto, GNUNET_memcpy (h_npayto, &sha512, sizeof (*h_npayto)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Normalized hash of normalized payto `%s' is %16s\n", + npayto.normalized_payto, + GNUNET_h2s_full (&sha512)); } @@ -740,6 +744,10 @@ TALER_full_payto_hash (const struct TALER_FullPayto fpayto, GNUNET_memcpy (h_fpayto, &sha512, sizeof (*h_fpayto)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Full hash of full payto `%s' is %16s\n", + fpayto.full_payto, + GNUNET_h2s_full (&sha512)); } |