diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-depositcheck.c | 12 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c | 77 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-pos.c | 2 | ||||
-rw-r--r-- | src/backenddb/Makefile.am | 1 | ||||
-rw-r--r-- | src/backenddb/merchant-0010.sql | 35 | ||||
-rw-r--r-- | src/backenddb/pg_account_kyc_get_status.c | 20 | ||||
-rw-r--r-- | src/backenddb/pg_account_kyc_set_status.c | 25 | ||||
-rw-r--r-- | src/backenddb/pg_account_kyc_set_status.h | 23 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 21 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 4 | ||||
-rw-r--r-- | src/include/taler_merchant_testing_lib.h | 126 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 41 | ||||
-rw-r--r-- | src/lib/Makefile.am | 2 | ||||
-rw-r--r-- | src/lib/merchant_api_get_kyc.c | 2 | ||||
-rw-r--r-- | src/testing/test_kyc_api.c | 41 | ||||
-rw-r--r-- | src/testing/test_merchant_api.c | 217 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_kyc_get.c | 32 |
17 files changed, 323 insertions, 358 deletions
diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c index 9245e1fb..cd0242f0 100644 --- a/src/backend/taler-merchant-depositcheck.c +++ b/src/backend/taler-merchant-depositcheck.c @@ -457,9 +457,8 @@ deposit_get_cb (void *cls, struct GNUNET_TIME_Timestamp now; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Exchange returned KYC requirement (%d/%d) for deposited coin %s\n", + "Exchange returned KYC requirement (%d) for deposited coin %s\n", dr->details.accepted.kyc_ok, - dr->details.accepted.aml_decision, TALER_B2S (&w->coin_pub)); now = GNUNET_TIME_timestamp_get (); qs = db_plugin->account_kyc_set_status ( @@ -468,20 +467,15 @@ deposit_get_cb (void *cls, &w->h_wire, exchange_url, dr->details.accepted.requirement_row, - NULL, - NULL, now, - dr->details.accepted.kyc_ok, - dr->details.accepted.aml_decision); + dr->details.accepted.kyc_ok); if (qs < 0) { GNUNET_break (0); GNUNET_SCHEDULER_shutdown (); return; } - if (dr->details.accepted.kyc_ok && - (TALER_AML_NORMAL == - dr->details.accepted.aml_decision)) + if (dr->details.accepted.kyc_ok) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Bumping wire transfer deadline in DB to %s as that is when we will retry\n", diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c index 0382b742..7c2081a6 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c @@ -488,37 +488,20 @@ exchange_check_cb (void *cls, struct KycContext *kc = ekr->kc; ekr->kyc = NULL; - switch (ks->http_status) + switch (ks->hr.http_status) { case MHD_HTTP_OK: { enum GNUNET_DB_QueryStatus qs; - if (TALER_AML_NORMAL != ks->details.ok.aml_status) - { - GNUNET_assert ( - 0 == - json_array_append_new ( - kc->pending_kycs, - GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ( - "aml_status", - ks->details.ok.aml_status), - GNUNET_JSON_pack_string ("exchange_url", - ekr->exchange_url), - GNUNET_JSON_pack_string ("payto_uri", - ekr->payto_uri)))); - } - qs = TMH_db->account_kyc_set_status (TMH_db->cls, - kc->mi->settings.id, - &ekr->h_wire, - ekr->exchange_url, - ekr->exchange_kyc_serial, - &ks->details.ok.exchange_sig, - &ks->details.ok.exchange_pub, - ks->details.ok.timestamp, - true, /* KYC OK */ - ks->details.ok.aml_status); + qs = TMH_db->account_kyc_set_status ( + TMH_db->cls, + kc->mi->settings.id, + &ekr->h_wire, + ekr->exchange_url, + ekr->exchange_kyc_serial, + GNUNET_TIME_timestamp_get (), + true); if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -536,10 +519,6 @@ exchange_check_cb (void *cls, json_array_append_new ( kc->pending_kycs, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("kyc_url", - ks->details.accepted.kyc_url), - GNUNET_JSON_pack_uint64 ("aml_status", - ks->details.accepted.aml_status), GNUNET_JSON_pack_string ("exchange_url", ekr->exchange_url), GNUNET_JSON_pack_string ("payto_uri", @@ -551,11 +530,8 @@ exchange_check_cb (void *cls, &ekr->h_wire, ekr->exchange_url, ekr->exchange_kyc_serial, - NULL, - NULL, now, - false, /* KYC not OK */ - ks->details.accepted.aml_status); + false); if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -574,11 +550,8 @@ exchange_check_cb (void *cls, &ekr->h_wire, ekr->exchange_url, ekr->exchange_kyc_serial, - NULL, - NULL, now, - true, /* KYC OK */ - TALER_AML_NORMAL); + true); if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -596,9 +569,6 @@ exchange_check_cb (void *cls, json_array_append_new ( kc->pending_kycs, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_uint64 ( - "aml_status", - ks->details.unavailable_for_legal_reasons.aml_status), GNUNET_JSON_pack_string ("exchange_url", ekr->exchange_url), GNUNET_JSON_pack_string ("payto_uri", @@ -610,11 +580,8 @@ exchange_check_cb (void *cls, &ekr->h_wire, ekr->exchange_url, ekr->exchange_kyc_serial, - NULL, - NULL, now, - true, /* KYC is OK, AML not... */ - ks->details.unavailable_for_legal_reasons.aml_status); + true); if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -625,8 +592,8 @@ exchange_check_cb (void *cls, default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Exchange responded with HTTP status %u (%d) to /kyc-check request!\n", - ks->http_status, - ks->ec); + ks->hr.http_status, + ks->hr.ec); kc->response_code = MHD_HTTP_BAD_GATEWAY; GNUNET_assert ( 0 == @@ -636,9 +603,9 @@ exchange_check_cb (void *cls, GNUNET_JSON_pack_string ("exchange_url", ekr->exchange_url), GNUNET_JSON_pack_uint64 ("exchange_code", - ks->ec), + ks->hr.ec), GNUNET_JSON_pack_uint64 ("exchange_http_status", - ks->http_status)))); + ks->hr.http_status)))); } ekr_finished (ekr); } @@ -660,6 +627,8 @@ kyc_with_exchange (void *cls, struct ExchangeKycRequest *ekr = cls; struct KycContext *kc = ekr->kc; struct TALER_PaytoHashP h_payto; + union TALER_AccountPrivateKeyP ap; + (void) exchange; ekr->fo = NULL; @@ -678,13 +647,12 @@ kyc_with_exchange (void *cls, } TALER_payto_hash (ekr->payto_uri, &h_payto); + ap.merchant_priv = kc->mi->merchant_priv; ekr->kyc = TALER_EXCHANGE_kyc_check ( TMH_curl_ctx, ekr->exchange_url, - keys, ekr->exchange_kyc_serial, - &h_payto, - 1, /* FIXME: this will go away! */ + &ap, GNUNET_TIME_absolute_get_remaining (kc->timeout), &exchange_check_cb, ekr); @@ -702,7 +670,6 @@ kyc_with_exchange (void *cls, * @param exchange_url base URL of the exchange for which this is a status * @param last_check when did we last get an update on our KYC status from the exchange * @param kyc_ok true if we satisfied the KYC requirements - * @param aml_decision latest AML decision known to us */ static void kyc_status_cb (void *cls, @@ -711,14 +678,12 @@ kyc_status_cb (void *cls, const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision) + bool kyc_ok) { struct KycContext *kc = cls; struct ExchangeKycRequest *ekr; if (kyc_ok && - (TALER_AML_PENDING != aml_decision) && (GNUNET_TIME_relative_cmp ( GNUNET_TIME_absolute_get_duration (last_check.abs_time), <, diff --git a/src/backend/taler-merchant-httpd_private-get-pos.c b/src/backend/taler-merchant-httpd_private-get-pos.c index d1230243..1595d3a2 100644 --- a/src/backend/taler-merchant-httpd_private-get-pos.c +++ b/src/backend/taler-merchant-httpd_private-get-pos.c @@ -20,7 +20,7 @@ */ #include "platform.h" #include "taler-merchant-httpd_private-get-pos.h" - +#include <taler/taler_json_lib.h> /** * Closure for add_product(). diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am index 52737c2b..1703f20c 100644 --- a/src/backenddb/Makefile.am +++ b/src/backenddb/Makefile.am @@ -26,6 +26,7 @@ sql_DATA = \ merchant-0007.sql \ merchant-0008.sql \ merchant-0009.sql \ + merchant-0010.sql \ drop.sql BUILT_SOURCES = \ diff --git a/src/backenddb/merchant-0010.sql b/src/backenddb/merchant-0010.sql new file mode 100644 index 00000000..e7ac0dc3 --- /dev/null +++ b/src/backenddb/merchant-0010.sql @@ -0,0 +1,35 @@ +-- +-- 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/> +-- + +-- @file merchant-0010.sql +-- @brief Remove dead aml_decision column +-- @author Christian Grothoff + +-- Everything in one big transaction +BEGIN; + +-- Check patch versioning is in place. +SELECT _v.register_patch('merchant-0010', NULL, NULL); + +SET search_path TO merchant; + +ALTER TABLE merchant_kyc + DROP COLUMN aml_decision + ,DROP COLUMN exchange_sig + ,DROP COLUMN exchange_pub; + +-- Complete transaction +COMMIT; diff --git a/src/backenddb/pg_account_kyc_get_status.c b/src/backenddb/pg_account_kyc_get_status.c index 1c7c5792..c2e97276 100644 --- a/src/backenddb/pg_account_kyc_get_status.c +++ b/src/backenddb/pg_account_kyc_get_status.c @@ -85,7 +85,6 @@ kyc_status_cb (void *cls, char *payto_uri; struct GNUNET_TIME_Timestamp last_check; bool kyc_ok; - uint32_t aml_decision; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), @@ -99,8 +98,6 @@ kyc_status_cb (void *cls, &last_check), GNUNET_PQ_result_spec_bool ("kyc_ok", &kyc_ok), - GNUNET_PQ_result_spec_uint32 ("aml_decision", - &aml_decision), GNUNET_PQ_result_spec_end }; @@ -134,20 +131,20 @@ kyc_status_cb (void *cls, payto_uri, exchange_url, last_check, - kyc_ok, - (enum TALER_AmlDecisionState) aml_decision); + kyc_ok); GNUNET_PQ_cleanup_result (rs); } } enum GNUNET_DB_QueryStatus -TMH_PG_account_kyc_get_status (void *cls, - const char *merchant_id, - const struct TALER_MerchantWireHashP *h_wire, - const char *exchange_url, - TALER_MERCHANTDB_KycCallback kyc_cb, - void *kyc_cb_cls) +TMH_PG_account_kyc_get_status ( + void *cls, + const char *merchant_id, + const struct TALER_MerchantWireHashP *h_wire, + const char *exchange_url, + TALER_MERCHANTDB_KycCallback kyc_cb, + void *kyc_cb_cls) { struct PostgresClosure *pg = cls; struct KycStatusContext ksc = { @@ -172,7 +169,6 @@ TMH_PG_account_kyc_get_status (void *cls, ",exchange_url" ",kyc_timestamp" ",kyc_ok" - ",aml_decision" " FROM merchant_instances" " JOIN merchant_accounts" " USING (merchant_serial)" diff --git a/src/backenddb/pg_account_kyc_set_status.c b/src/backenddb/pg_account_kyc_set_status.c index 6c69c448..444b263c 100644 --- a/src/backenddb/pg_account_kyc_set_status.c +++ b/src/backenddb/pg_account_kyc_set_status.c @@ -32,14 +32,10 @@ TMH_PG_account_kyc_set_status ( const struct TALER_MerchantWireHashP *h_wire, const char *exchange_url, uint64_t exchange_kyc_serial, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_ExchangePublicKeyP *exchange_pub, struct GNUNET_TIME_Timestamp timestamp, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision) + bool kyc_ok) { struct PostgresClosure *pg = cls; - uint32_t aml32 = (uint32_t) aml_decision; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (merchant_id), GNUNET_PQ_query_param_auto_from_type (h_wire), @@ -47,13 +43,6 @@ TMH_PG_account_kyc_set_status ( GNUNET_PQ_query_param_uint64 (&exchange_kyc_serial), GNUNET_PQ_query_param_timestamp (×tamp), GNUNET_PQ_query_param_bool (kyc_ok), - exchange_pub - ? GNUNET_PQ_query_param_auto_from_type (exchange_pub) - : GNUNET_PQ_query_param_null (), - exchange_sig - ? GNUNET_PQ_query_param_auto_from_type (exchange_sig) - : GNUNET_PQ_query_param_null (), - GNUNET_PQ_query_param_uint32 (&aml32), GNUNET_PQ_query_param_end }; @@ -65,11 +54,8 @@ TMH_PG_account_kyc_set_status ( ",kyc_ok" ",exchange_kyc_serial" ",account_serial" - ",exchange_url" - ",exchange_pub" - ",exchange_sig" - ",aml_decision)" - " SELECT $5, $6, $4, account_serial, $3, $7, $8, $9" + ",exchange_url)" + " SELECT $5, $6, $4, account_serial, $3" " FROM merchant_instances" " JOIN merchant_accounts USING (merchant_serial)" " WHERE merchant_id=$1" @@ -78,10 +64,7 @@ TMH_PG_account_kyc_set_status ( "UPDATE" " SET exchange_kyc_serial=$4" " ,kyc_timestamp=$5" - " ,kyc_ok=$6" - " ,exchange_pub=$7" - " ,exchange_sig=$8" - " ,aml_decision=$9"); + " ,kyc_ok=$6"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "upsert_account_kyc", params); diff --git a/src/backenddb/pg_account_kyc_set_status.h b/src/backenddb/pg_account_kyc_set_status.h index c9869242..84abe48a 100644 --- a/src/backenddb/pg_account_kyc_set_status.h +++ b/src/backenddb/pg_account_kyc_set_status.h @@ -33,25 +33,18 @@ * @param h_wire hash of the wire account to check * @param exchange_url base URL of the exchange to check * @param exchange_kyc_serial serial number for our account at the exchange (0 if unknown) - * @param exchange_sig signature of the exchange, or NULL for none - * @param exchange_pub public key of the exchange, or NULL for none * @param timestamp timestamp to store * @param kyc_ok current KYC status (true for satisfied) - * @param aml_decision current AML decision state at the exchange * @return database result code */ enum GNUNET_DB_QueryStatus -TMH_PG_account_kyc_set_status (void *cls, - const char *merchant_id, - const struct TALER_MerchantWireHashP *h_wire, - const char *exchange_url, - uint64_t exchange_kyc_serial, - const struct - TALER_ExchangeSignatureP *exchange_sig, - const struct - TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Timestamp timestamp, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision); +TMH_PG_account_kyc_set_status ( + void *cls, + const char *merchant_id, + const struct TALER_MerchantWireHashP *h_wire, + const char *exchange_url, + uint64_t exchange_kyc_serial, + struct GNUNET_TIME_Timestamp timestamp, + bool kyc_ok); #endif diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 3591a133..5f8b5eb7 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -5572,8 +5572,7 @@ kyc_status_ok (void *cls, const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok, - enum TALER_AmlDecisionState ades) + bool kyc_ok) { bool *fail = cls; @@ -5589,8 +5588,7 @@ kyc_status_fail (void *cls, const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok, - enum TALER_AmlDecisionState ades) + bool kyc_ok) { bool *fail = cls; @@ -5627,33 +5625,24 @@ test_kyc (void) &account.h_wire, "https://exchange.net/", 1LLU, - NULL, - NULL, now, - false, - TALER_AML_NORMAL)); + false)); TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->account_kyc_set_status (plugin->cls, instance.instance.id, &account.h_wire, "https://exchange2.com/", 1LLU, - NULL, - NULL, now, - false, - TALER_AML_NORMAL)); + false)); TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->account_kyc_set_status (plugin->cls, instance.instance.id, &account.h_wire, "https://exchange.net/", 1LLU, - NULL, - NULL, now, - true, - TALER_AML_NORMAL)); + true)); fail = true; TEST_RET_ON_FAIL (1 != plugin->account_kyc_get_status (plugin->cls, diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 63be079a..15c1f759 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -4401,10 +4401,6 @@ struct TALER_MERCHANT_AccountKycRedirectDetail */ const char *payto_uri; - /** - * AML state for our account. - */ - enum TALER_AmlDecisionState aml_status; }; diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index d4b5bd27..c67d4959 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -35,7 +35,7 @@ #define MERCHANT_FAIL() \ - do {GNUNET_break (0); return NULL; } while (0) + do {GNUNET_break (0); return NULL; } while (0) /** @@ -1260,7 +1260,7 @@ TALER_TESTING_cmd_merchant_delete_transfer (const char *label, * of the bank account to check KYC for; NULL to check all accounts * @param exchange_url base URL of the exchange to check KYC status for * @param expected_http_status expected HTTP status - * @param expected_aml_state expected AML state (only effective if @e expected_http_status is #MHD_HTTP_OK) + * @param expected_kyc_state expected KYC state (only effective if @e expected_http_status is #MHD_HTTP_OK/#MHD_HTTP_ACCEPTED) * @return the command */ struct TALER_TESTING_Command @@ -1271,7 +1271,7 @@ TALER_TESTING_cmd_merchant_kyc_get ( const char *h_wire_ref, const char *exchange_url, unsigned int expected_http_status, - enum TALER_AmlDecisionState expected_aml_state); + bool expected_kyc_state); /* ****** OTP devices ******* */ @@ -1797,52 +1797,52 @@ TALER_TESTING_cmd_checkserver2 (const char *label, */ // FIXME: rename: refund_entry->refund_detail #define TALER_MERCHANT_TESTING_SIMPLE_TRAITS(op) \ - op (claim_nonce, const struct GNUNET_CRYPTO_EddsaPublicKey) \ - op (pickup_id, const struct TALER_PickupIdentifierP) \ - op (instance_name, const char) \ - op (instance_id, const char) \ - op (address, const json_t) \ - op (product_description, const char) \ - op (product_image, const char) \ - op (product_stock, const int64_t) \ - op (product_unit, const char) \ - op (product_id, const char) \ - op (reason, const char) \ - op (lock_uuid, const char) \ - op (auth_token, const char) \ - op (paths_length, const uint32_t) \ - op (payto_length, const uint32_t) \ - op (num_planchets, const uint32_t) \ - op (i18n_description, const json_t) \ - op (taxes, const json_t) \ - op (fee, const struct TALER_Amount) \ - op (use_stefan, const bool) \ - op (jurisdiction, const json_t) \ - op (wire_delay, const struct GNUNET_TIME_Relative) \ - op (pay_delay, const struct GNUNET_TIME_Relative) \ - op (refund_entry, const struct TALER_MERCHANT_RefundDetail) \ - op (order_terms, const json_t) \ - op (h_contract_terms, const struct TALER_PrivateContractHashP) \ - op (h_wire, const struct TALER_MerchantWireHashP) \ - op (proposal_reference, const char) \ - op (template_description, const char) \ - op (otp_device_description, const char) \ - op (otp_id, const char) \ - op (otp_key, const char) \ - op (otp_alg, const enum TALER_MerchantConfirmationAlgorithm) \ - op (template_id, const char) \ - op (template_contract, const json_t) \ - op (event_type, const char) \ - op (webhook_id, const char) \ - op (merchant_base_url, const char) \ - op (url, const char) \ - op (http_method, const char) \ - op (header_template, const char) \ - op (body_template, const char) \ - op (summary, const char) \ - op (token_family_slug, const char) \ - op (token_family_duration, const struct GNUNET_TIME_Relative) \ - op (token_family_kind, const char) + op (claim_nonce, const struct GNUNET_CRYPTO_EddsaPublicKey) \ + op (pickup_id, const struct TALER_PickupIdentifierP) \ + op (instance_name, const char) \ + op (instance_id, const char) \ + op (address, const json_t) \ + op (product_description, const char) \ + op (product_image, const char) \ + op (product_stock, const int64_t) \ + op (product_unit, const char) \ + op (product_id, const char) \ + op (reason, const char) \ + op (lock_uuid, const char) \ + op (auth_token, const char) \ + op (paths_length, const uint32_t) \ + op (payto_length, const uint32_t) \ + op (num_planchets, const uint32_t) \ + op (i18n_description, const json_t) \ + op (taxes, const json_t) \ + op (fee, const struct TALER_Amount) \ + op (use_stefan, const bool) \ + op (jurisdiction, const json_t) \ + op (wire_delay, const struct GNUNET_TIME_Relative) \ + op (pay_delay, const struct GNUNET_TIME_Relative) \ + op (refund_entry, const struct TALER_MERCHANT_RefundDetail) \ + op (order_terms, const json_t) \ + op (h_contract_terms, const struct TALER_PrivateContractHashP) \ + op (h_wire, const struct TALER_MerchantWireHashP) \ + op (proposal_reference, const char) \ + op (template_description, const char) \ + op (otp_device_description, const char) \ + op (otp_id, const char) \ + op (otp_key, const char) \ + op (otp_alg, const enum TALER_MerchantConfirmationAlgorithm) \ + op (template_id, const char) \ + op (template_contract, const json_t) \ + op (event_type, const char) \ + op (webhook_id, const char) \ + op (merchant_base_url, const char) \ + op (url, const char) \ + op (http_method, const char) \ + op (header_template, const char) \ + op (body_template, const char) \ + op (summary, const char) \ + op (token_family_slug, const char) \ + op (token_family_duration, const struct GNUNET_TIME_Relative) \ + op (token_family_kind, const char) /** @@ -1851,20 +1851,20 @@ TALER_TESTING_cmd_checkserver2 (const char *label, * @param op macro to call */ #define TALER_MERCHANT_TESTING_INDEXED_TRAITS(op) \ - op (coin_reference, const char) \ - op (paths, const char) \ - op (payto_uris, const char) \ - op (h_wires, const struct TALER_MerchantWireHashP) \ - op (amounts, const struct TALER_Amount) \ - op (urls, const char) \ - op (http_methods, const char) \ - op (http_header, const char) \ - op (http_body, const void) \ - op (http_body_size, const size_t) \ - op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ - op (token_priv, const struct TALER_TokenUsePrivateKeyP) \ - op (token_issue_sig, const struct TALER_TokenIssueSignatureP) \ - op (token_issue_pub, const struct TALER_TokenIssuePublicKeyP) + op (coin_reference, const char) \ + op (paths, const char) \ + op (payto_uris, const char) \ + op (h_wires, const struct TALER_MerchantWireHashP) \ + op (amounts, const struct TALER_Amount) \ + op (urls, const char) \ + op (http_methods, const char) \ + op (http_header, const char) \ + op (http_body, const void) \ + op (http_body_size, const size_t) \ + op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ + op (token_priv, const struct TALER_TokenUsePrivateKeyP) \ + op (token_issue_sig, const struct TALER_TokenIssueSignatureP) \ + op (token_issue_pub, const struct TALER_TokenIssuePublicKeyP) TALER_MERCHANT_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT) diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 0b41ddcb..3f27a138 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -799,7 +799,6 @@ typedef void * @param exchange_url base URL of the exchange for which this is a status * @param last_check when did we last get an update on our KYC status from the exchange * @param kyc_ok true if we satisfied the KYC requirements - * @param aml_decision current AML decision state at the exchange */ typedef void (*TALER_MERCHANTDB_KycCallback)( @@ -809,8 +808,7 @@ typedef void const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision); + bool kyc_ok); /** @@ -1685,24 +1683,19 @@ struct TALER_MERCHANTDB_Plugin * @param h_wire hash of the wire account to check * @param exchange_url base URL of the exchange to check * @param exchange_kyc_serial serial number for our account at the exchange (0 if unknown) - * @param exchange_sig signature of the exchange, or NULL for none - * @param exchange_pub public key of the exchange, or NULL for none * @param timestamp timestamp to store * @param kyc_ok current KYC status (true for satisfied) - * @param aml_decision current AML decision state at the exchange * @return database result code */ enum GNUNET_DB_QueryStatus - (*account_kyc_set_status)(void *cls, - const char *merchant_id, - const struct TALER_MerchantWireHashP *h_wire, - const char *exchange_url, - uint64_t exchange_kyc_serial, - const struct TALER_ExchangeSignatureP *exchange_sig, - const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Timestamp timestamp, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision); + (*account_kyc_set_status)( + void *cls, + const char *merchant_id, + const struct TALER_MerchantWireHashP *h_wire, + const char *exchange_url, + uint64_t exchange_kyc_serial, + struct GNUNET_TIME_Timestamp timestamp, + bool kyc_ok); /** @@ -2275,7 +2268,6 @@ struct TALER_MERCHANTDB_Plugin void *rc_cls); - /** * Retrieve details about tokens that were used for an order. * @@ -2548,8 +2540,10 @@ struct TALER_MERCHANTDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_spent_token)(void *cls, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, + const struct TALER_PrivateContractHashP * + h_contract_terms, + const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub + , const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, const struct TALER_TokenIssueSignatureP *issue_sig); @@ -2566,9 +2560,12 @@ struct TALER_MERCHANTDB_Plugin */ enum GNUNET_DB_QueryStatus (*insert_issued_token) (void *cls, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenIssueBlindSignatureP *blind_sig); + const struct TALER_PrivateContractHashP * + h_contract_terms, + const struct TALER_TokenIssuePublicKeyHashP * + h_issue_pub, + const struct TALER_TokenIssueBlindSignatureP * + blind_sig); /** diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 4e6a901a..c895aaf4 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -10,7 +10,7 @@ lib_LTLIBRARIES = \ libtalermerchant.la libtalermerchant_la_LDFLAGS = \ - -version-info 6:0:0 \ + -version-info 7:0:0 \ -no-undefined libtalermerchant_la_SOURCES = \ diff --git a/src/lib/merchant_api_get_kyc.c b/src/lib/merchant_api_get_kyc.c index d2a819ea..a6048fc6 100644 --- a/src/lib/merchant_api_get_kyc.c +++ b/src/lib/merchant_api_get_kyc.c @@ -116,8 +116,6 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc, TALER_JSON_spec_web_url ("kyc_url", &pending_kycs[i].kyc_url), NULL), - TALER_JSON_spec_aml_decision ("aml_status", - &pending_kycs[i].aml_status), TALER_JSON_spec_web_url ("exchange_url", &pending_kycs[i].exchange_url), TALER_JSON_spec_payto_uri ("payto_uri", diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 6ef40b45..a9d79715 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -101,8 +101,9 @@ static char *merchant_url_i1a; * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator_with_kyc (label "-aggregator", CONFIG_FILE), \ - TALER_TESTING_cmd_exec_transfer (label "-transfer", CONFIG_FILE) + TALER_TESTING_cmd_exec_aggregator_with_kyc (label "-aggregator", \ + CONFIG_FILE), \ + TALER_TESTING_cmd_exec_transfer (label "-transfer", CONFIG_FILE) /** @@ -228,7 +229,7 @@ run (void *cls, NULL, EXCHANGE_URL, MHD_HTTP_NO_CONTENT, - TALER_AML_NORMAL), + false), /* now we get the legi UUID by running taler-merchant-depositcheck */ TALER_TESTING_cmd_depositcheck ( "deposit-check", @@ -241,7 +242,7 @@ run (void *cls, NULL, EXCHANGE_URL, MHD_HTTP_ACCEPTED, - TALER_AML_NORMAL), + true), TALER_TESTING_cmd_proof_kyc_oauth2 ( "kyc-do", "kyc-pending", @@ -295,10 +296,18 @@ run (void *cls, "freeze", "aml-officer", "post-transfer-1", - "EUR:1", + true /* keep investigating */, + GNUNET_TIME_UNIT_HOURS /* expiration */, + NULL /* successor measure: default */, + "{\"rules\":[" + "{\"timeframe\":{\"d_us\":3600000000}," + " \"threshold\":\"EUR:1\"," + " \"operation_type\":\"WITHDRAW\"," + " \"verboten\":true" + "}" + "]}" /* new rules */, + "{}" /* properties */, "suspicious", - TALER_AML_FROZEN, - NULL, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_check_bank_admin_transfer ( "check_bank_transfer-big", @@ -361,7 +370,7 @@ run (void *cls, NULL, /* no wire ref */ EXCHANGE_URL, MHD_HTTP_ACCEPTED, - TALER_AML_FROZEN), + true), TALER_TESTING_cmd_sleep ( "sleep to de-collide AML timestamps", 1), @@ -369,10 +378,18 @@ run (void *cls, "unfreeze", "aml-officer", "post-transfer-1", - "EUR:100", + true /* keep investigating */, + GNUNET_TIME_UNIT_HOURS /* expiration */, + NULL /* successor measure: default */, + "{\"rules\":[" + "{\"timeframe\":{\"d_us\":3600000000}," + " \"threshold\":\"EUR:100\"," + " \"operation_type\":\"WITHDRAW\"," + " \"verboten\":true" + "}" + "]}" /* new rules */, + "{}" /* properties */, "fine", - TALER_AML_NORMAL, - NULL, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_kyc_get ( "aml-unfrozen", @@ -381,7 +398,7 @@ run (void *cls, NULL, /* no wire ref */ EXCHANGE_URL, MHD_HTTP_NO_CONTENT, - TALER_AML_NORMAL), + false), CMD_EXEC_AGGREGATOR ("run-aggregator-aml-normal"), TALER_TESTING_cmd_check_bank_transfer ( "check_bank_transfer-498c-post-unfreeze", diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 28c32c2f..5cc2cc67 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -44,7 +44,7 @@ * commands should NOT wait for this timeout! */ #define POLL_ORDER_TIMEOUT \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) /** * The 'poll-orders-conclude-1x' and other 'conclude' @@ -52,7 +52,7 @@ * here we use a short value! */ #define POLL_ORDER_SHORT_TIMEOUT \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) /** * Configuration file we use. One (big) configuration is used @@ -174,8 +174,8 @@ cmd_exec_wirewatch (const char *label) * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \ - TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file) + TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \ + TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file) /** @@ -208,23 +208,25 @@ run (void *cls, struct TALER_TESTING_Interpreter *is) { struct TALER_TESTING_Command get_private_order_id[] = { - TALER_TESTING_cmd_merchant_post_instances ("instance-create-default", - merchant_url, - "default", - MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-default", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, PAYTO_I1, NULL, NULL, MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_kyc_get ("instance-create-kyc-0", - merchant_url, - NULL, - NULL, - EXCHANGE_URL, - MHD_HTTP_NO_CONTENT, - TALER_AML_NORMAL), + TALER_TESTING_cmd_merchant_kyc_get ( + "instance-create-kyc-0", + merchant_url, + NULL, + NULL, + EXCHANGE_URL, + MHD_HTTP_NO_CONTENT, + false), TALER_TESTING_cmd_merchant_post_orders_no_claim ( "create-proposal-bad-currency", merchant_url, @@ -233,28 +235,32 @@ run (void *cls, GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, "CHF:5.0"), - TALER_TESTING_cmd_merchant_post_orders_no_claim ("create-proposal-4", - merchant_url, - MHD_HTTP_OK, - "4", - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - "EUR:5.0"), - TALER_TESTING_cmd_merchant_get_order ("get-order-4", - merchant_url, - "create-proposal-4", - TALER_MERCHANT_OSC_UNPAID, - false, - MHD_HTTP_OK, - NULL), - TALER_TESTING_cmd_merchant_delete_order ("delete-order-4", - merchant_url, - "4", - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_purge_instance ("purge-default", - merchant_url, - "default", - MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_post_orders_no_claim ( + "create-proposal-4", + merchant_url, + MHD_HTTP_OK, + "4", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:5.0"), + TALER_TESTING_cmd_merchant_get_order ( + "get-order-4", + merchant_url, + "create-proposal-4", + TALER_MERCHANT_OSC_UNPAID, + false, + MHD_HTTP_OK, + NULL), + TALER_TESTING_cmd_merchant_delete_order ( + "delete-order-4", + merchant_url, + "4", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_purge_instance ( + "purge-default", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_end () }; @@ -626,7 +632,8 @@ run (void *cls, 5, 0, json_object (), - GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_relative_to_timestamp + ( GNUNET_TIME_UNIT_MINUTES), MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_lock_product ("lock-product-p3", @@ -1682,35 +1689,41 @@ run (void *cls, "EUR:5", 0, MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_post_tokenfamilies ("create-upcoming-tokenfamily", - merchant_url, - MHD_HTTP_NO_CONTENT, - "subscription-upcoming", - "Upcoming Subscription", - "An upcoming subscription that is not valid yet.", - NULL, - /* In one day */ - GNUNET_TIME_absolute_to_timestamp ( - GNUNET_TIME_absolute_add ( - GNUNET_TIME_timestamp_get ().abs_time, GNUNET_TIME_UNIT_DAYS)), - /* In a year */ - GNUNET_TIME_absolute_to_timestamp ( - GNUNET_TIME_absolute_add ( - GNUNET_TIME_timestamp_get ().abs_time, GNUNET_TIME_UNIT_YEARS)), - GNUNET_TIME_UNIT_MONTHS, - GNUNET_TIME_UNIT_MONTHS, - "subscription"), - TALER_TESTING_cmd_merchant_post_orders_choices ("create-order-with-upcoming-output", - cred.cfg, - merchant_url, - MHD_HTTP_CONFLICT, - "create-upcoming-tokenfamily", - 0, - 1, - "5-upcoming-output", - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - "EUR:5.0"), + TALER_TESTING_cmd_merchant_post_tokenfamilies ( + "create-upcoming-tokenfamily", + merchant_url, + MHD_HTTP_NO_CONTENT, + "subscription-upcoming", + "Upcoming Subscription", + "An upcoming subscription that is not valid yet.", + NULL, + /* In one day */ + GNUNET_TIME_absolute_to_timestamp + ( + GNUNET_TIME_absolute_add ( + GNUNET_TIME_timestamp_get () + .abs_time, GNUNET_TIME_UNIT_DAYS)), + /* In a year */ + GNUNET_TIME_absolute_to_timestamp + ( + GNUNET_TIME_absolute_add ( + GNUNET_TIME_timestamp_get () + .abs_time, GNUNET_TIME_UNIT_YEARS)), + GNUNET_TIME_UNIT_MONTHS, + GNUNET_TIME_UNIT_MONTHS, + "subscription"), + TALER_TESTING_cmd_merchant_post_orders_choices ( + "create-order-with-upcoming-output", + cred.cfg, + merchant_url, + MHD_HTTP_CONFLICT, + "create-upcoming-tokenfamily", + 0, + 1, + "5-upcoming-output", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:5.0"), TALER_TESTING_cmd_merchant_post_tokenfamilies ("create-tokenfamily", merchant_url, MHD_HTTP_NO_CONTENT, @@ -1719,7 +1732,8 @@ run (void *cls, "A subscription.", NULL, GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_YEARS), + GNUNET_TIME_relative_to_timestamp + (GNUNET_TIME_UNIT_YEARS), GNUNET_TIME_UNIT_MONTHS, GNUNET_TIME_UNIT_MONTHS, "subscription"), @@ -1744,27 +1758,29 @@ run (void *cls, NULL, 0, NULL), - TALER_TESTING_cmd_merchant_post_orders_choices ("create-order-with-input-and-output", - cred.cfg, - merchant_url, - MHD_HTTP_OK, - "create-tokenfamily", - 1, - 1, - "5-input-output", - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - "EUR:0.0"), - TALER_TESTING_cmd_merchant_pay_order_choices ("pay-order-with-input-and-output", - merchant_url, - MHD_HTTP_OK, - "create-order-with-input-and-output", - "", - "EUR:0", - "EUR:0", - NULL, - 0, - "pay-order-with-output"), + TALER_TESTING_cmd_merchant_post_orders_choices ( + "create-order-with-input-and-output", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "create-tokenfamily", + 1, + 1, + "5-input-output", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:0.0"), + TALER_TESTING_cmd_merchant_pay_order_choices ( + "pay-order-with-input-and-output", + merchant_url, + MHD_HTTP_OK, + "create-order-with-input-and-output", + "", + "EUR:0", + "EUR:0", + NULL, + 0, + "pay-order-with-output"), // TALER_TESTING_cmd_merchant_pay_order_choices ("idempotent-pay-order-with-input-and-output", // merchant_url, // MHD_HTTP_OK, @@ -1775,17 +1791,18 @@ run (void *cls, // NULL, // 0, // "pay-order-with-output"), - TALER_TESTING_cmd_merchant_post_orders_choices ("create-another-order-with-input-and-output", - cred.cfg, - merchant_url, - MHD_HTTP_OK, - "create-tokenfamily", - 1, - 1, - "5-input-output-2", - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - "EUR:0.0"), + TALER_TESTING_cmd_merchant_post_orders_choices ( + "create-another-order-with-input-and-output", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "create-tokenfamily", + 1, + 1, + "5-input-output-2", + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + "EUR:0.0"), TALER_TESTING_cmd_merchant_pay_order_choices ("double-spend-token", merchant_url, MHD_HTTP_CONFLICT, diff --git a/src/testing/testing_api_cmd_kyc_get.c b/src/testing/testing_api_cmd_kyc_get.c index a8f29264..416423b1 100644 --- a/src/testing/testing_api_cmd_kyc_get.c +++ b/src/testing/testing_api_cmd_kyc_get.c @@ -73,9 +73,9 @@ struct KycGetState unsigned int expected_http_status; /** - * Expected AML state. + * Expected KYC state. */ - enum TALER_AmlDecisionState expected_aml_state; + bool expected_kyc_state; /** * Interpreter state. @@ -131,17 +131,11 @@ kyc_get_cb (void *cls, switch (kr->hr.http_status) { case MHD_HTTP_ACCEPTED: - - if ( ( (TALER_AML_NORMAL != cs->expected_aml_state) && - (0 == kr->details.kyc_status.pending_kycs_length) ) || - ( (0 < kr->details.kyc_status.pending_kycs_length) && - (cs->expected_aml_state != - kr->details.kyc_status.pending_kycs[0].aml_status) ) ) + if (! cs->expected_kyc_state) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Expected AML state %u, got %u/%u\n", - cs->expected_aml_state, - kr->details.kyc_status.pending_kycs[0].aml_status, + "Expected KYC state %u, got %u\n", + cs->expected_kyc_state, kr->details.kyc_status.pending_kycs_length); TALER_TESTING_FAIL (cs->is); } @@ -158,17 +152,7 @@ kyc_get_cb (void *cls, url = kr->details.kyc_status.pending_kycs[i].kyc_url; if (NULL == url) { - /* AML status here must be either pending or frozne */ - switch (kr->details.kyc_status.pending_kycs[i].aml_status) - { - case TALER_AML_NORMAL: - TALER_TESTING_FAIL (cs->is); - case TALER_AML_PENDING: - continue; - case TALER_AML_FROZEN: - continue; - } - TALER_TESTING_FAIL (cs->is); + continue; } tok = strstr (url, "&redirect_uri="); if (NULL == tok) @@ -325,7 +309,7 @@ TALER_TESTING_cmd_merchant_kyc_get ( const char *h_wire_ref, const char *exchange_url, unsigned int expected_http_status, - enum TALER_AmlDecisionState expected_aml_state) + bool expected_kyc_state) { struct KycGetState *cs; @@ -335,7 +319,7 @@ TALER_TESTING_cmd_merchant_kyc_get ( cs->h_wire_ref = h_wire_ref; cs->exchange_url = exchange_url; cs->expected_http_status = expected_http_status; - cs->expected_aml_state = expected_aml_state; + cs->expected_kyc_state = expected_kyc_state; { struct TALER_TESTING_Command cmd = { .cls = cs, |