gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 24/24: complete KYC test


From: gnunet
Subject: [taler-merchant] 24/24: complete KYC test
Date: Wed, 17 Nov 2021 12:44:47 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

commit 39e6ebbc169a250b6ae11928f5ce58696f09f19f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Nov 17 11:01:54 2021 +0100

    complete KYC test
---
 src/testing/.gitignore                |  1 +
 src/testing/test_kyc_api.c            | 81 +++++++++++-------------------
 src/testing/test_kyc_api.conf         | 17 +++++++
 src/testing/testing_api_cmd_kyc_get.c | 93 ++++++++++++++++++++++++++++++++++-
 4 files changed, 139 insertions(+), 53 deletions(-)

diff --git a/src/testing/.gitignore b/src/testing/.gitignore
index e3868de6..78124d09 100644
--- a/src/testing/.gitignore
+++ b/src/testing/.gitignore
@@ -10,3 +10,4 @@ 
test_reducer_home/.local/share/taler/exchange-offline/secm_tofus.pub
 test_reducer_home/.local/share/taler/exchange-secmod-eddsa/
 test_reducer_home/.local/share/taler/exchange-secmod-rsa/
 test_reducer_home/
+test_kyc_api
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index d88de753..8bb19eab 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -110,51 +110,6 @@ static struct GNUNET_OS_Process *merchantd;
  */
 #define MERCHANT_ACCOUNT_NAME "3"
 
-/**
- * Payto URIs to use for testing accounts on the merchant.
- */
-const char *payto_uris[] = {
-  PAYTO_I1,
-  "payto://iban/CH9300762011623852957?receiver-name=Test"
-  /* Just for testing account inactivation. */
-};
-
-const char *order_1_transfers[] = {
-  "post-transfer-1",
-  NULL
-};
-
-const char *order_1_forgets_1[] = {
-  "forget-1",
-  NULL
-};
-
-const char *order_1_forgets_2[] = {
-  "forget-1",
-  "forget-order-array-elem",
-  NULL
-};
-
-const char *order_1_forgets_3[] = {
-  "forget-1",
-  "forget-order-array-elem",
-  "forget-order-array-wc",
-  NULL
-};
-
-
-/**
- * Execute the taler-exchange-wirewatch command with
- * our configuration file.
- *
- * @param label label to use for the command.
- */
-static struct TALER_TESTING_Command
-cmd_exec_wirewatch (const char *label)
-{
-  return TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE);
-}
-
 
 /**
  * Execute the taler-exchange-aggregator, closer and transfer commands with
@@ -163,7 +118,7 @@ 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_aggregator_with_kyc (label "-aggregator", 
CONFIG_FILE), \
   TALER_TESTING_cmd_exec_transfer (label "-transfer", CONFIG_FILE)
 
 
@@ -203,11 +158,10 @@ run (void *cls,
     cmd_transfer_to_exchange ("create-reserve-1",
                               "EUR:10.02"),
     /**
-     * Make a reserve exist,
-     * according to the previous
-     * transfer.
-     *///
-    cmd_exec_wirewatch ("wirewatch-1"),
+     * Make a reserve exist, according to the previous transfer.
+     */
+    TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1",
+                                      CONFIG_FILE),
     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2",
                                                  "EUR:10.02",
                                                  payer_payto,
@@ -264,6 +218,27 @@ run (void *cls,
                                                  MHD_HTTP_NO_CONTENT),
     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"),
     CMD_EXEC_AGGREGATOR ("run-aggregator"),
+    /* KYC: hence nothing happened at the bank yet: */
+    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
+    /* FIXME-#7052: this should ideally not be needed... */
+    TALER_TESTING_cmd_merchant_get_order ("get-order",
+                                          merchant_url,
+                                          "create-proposal-1",
+                                          TALER_MERCHANT_OSC_PAID,
+                                          false,
+                                          MHD_HTTP_OK),
+    TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending",
+                                        merchant_url,
+                                        NULL,
+                                        NULL,
+                                        EXCHANGE_URL,
+                                        MHD_HTTP_ACCEPTED),
+    TALER_TESTING_cmd_proof_kyc ("kyc-do",
+                                 "kyc-pending",
+                                 "pass",
+                                 "state",
+                                 MHD_HTTP_SEE_OTHER),
+    CMD_EXEC_AGGREGATOR ("run-aggregator"),
     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-498c",
                                            EXCHANGE_URL,
                                            "EUR:4.98",
@@ -283,12 +258,14 @@ run (void *cls,
                                               MHD_HTTP_OK,
                                               "post-transfer-1",
                                               NULL),
-    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
+    TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-3"),
     TALER_TESTING_cmd_end ()
   };
 
   struct TALER_TESTING_Command commands[] = {
     /* general setup */
+    TALER_TESTING_cmd_oauth ("start-oauth-service",
+                             6666),
     TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
                                    MHD_HTTP_NO_CONTENT,
                                    false),
diff --git a/src/testing/test_kyc_api.conf b/src/testing/test_kyc_api.conf
index 5f706d63..408d6639 100644
--- a/src/testing/test_kyc_api.conf
+++ b/src/testing/test_kyc_api.conf
@@ -103,6 +103,23 @@ MASTER_PUBLIC_KEY = 
T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
 BASE_URL = "http://localhost:8081/";
 
 
+KYC_MODE = OAUTH2
+
+KYC_WALLET_BALANCE_LIMIT = EUR:1
+
+KYC_WITHDRAW_PERIOD = "31 days"
+
+KYC_WITHDRAW_LIMIT = EUR:20
+
+[exchange-kyc-oauth2]
+
+KYC_OAUTH2_URL = http://localhost:6666/oauth/v2/login
+KYC_INFO_URL = http://localhost:6666/api/user/me
+KYC_OAUTH2_CLIENT_ID = taler-exchange
+KYC_OAUTH2_CLIENT_SECRET = exchange-secret
+KYC_OAUTH2_POST_URL = http://example.com/
+
+
 [exchangedb-postgres]
 CONFIG = "postgres:///talercheck"
 
diff --git a/src/testing/testing_api_cmd_kyc_get.c 
b/src/testing/testing_api_cmd_kyc_get.c
index 0d7a405e..07fe84e1 100644
--- a/src/testing/testing_api_cmd_kyc_get.c
+++ b/src/testing/testing_api_cmd_kyc_get.c
@@ -61,6 +61,12 @@ struct KycGetState
    */
   const char *exchange_url;
 
+  /**
+   * Set to the payment target UUID of the first exchange account
+   * for which we failed to pass the KYC check, or 0.
+   */
+  uint64_t payment_target_uuid;
+
   /**
    * Expected HTTP response code.
    */
@@ -117,6 +123,61 @@ kyc_get_cb (void *cls,
                 kr->hr.http_status);
     TALER_TESTING_FAIL (cs->is);
   }
+  switch (kr->hr.http_status)
+  {
+  case MHD_HTTP_ACCEPTED:
+    if (0 != kr->details.kyc_status.pending_kycs_length)
+    {
+      const char *url;
+      const char *tok;
+      const char *end;
+      char *dec;
+      const char *eq;
+      unsigned long long uuid;
+      size_t toklen;
+      char dummy;
+
+      url = kr->details.kyc_status.pending_kycs[0].kyc_url;
+      tok = strstr (url, "&redirect_uri=");
+      if (NULL == tok)
+        TALER_TESTING_FAIL (cs->is);
+      tok += strlen ("&redirect_uri=");
+      end = strchr (tok, '&');
+      if (NULL == end)
+        toklen = strlen (tok);
+      else
+        toklen = end - tok;
+      (void) GNUNET_STRINGS_urldecode (tok,
+                                       toklen,
+                                       &dec);
+      eq = strrchr (dec, '/');
+      if (NULL == eq)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Received unexpected KYC URL `%s' (%s)\n",
+                    url,
+                    dec);
+        GNUNET_free (dec);
+        TALER_TESTING_FAIL (cs->is);
+      }
+      eq++;
+      if (1 != sscanf (eq,
+                       "%llu%c",
+                       &uuid,
+                       &dummy))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Received unexpected KYC URL `%s' (%s)\n",
+                    url,
+                    dec);
+        GNUNET_free (dec);
+        TALER_TESTING_FAIL (cs->is);
+      }
+      GNUNET_free (dec);
+      cs->payment_target_uuid = uuid;
+    }
+    break;
+  }
   TALER_TESTING_interpreter_next (cs->is);
 }
 
@@ -181,6 +242,35 @@ kyc_get_run (void *cls,
 }
 
 
+/**
+ * Offer internal data from "KYC" GET CMD.
+ *
+ * @param cls closure.
+ * @param[out] ret result (could be anything).
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ */
+static enum GNUNET_GenericReturnValue
+kyc_get_traits (void *cls,
+                const void **ret,
+                const char *trait,
+                unsigned int index)
+{
+  struct KycGetState *cs = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    TALER_TESTING_make_trait_payment_target_uuid (
+      &cs->payment_target_uuid),
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_kyc_get (const char *label,
                                     const char *merchant_url,
@@ -202,7 +292,8 @@ TALER_TESTING_cmd_merchant_kyc_get (const char *label,
       .cls = cs,
       .label = label,
       .run = &kyc_get_run,
-      .cleanup = &kyc_get_cleanup
+      .cleanup = &kyc_get_cleanup,
+      .traits = &kyc_get_traits
     };
 
     return cmd;

-- 
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]