commit a5e9361b7c2e648d974df3407b9f47bebb214be7
parent 9e3928b2983f6cc917d8909de58177339d3d1423
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Mon, 31 Mar 2025 18:41:23 +0200
few updates of the donau test and api
Diffstat:
4 files changed, 147 insertions(+), 7 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1754,8 +1754,7 @@ phase_success_response (struct PayContext *pc)
token_sigs = (0 >= pc->validate_tokens.output_tokens_len)
? NULL
: build_token_sigs (pc);
- // FIXME: somehow have to convert from the sigs to the json,
- // maybe signatures_to_JSON (donau-httpd-batch-issue.c) could be usefull
+
pay_end (pc,
TALER_MHD_REPLY_JSON_PACK (
pc->connection,
@@ -1767,7 +1766,6 @@ phase_success_response (struct PayContext *pc)
GNUNET_JSON_pack_array_steal ("token_sigs",
token_sigs)),
#ifdef HAVE_DONAU_DONAU_SERVICE_H
- // FIXME: Check for the correctness of pack method
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_array_steal ("donau_sigs",
pc->donau_receipt.donau_sigs_json)),
diff --git a/src/backenddb/pg_lookup_order_charity.c b/src/backenddb/pg_lookup_order_charity.c
@@ -0,0 +1,84 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2025 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 backenddb/pg_lookup_donau_charity.c
+ * @brief Implementation for retrieving Donau charity_id and corresponding private key
+ * by Donau URL.
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "donau/donau_service.h"
+#include "pg_lookup_order_charity.h"
+#include "pg_helper.h"
+
+/**
+ * Implementation of #TMH_PG_lookup_donau_charity.
+ *
+ * This function:
+ * 1. Finds the relevant row in merchant_donau_instances by matching donau_url.
+ * 2. Joins to merchant_instances by comparing charity_pub_key = merchant_pub.
+ * 3. Joins to merchant_keys by matching the merchant_serial from merchant_instances,
+ * retrieving merchant_priv (the private key).
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_lookup_order_charity (
+ void *cls,
+ const char *donau_url,
+ uint64_t *charity_id,
+ struct DONAU_CharityPrivateKeyP *charity_priv)
+{
+ struct PostgresClosure *pg = cls;
+
+ uint64_t cid;
+ struct DONAU_CharityPrivateKeyP cpriv;
+
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (donau_url),
+ GNUNET_PQ_query_param_end
+ };
+
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("charity_id", &cid),
+ GNUNET_PQ_result_spec_auto_from_type ("merchant_priv", &cpriv),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+
+ PREPARE(pg,
+ "lookup_donau_charity",
+ "SELECT di.charity_id, k.merchant_priv "
+ "FROM merchant_donau_instances di "
+ "JOIN merchant_instances mi "
+ " ON di.charity_pub_key = mi.merchant_pub "
+ "JOIN merchant_keys k "
+ " ON mi.merchant_serial = k.merchant_serial "
+ "WHERE di.donau_url=$1"
+ ";");
+
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_donau_charity",
+ params,
+ rs);
+}
+\ No newline at end of file
diff --git a/src/backenddb/pg_lookup_order_charity.h b/src/backenddb/pg_lookup_order_charity.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2025 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 backenddb/pg_lookup_donau_charity.h
+ * @brief Header for retrieving Donau charity_id and corresponding private key
+ * by Donau URL.
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#ifndef PG_LOOKUP_DONAU_CHARITY_H
+#define PG_LOOKUP_DONAU_CHARITY_H
+
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "donau/donau_service.h"
+#include "pg_helper.h"
+
+/**
+ * Retrieve the charity’s ID and private key for a given Donau URL.
+ *
+ * @param cls plugin closure (the Postgres DB handle / struct PostgresClosure *)
+ * @param donau_url base URL of the Donau instance
+ * @param[out] charity_id set to the `charity_id` from `merchant_donau_instances`
+ * @param[out] charity_priv set to the private key (32 bytes)
+ * @return #GNUNET_DB_STATUS_SUCCESS if found,
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if none found,
+ * #GNUNET_DB_STATUS_SOFT_ERROR or #GNUNET_DB_STATUS_HARD_ERROR on errors
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_lookup_order_charity (
+ void *cls,
+ const char *donau_url,
+ uint64_t *charity_id,
+ struct DONAU_CharityPrivateKeyP *charity_priv);
+
+#endif /* PG_LOOKUP_DONAU_CHARITY_H */
+\ No newline at end of file
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
@@ -1817,14 +1817,15 @@ run (void *cls,
};
struct TALER_TESTING_Command donau[] = {
- TALER_TESTING_cmd_merchant_get_donau_instances(
- "get-donau-instance",
- merchant_url,
- MHD_HTTP_OK),
TALER_TESTING_cmd_merchant_post_donau_instance(
"post-donau-instance",
merchant_url,
MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_get_donau_instances(
+ "get-donau-instance",
+ merchant_url,
+ MHD_HTTP_OK),
+ //FIXME: Add the part with making the order and paying it over with the donau receipt
TALER_TESTING_cmd_merchant_delete_donau_instance(
"delete-donau-instance",
merchant_url,