gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: fix test regressions


From: gnunet
Subject: [taler-exchange] branch master updated: fix test regressions
Date: Sat, 24 Aug 2024 17:55:52 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new f7620b28b fix test regressions
f7620b28b is described below

commit f7620b28be47a04cb10e155caad0e147e174f1d2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Aug 24 17:55:48 2024 +0200

    fix test regressions
---
 src/exchange/taler-exchange-httpd_deposits_get.c   | 18 ++++-
 src/exchangedb/pg_insert_kyc_requirement_process.c |  7 ++
 .../pg_lookup_completed_legitimization.c           | 94 ++++++++++++++++++++++
 .../pg_lookup_completed_legitimization.h           | 64 +++++++++++++++
 src/exchangedb/pg_lookup_transfer_by_deposit.c     |  8 +-
 src/exchangedb/pg_lookup_transfer_by_deposit.h     |  4 +-
 src/exchangedb/plugin_exchangedb_postgres.c        |  3 +
 src/exchangedb/test_exchangedb.c                   |  8 +-
 src/include/taler_exchangedb_plugin.h              |  4 +-
 src/testing/testing_api_cmd_kyc_proof.c            |  2 +-
 10 files changed, 205 insertions(+), 7 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c 
b/src/exchange/taler-exchange-httpd_deposits_get.c
index 4787c74db..174b428e0 100644
--- a/src/exchange/taler-exchange-httpd_deposits_get.c
+++ b/src/exchange/taler-exchange-httpd_deposits_get.c
@@ -74,6 +74,15 @@ struct DepositWtidContext
    */
   struct TALER_MerchantPublicKeyP merchant;
 
+  /**
+   * Public key for KYC operations on the target bank
+   * account for the wire transfer. All zero if no
+   * public key is accepted yet. In that case, the
+   * client should use the @e merchant public key for
+   * the KYC auth wire transfer.
+   */
+  union TALER_AccountPublicKeyP account_pub;
+
   /**
    * The coin's public key.  This is the value that must have been
    * signed (blindly) by the Exchange.
@@ -254,7 +263,8 @@ deposits_get_transaction (void *cls,
     &ctx->execution_time,
     &ctx->coin_contribution,
     &fee,
-    &ctx->kyc);
+    &ctx->kyc,
+    &ctx->account_pub);
   if (0 > qs)
   {
     if (GNUNET_DB_STATUS_HARD_ERROR == qs)
@@ -401,6 +411,12 @@ handle_track_transaction_request (
                                    NULL)
         : GNUNET_JSON_pack_uint64 ("requirement_row",
                                    ctx->kyc.requirement_row)),
+      GNUNET_JSON_pack_allow_null (
+        (GNUNET_is_zero (&ctx->account_pub))
+        ? GNUNET_JSON_pack_string ("account_pub",
+                                   NULL)
+        : GNUNET_JSON_pack_data_auto ("account_pub",
+                                      &ctx->account_pub)),
       GNUNET_JSON_pack_bool ("kyc_ok",
                              ctx->kyc.ok),
       GNUNET_JSON_pack_timestamp ("execution_time",
diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.c 
b/src/exchangedb/pg_insert_kyc_requirement_process.c
index 33e4b9f70..d6f8850b3 100644
--- a/src/exchangedb/pg_insert_kyc_requirement_process.c
+++ b/src/exchangedb/pg_insert_kyc_requirement_process.c
@@ -72,6 +72,13 @@ TEH_PG_insert_kyc_requirement_process (
            "  ,measure_index"
            "  ) VALUES "
            "  ($1, $2, $3, $4, $5, $6, $7)"
+           " ON CONFLICT (legitimization_measure_serial_id,measure_index)"
+           " DO UPDATE"
+           "   SET h_payto=$1"
+           "      ,start_time=$2"
+           "      ,provider_name=$3"
+           "      ,provider_user_id=$4"
+           "      ,provider_legitimization_id=$5"
            " RETURNING legitimization_process_serial_id");
   return GNUNET_PQ_eval_prepared_singleton_select (
     pg->conn,
diff --git a/src/exchangedb/pg_lookup_completed_legitimization.c 
b/src/exchangedb/pg_lookup_completed_legitimization.c
new file mode 100644
index 000000000..35647c847
--- /dev/null
+++ b/src/exchangedb/pg_lookup_completed_legitimization.c
@@ -0,0 +1,94 @@
+/*
+   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 exchangedb/pg_lookup_pending_legitimization.c
+ * @brief Implementation of the lookup_pending_legitimization function for 
Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_lookup_pending_legitimization.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TEH_PG_lookup_completed_legitimization (
+  void *cls,
+  uint64_t legitimization_measure_serial_id,
+  uint32_t measure_index,
+  struct TALER_AccountAccessTokenP *access_token,
+  struct TALER_PaytoHashP *h_payto,
+  json_t **jmeasures,
+  bool *is_finished,
+  size_t *encrypted_attributes_len,
+  void **encrypted_attributes
+  )
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id),
+    GNUNET_PQ_query_param_uint32 (&measure_index),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    TALER_PQ_result_spec_json (
+      "jmeasures",
+      jmeasures),
+    GNUNET_PQ_result_spec_auto_from_type (
+      "wire_target_h_payto",
+      h_payto),
+    GNUNET_PQ_result_spec_auto_from_type (
+      "access_token",
+      access_token),
+    GNUNET_PQ_result_spec_bool (
+      "is_finished",
+      is_finished),
+    GNUNET_PQ_result_spec_allow_null (
+      GNUNET_PQ_result_spec_variable_size (
+        "encrypted_attributes",
+        encrypted_attributes,
+        encrypted_attributes_len),
+      NULL),
+    GNUNET_PQ_result_spec_end
+  };
+
+  *encrypted_attributes_len = 0;
+  *encrypted_attributes = NULL;
+  PREPARE (pg,
+           "lookup_completed_legitimization",
+           "SELECT "
+           " lm.jmeasures"
+           ",wt.wire_target_h_payto"
+           ",lm.access_token"
+           ",lm.is_finished"
+           ",ka.encrypted_attributes"
+           " FROM legitimization_measures lm"
+           " JOIN wire_targets wt"
+           "   ON (lm.access_token = wt.access_token)"
+           " LEFT JOIN legitimization_processes lp"
+           "   ON (lm.legitimization_measure_serial_id = 
lp.legitimization_measure_serial_id)"
+           " LEFT JOIN kyc_attributes ka"
+           "   ON (ka.legitimization_serial = 
lp.legitimization_process_serial_id)"
+           " WHERE lm.legitimization_measure_serial_id=$1"
+           "   AND lp.measure_index=$2;");
+  return GNUNET_PQ_eval_prepared_singleton_select (
+    pg->conn,
+    "lookup_completed_legitimization",
+    params,
+    rs);
+}
diff --git a/src/exchangedb/pg_lookup_completed_legitimization.h 
b/src/exchangedb/pg_lookup_completed_legitimization.h
new file mode 100644
index 000000000..1bc16c2ac
--- /dev/null
+++ b/src/exchangedb/pg_lookup_completed_legitimization.h
@@ -0,0 +1,64 @@
+/*
+   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 exchangedb/pg_lookup_pending_legitimization.h
+ * @brief implementation of the lookup_pending_legitimization function for 
Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_LOOKUP_COMPLETED_LEGITIMIZATION_H
+#define PG_LOOKUP_COMPLETED_LEGITIMIZATION_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_exchangedb_plugin.h"
+
+
+/**
+ * Lookup measure data for a legitimization process.
+ *
+ * @param cls closure
+ * @param legitimization_measure_serial_id
+ *    row in legitimization_measures table to access
+ * @param measure_index index of the measure to return
+ *    attribute data for
+ * @param[out] access_token
+ *    set to token for access control that must match
+ * @param[out] h_payto set to the the hash of the
+ *    payto URI of the account undergoing legitimization
+ * @param[out] jmeasures set to the legitimization
+ *    measures that were put on the account
+ * @param[out] is_finished set to true if the legitimization was
+ *    already finished
+ * @param[out] encrypted_attributes_len set to length of
+ *    @a encrypted_attributes
+ * @param[out] encrypted_attributes set to the attributes
+ *    obtained for the legitimization process, if it
+ *    succeeded, otherwise set to NULL
+ * @return database transaction status
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_lookup_completed_legitimization (
+  void *cls,
+  uint64_t legitimization_measure_serial_id,
+  uint32_t measure_index,
+  struct TALER_AccountAccessTokenP *access_token,
+  struct TALER_PaytoHashP *h_payto,
+  json_t **jmeasures,
+  bool *is_finished,
+  size_t *encrypted_attributes_len,
+  void **encrypted_attributes);
+
+#endif
diff --git a/src/exchangedb/pg_lookup_transfer_by_deposit.c 
b/src/exchangedb/pg_lookup_transfer_by_deposit.c
index ffa762477..e3c5cb737 100644
--- a/src/exchangedb/pg_lookup_transfer_by_deposit.c
+++ b/src/exchangedb/pg_lookup_transfer_by_deposit.c
@@ -38,7 +38,8 @@ TEH_PG_lookup_transfer_by_deposit (
   struct GNUNET_TIME_Timestamp *exec_time,
   struct TALER_Amount *amount_with_fee,
   struct TALER_Amount *deposit_fee,
-  struct TALER_EXCHANGEDB_KycStatus *kyc)
+  struct TALER_EXCHANGEDB_KycStatus *kyc,
+  union TALER_AccountPublicKeyP *account_pub)
 {
   struct PostgresClosure *pg = cls;
   enum GNUNET_DB_QueryStatus qs;
@@ -63,6 +64,10 @@ TEH_PG_lookup_transfer_by_deposit (
                                  amount_with_fee),
     TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
                                  deposit_fee),
+    GNUNET_PQ_result_spec_allow_null (
+      GNUNET_PQ_result_spec_auto_from_type ("target_pub",
+                                            account_pub),
+      NULL),
     GNUNET_PQ_result_spec_end
   };
 
@@ -78,6 +83,7 @@ TEH_PG_lookup_transfer_by_deposit (
            ",cdep.amount_with_fee"
            ",bdep.wire_salt"
            ",wt.payto_uri"
+           ",wt.target_pub"
            ",denom.fee_deposit"
            " FROM coin_deposits cdep"
            "    JOIN batch_deposits bdep"
diff --git a/src/exchangedb/pg_lookup_transfer_by_deposit.h 
b/src/exchangedb/pg_lookup_transfer_by_deposit.h
index ff5554dcc..2a5340d4f 100644
--- a/src/exchangedb/pg_lookup_transfer_by_deposit.h
+++ b/src/exchangedb/pg_lookup_transfer_by_deposit.h
@@ -42,6 +42,7 @@
  * @param[out] amount_with_fee set to the total deposited amount
  * @param[out] deposit_fee set to how much the exchange did charge for the 
deposit
  * @param[out] kyc set to the kyc status of the receiver (if @a pending)
+ * @param[out] account_pub set to public key that is authorized to start the 
KYC process; unchanged if no such key is known
  * @return transaction status code
  */
 enum GNUNET_DB_QueryStatus
@@ -56,6 +57,7 @@ TEH_PG_lookup_transfer_by_deposit (
   struct GNUNET_TIME_Timestamp *exec_time,
   struct TALER_Amount *amount_with_fee,
   struct TALER_Amount *deposit_fee,
-  struct TALER_EXCHANGEDB_KycStatus *kyc);
+  struct TALER_EXCHANGEDB_KycStatus *kyc,
+  union TALER_AccountPublicKeyP *account_pub);
 
 #endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index dee515a0c..46ac98382 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -56,6 +56,7 @@
 #include "pg_lookup_kyc_status_by_token.h"
 #include "pg_lookup_serial_by_table.h"
 #include "pg_lookup_pending_legitimization.h"
+#include "pg_lookup_completed_legitimization.h"
 #include "pg_lookup_active_legitimization.h"
 #include "pg_select_account_merges_above_serial_id.h"
 #include "pg_select_all_purse_decisions_above_serial_id.h"
@@ -755,6 +756,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &TEH_PG_lookup_signkey_revocation;
   plugin->lookup_denomination_key
     = &TEH_PG_lookup_denomination_key;
+  plugin->lookup_completed_legitimization
+    = &TEH_PG_lookup_completed_legitimization;
   plugin->lookup_pending_legitimization
     = &TEH_PG_lookup_pending_legitimization;
   plugin->lookup_active_legitimization
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 4868e1501..bbd0f30d1 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -984,6 +984,7 @@ test_wire_out (const struct TALER_EXCHANGEDB_BatchDeposit 
*bd)
     struct TALER_Amount coin_fee2;
     struct GNUNET_TIME_Timestamp execution_time2;
     struct TALER_EXCHANGEDB_KycStatus kyc;
+    union TALER_AccountPublicKeyP account_pub;
 
     h_contract_terms_wt2.hash.bits[0]++;
     FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
@@ -997,7 +998,8 @@ test_wire_out (const struct TALER_EXCHANGEDB_BatchDeposit 
*bd)
                                                 &execution_time2,
                                                 &coin_contribution2,
                                                 &coin_fee2,
-                                                &kyc));
+                                                &kyc,
+                                                &account_pub));
   }
   {
     struct TALER_ReservePublicKeyP rpub;
@@ -1029,6 +1031,7 @@ test_wire_out (const struct TALER_EXCHANGEDB_BatchDeposit 
*bd)
     struct TALER_Amount coin_fee2;
     struct GNUNET_TIME_Timestamp execution_time2;
     struct TALER_EXCHANGEDB_KycStatus kyc;
+    union TALER_AccountPublicKeyP account_pub;
 
     FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
             plugin->lookup_transfer_by_deposit (plugin->cls,
@@ -1041,7 +1044,8 @@ test_wire_out (const struct TALER_EXCHANGEDB_BatchDeposit 
*bd)
                                                 &execution_time2,
                                                 &coin_contribution2,
                                                 &coin_fee2,
-                                                &kyc));
+                                                &kyc,
+                                                &account_pub));
     GNUNET_assert (0 == GNUNET_memcmp (&wtid2,
                                        &wire_out_wtid));
     GNUNET_assert (GNUNET_TIME_timestamp_cmp (execution_time2,
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 1f682b4c7..e08371da4 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -4927,6 +4927,7 @@ struct TALER_EXCHANGEDB_Plugin
    * @param[out] execution_time when was the transaction done, or
    *         when we expect it to be done (if @a pending is false)
    * @param[out] kyc set to the kyc status of the receiver (if @a pending)
+   * @param[out] account_pub set to public key that is authorized to start the 
KYC process; unchanged if no such key is known
    * @return transaction status code
    */
   enum GNUNET_DB_QueryStatus
@@ -4941,7 +4942,8 @@ struct TALER_EXCHANGEDB_Plugin
     struct GNUNET_TIME_Timestamp *exec_time,
     struct TALER_Amount *amount_with_fee,
     struct TALER_Amount *deposit_fee,
-    struct TALER_EXCHANGEDB_KycStatus *kyc);
+    struct TALER_EXCHANGEDB_KycStatus *kyc,
+    union TALER_AccountPublicKeyP *account_pub);
 
 
   /**
diff --git a/src/testing/testing_api_cmd_kyc_proof.c 
b/src/testing/testing_api_cmd_kyc_proof.c
index e5135e0f4..af6d9c139 100644
--- a/src/testing/testing_api_cmd_kyc_proof.c
+++ b/src/testing/testing_api_cmd_kyc_proof.c
@@ -175,7 +175,7 @@ proof_kyc_run (void *cls,
 
 
 /**
- * Cleanup the state from a "track transaction" CMD, and possibly
+ * Cleanup the state from a "kyc proof" CMD, and possibly
  * cancel a operation thereof.
  *
  * @param cls closure.

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