gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated (a462d86ee -> 4ab8ca549)


From: gnunet
Subject: [taler-exchange] branch master updated (a462d86ee -> 4ab8ca549)
Date: Sun, 04 Aug 2024 12:54:13 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository exchange.

    from a462d86ee add new command to test kyc-upload endpoint
     new 94da34ede more clear naming of variables
     new 976589d69 more clear naming of variables
     new 7292df436 add missing argument
     new 7edb381c7 prepare config for form test
     new 5992fffab add missing argument
     new 4ab8ca549 work towards FORM testing

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/exchange/taler-exchange-httpd_kyc-info.c       | 14 ++--
 src/include/taler_exchange_service.h               |  3 +
 src/include/taler_kyclogic_lib.h                   |  4 +-
 src/kyclogic/Makefile.am                           |  1 +
 src/kyclogic/kyclogic_api.c                        |  8 +--
 ...uth => taler-exchange-helper-measure-test-form} |  2 +-
 src/lib/exchange_api_add_aml_decision.c            |  9 ++-
 src/testing/test_exchange_api.conf                 | 25 +++++++
 src/testing/test_kyc_api.c                         | 82 +++++++++++++++++++++-
 src/testing/testing_api_cmd_take_aml_decision.c    | 19 +++--
 10 files changed, 144 insertions(+), 23 deletions(-)
 copy src/kyclogic/{taler-exchange-helper-measure-test-oauth => 
taler-exchange-helper-measure-test-form} (98%)

diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c 
b/src/exchange/taler-exchange-httpd_kyc-info.c
index 1d9804d30..768703690 100644
--- a/src/exchange/taler-exchange-httpd_kyc-info.c
+++ b/src/exchange/taler-exchange-httpd_kyc-info.c
@@ -180,13 +180,13 @@ db_event_cb (void *cls,
  * the LegitimizationMeasures.
  *
  * @param[in,out] kyp request to reply on
- * @param row_id etag to set for the response
+ * @param legitimization_measure_row_id etag to set for the response
  * @param jmeasures measures to encode
  * @return MHD status code
  */
 static MHD_RESULT
 generate_reply (struct KycPoller *kyp,
-                uint64_t row_id,
+                uint64_t legitimization_measure_row_id,
                 const json_t *jmeasures)
 {
   const json_t *measures;
@@ -255,7 +255,7 @@ generate_reply (struct KycPoller *kyp,
       prog_name,
       &kyp->access_token,
       i,
-      row_id);
+      legitimization_measure_row_id);
     if (NULL == kri)
     {
       GNUNET_break (0);
@@ -278,7 +278,7 @@ generate_reply (struct KycPoller *kyp,
     GNUNET_snprintf (etags,
                      sizeof (etags),
                      "%llu",
-                     (unsigned long long) row_id);
+                     (unsigned long long) legitimization_measure_row_id);
     resp = TALER_MHD_MAKE_JSON_PACK (
       GNUNET_JSON_pack_array_steal ("requirements",
                                     kris),
@@ -310,7 +310,7 @@ TEH_handler_kyc_info (
   struct KycPoller *kyp = rc->rh_ctx;
   MHD_RESULT res;
   enum GNUNET_DB_QueryStatus qs;
-  uint64_t last_row;
+  uint64_t legitimization_measure_last_row;
   json_t *jmeasures;
 
   if (NULL == kyp)
@@ -402,7 +402,7 @@ TEH_handler_kyc_info (
   qs = TEH_plugin->lookup_kyc_status_by_token (
     TEH_plugin->cls,
     &kyp->access_token,
-    &last_row,
+    &legitimization_measure_last_row,
     &jmeasures);
   if (qs < 0)
   {
@@ -443,7 +443,7 @@ TEH_handler_kyc_info (
   }
 
   res = generate_reply (kyp,
-                        last_row,
+                        legitimization_measure_last_row,
                         jmeasures);
   json_decref (jmeasures);
   return res;
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 287d73a42..ab8b799ac 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -6313,6 +6313,8 @@ struct TALER_EXCHANGE_AccountRule
  *                      decision is about
  * @param decision_time when was the decision made
  * @param successor_measure measure to activate after @a expiration_time if no 
rule applied
+ * @param new_check new KYC check to provide to the user,
+ *          NULL for none
  * @param expiration_time when do the new rules expire
  * @param num_rules length of the @a rules array
  * @param rules new rules for the account
@@ -6333,6 +6335,7 @@ TALER_EXCHANGE_add_aml_decision (
   const struct TALER_PaytoHashP *h_payto,
   struct GNUNET_TIME_Timestamp decision_time,
   const char *successor_measure,
+  const char *new_check,
   struct GNUNET_TIME_Timestamp expiration_time,
   unsigned int num_rules,
   const struct TALER_EXCHANGE_AccountRule *rules,
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 7f7b27169..1fcf65ace 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -521,7 +521,7 @@ TALER_KYCLOGIC_check_form (
  * @param prog_name the program to run
  * @param access_token access token for the measure
  * @param offset offset of the measure
- * @param row_id row in the legitimization_measures table
+ * @param legitimization_measure_row_id row in the legitimization_measures 
table
  * @return JSON object with matching KycRequirementInformation
  */
 json_t *
@@ -530,7 +530,7 @@ TALER_KYCLOGIC_measure_to_requirement (
   const char *prog_name,
   const struct TALER_AccountAccessTokenP *access_token,
   size_t offset,
-  uint64_t row_id);
+  uint64_t legitimization_measure_row_id);
 
 
 /**
diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am
index bf258b278..7da1f758f 100644
--- a/src/kyclogic/Makefile.am
+++ b/src/kyclogic/Makefile.am
@@ -16,6 +16,7 @@ pkgcfg_DATA = \
 
 bin_SCRIPTS = \
   taler-exchange-helper-converter-oauth2-test-full_name \
+  taler-exchange-helper-measure-test-form \
   taler-exchange-helper-measure-test-oauth \
   taler-exchange-kyc-kycaid-converter.sh \
   taler-exchange-kyc-persona-converter.sh \
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index 4bad55f68..0930371c6 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -2751,7 +2751,7 @@ TALER_KYCLOGIC_measure_to_requirement (
   const char *prog_name,
   const struct TALER_AccountAccessTokenP *access_token,
   size_t offset,
-  uint64_t row_id)
+  uint64_t legitimization_measure_row_id)
 {
   struct TALER_KYCLOGIC_KycCheck *kc;
   json_t *kri;
@@ -2767,7 +2767,7 @@ TALER_KYCLOGIC_measure_to_requirement (
   }
   GNUNET_assert (offset <= UINT32_MAX);
   TALER_kyc_measure_authorization_hash (access_token,
-                                        row_id,
+                                        legitimization_measure_row_id,
                                         (uint32_t) offset,
                                         &shv);
   switch (kc->type)
@@ -2788,7 +2788,7 @@ TALER_KYCLOGIC_measure_to_requirement (
                      "%s-%u-%llu",
                      ids,
                      (unsigned int) offset,
-                     (unsigned long long) row_id);
+                     (unsigned long long) legitimization_measure_row_id);
     GNUNET_free (ids);
     kri = GNUNET_JSON_PACK (
       GNUNET_JSON_pack_string ("form",
@@ -2809,7 +2809,7 @@ TALER_KYCLOGIC_measure_to_requirement (
                      "%s-%u-%llu",
                      ids,
                      (unsigned int) offset,
-                     (unsigned long long) row_id);
+                     (unsigned long long) legitimization_measure_row_id);
     GNUNET_free (ids);
     kri = GNUNET_JSON_PACK (
       GNUNET_JSON_pack_string ("form",
diff --git a/src/kyclogic/taler-exchange-helper-measure-test-oauth 
b/src/kyclogic/taler-exchange-helper-measure-test-form
similarity index 98%
copy from src/kyclogic/taler-exchange-helper-measure-test-oauth
copy to src/kyclogic/taler-exchange-helper-measure-test-form
index 554a179b6..d231e6244 100755
--- a/src/kyclogic/taler-exchange-helper-measure-test-oauth
+++ b/src/kyclogic/taler-exchange-helper-measure-test-form
@@ -21,7 +21,7 @@ set -eu
 echo "Running $0" 1>&2
 
 # This is a KYC measure program that checks the output
-# of an OAuth2 authentication, and if it passed,
+# of a simple FORM submission, and if it passed,
 # increases all limits to EUR:1000.
 # (and doesn't impose any other limits)
 
diff --git a/src/lib/exchange_api_add_aml_decision.c 
b/src/lib/exchange_api_add_aml_decision.c
index 74d7ed09c..1fee742b8 100644
--- a/src/lib/exchange_api_add_aml_decision.c
+++ b/src/lib/exchange_api_add_aml_decision.c
@@ -130,6 +130,7 @@ TALER_EXCHANGE_add_aml_decision (
   const struct TALER_PaytoHashP *h_payto,
   struct GNUNET_TIME_Timestamp decision_time,
   const char *successor_measure,
+  const char *new_check,
   struct GNUNET_TIME_Timestamp expiration_time,
   unsigned int num_rules,
   const struct TALER_EXCHANGE_AccountRule *rules,
@@ -215,14 +216,18 @@ TALER_EXCHANGE_add_aml_decision (
     GNUNET_JSON_pack_allow_null (
       GNUNET_JSON_pack_string ("successor_measure",
                                successor_measure)),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("new_check",
+                               new_check)),
     GNUNET_JSON_pack_array_steal ("rules",
                                   jrules),
     GNUNET_JSON_pack_object_steal ("custom_measures",
                                    jmeasures)
     );
 
-  GNUNET_CRYPTO_eddsa_key_get_public (&officer_priv->eddsa_priv,
-                                      &officer_pub.eddsa_pub);
+  GNUNET_CRYPTO_eddsa_key_get_public (
+    &officer_priv->eddsa_priv,
+    &officer_pub.eddsa_pub);
   TALER_officer_aml_decision_sign (justification,
                                    decision_time,
                                    h_payto,
diff --git a/src/testing/test_exchange_api.conf 
b/src/testing/test_exchange_api.conf
index c40ae4b1c..008aaa919 100644
--- a/src/testing/test_exchange_api.conf
+++ b/src/testing/test_exchange_api.conf
@@ -123,6 +123,22 @@ PROVIDER_ID = test-oauth2
 # Outputs from this check
 OUTPUTS = full_name birthdate
 
+[kyc-check-test-form]
+VOLUNTARY = NO
+# We use an external provider
+TYPE = FORM
+DESCRIPTION = "Test form"
+DESCRIPTION_I18N = {}
+# No context requirements
+REQUIRES =
+# Measure to execute if check failed.
+FALLBACK = manual-freeze
+# This check runs on oauth2
+FORM_NAME = full_name_and_birthdate
+# Outputs from this check
+OUTPUTS = full_name birthdate
+
+
 # This is the "default" setting for an account if
 # it has not yet triggered anything.
 [kyc-check-default]
@@ -174,6 +190,15 @@ COMMAND = taler-exchange-helper-measure-test-oauth
 # What measure to take if the COMMAND failed.
 FALLBACK = manual-freeze
 
+[aml-program-test-form-check]
+DESCRIPTION = "Validates the output from the test-form and then increases all 
limits to EUR:1000"
+# Command that runs on the output of the form
+# to decide what rules should apply next.
+COMMAND = taler-exchange-helper-measure-test-form
+# What measure to take if the COMMAND failed.
+FALLBACK = manual-freeze
+
+
 [kyc-measure-run-oauth]
 # Get client ID via the OAuth test provider
 CHECK_NAME = oauth-test-id
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index a760b7a6b..2b19e33f0 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -481,7 +481,7 @@ run (void *cls,
     TALER_TESTING_cmd_check_kyc_get (
       "check-kyc-purse-create",
       "purse-create-with-reserve",
-      "purse-create-with-reserve", /* correct!? */
+      "purse-create-with-reserve",
       MHD_HTTP_ACCEPTED),
     TALER_TESTING_cmd_get_kyc_info (
       "get-kyc-info-purse-create",
@@ -667,6 +667,84 @@ run (void *cls,
     TALER_TESTING_cmd_end ()
   };
 
+  struct TALER_TESTING_Command aml_form[] = {
+    TALER_TESTING_cmd_set_officer (
+      "create-aml-form-officer-1",
+      NULL,
+      "Peter Falk",
+      true,
+      false),
+    /* Trigger something upon which an AML officer could act */
+    TALER_TESTING_cmd_wallet_kyc_get (
+      "wallet-trigger-kyc-for-form-aml",
+      NULL,
+      "EUR:1000",
+      MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
+    TALER_TESTING_cmd_wallet_kyc_get (
+      "wallet-trigger-kyc-for-form-aml-disallowed",
+      "wallet-trigger-kyc-for-form-aml",
+      "EUR:500",
+      MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
+    /* AML officer switches from Oauth2 to form */
+    TALER_TESTING_cmd_take_aml_decision (
+      "aml-decide-form",
+      "create-aml-form-officer-1",
+      "wallet-trigger-kyc-for-form-aml",
+      false /* just awaiting KYC, no investigation */,
+      GNUNET_TIME_UNIT_HOURS /* expiration */,
+      NULL /* successor measure: default */,
+      "{\"rules\":"
+      " ["
+      "   {"
+      "     \"timeframe\":{\"d_us\":3600000000}"
+      "     ,\"threshold\":\"EUR:0\""
+      "     ,\"operation_type\":\"BALANCE\""
+      "     ,\"measures\":[\"form-measure\"]"
+      "     ,\"verboten\":false"
+      "   }"
+      " ]" /* end new rules */
+      ",\"new_check\":\"form-check\"" // FIXME: do we need this?
+      ",\"custom_measures\":"
+      "  {"
+      "    \"form-measure\":"
+      "    {"
+      "       \"check_name\":\"test-form\""
+      "      ,\"prog_name\":\"test-form-check\""
+      "    }"
+      "  }" /* end custom measures */
+      "}",
+      "{}" /* properties */,
+      "form time",
+      MHD_HTTP_NO_CONTENT),
+    /* Wallet learns about form submission */
+    TALER_TESTING_cmd_check_kyc_get (
+      "check-kyc-form",
+      "wallet-trigger-kyc-for-form-aml",
+      "wallet-trigger-kyc-for-form-aml",
+      MHD_HTTP_ACCEPTED),
+    TALER_TESTING_cmd_get_kyc_info (
+      "get-kyc-info-form",
+      "check-kyc-form",
+      MHD_HTTP_OK),
+#if FIXME
+    TALER_TESTING_cmd_post_kyc_form (
+      "wallet-post-kyc-form",
+      "get-kyc-info-form",
+      0,  /* requirement index */
+      "application/x-www-form-urlencoded",
+      "full_name=Bob&birthdate=1990-00-00",
+      MHD_HTTP_NO_CONTENT),
+    /* now this should be allowed */
+    TALER_TESTING_cmd_wallet_kyc_get (
+      "wallet-trigger-kyc-for-form-aml-allowed",
+      "wallet-trigger-kyc-for-form-aml",
+      "EUR:500",
+      MHD_HTTP_NO_CONTENT),
+#endif
+    TALER_TESTING_cmd_end ()
+  };
+
+
   struct TALER_TESTING_Command commands[] = {
     TALER_TESTING_cmd_run_fakebank (
       "run-fakebank",
@@ -709,6 +787,8 @@ run (void *cls,
       pull),
     TALER_TESTING_cmd_batch ("aml",
                              aml),
+    TALER_TESTING_cmd_batch ("aml-form",
+                             aml_form),
     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
index dbc9747c0..f0eca3e39 100644
--- a/src/testing/testing_api_cmd_take_aml_decision.c
+++ b/src/testing/testing_api_cmd_take_aml_decision.c
@@ -149,6 +149,7 @@ take_aml_decision_run (void *cls,
   const json_t *jmeasures = NULL;
   struct GNUNET_TIME_Timestamp expiration_time
     = GNUNET_TIME_relative_to_timestamp (ds->expiration_delay);
+  const char *new_check = NULL;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_array_const ("rules",
                                   &jrules),
@@ -156,6 +157,10 @@ take_aml_decision_run (void *cls,
       GNUNET_JSON_spec_object_const ("custom_measures",
                                      &jmeasures),
       NULL),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_string ("new_check",
+                               &new_check),
+      NULL),
     GNUNET_JSON_spec_end ()
   };
   unsigned int num_rules;
@@ -245,7 +250,7 @@ take_aml_decision_run (void *cls,
     json_array_foreach ((json_t *) jrules, i, jrule)
     {
       struct TALER_EXCHANGE_AccountRule *rule = &rules[i];
-      const json_t *jmeasures = NULL;
+      const json_t *jameasures = NULL;
       struct GNUNET_JSON_Specification ispec[] = {
         GNUNET_JSON_spec_relative_time ("timeframe",
                                         &rule->timeframe),
@@ -253,7 +258,7 @@ take_aml_decision_run (void *cls,
                                     &rule->threshold),
         GNUNET_JSON_spec_mark_optional (
           GNUNET_JSON_spec_array_const ("measures",
-                                        &jmeasures),
+                                        &jameasures),
           NULL),
         GNUNET_JSON_spec_mark_optional (
           GNUNET_JSON_spec_uint32 ("display_priority",
@@ -292,22 +297,23 @@ take_aml_decision_run (void *cls,
         TALER_TESTING_interpreter_fail (is);
         return;
       }
-      if (NULL != jmeasures)
+      if (NULL != jameasures)
       {
         rule->num_measures
-          = (unsigned int) json_array_size (jmeasures);
+          = (unsigned int) json_array_size (jameasures);
         rule->measures
           = GNUNET_new_array (rule->num_measures,
                               const char *);
         for (unsigned int k = 0; k<rule->num_measures; k++)
           rule->measures[k]
             = json_string_value (
-                json_array_get (jmeasures,
+                json_array_get (jameasures,
                                 k));
       }
     }
+
     off = 0;
-    json_object_foreach ((json_t *) jrules, mname, jmeasure)
+    json_object_foreach ((json_t *) jmeasures, mname, jmeasure)
     {
       struct TALER_EXCHANGE_MeasureInformation *mi = &measures[off++];
       struct GNUNET_JSON_Specification ispec[] = {
@@ -350,6 +356,7 @@ take_aml_decision_run (void *cls,
       h_payto,
       now,
       ds->successor_measure,
+      new_check,
       expiration_time,
       num_rules,
       rules,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]