[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/02: Merge, worked on payment testing (policy upload
From: |
gnunet |
Subject: |
[taler-anastasis] 02/02: Merge, worked on payment testing (policy upload) |
Date: |
Tue, 21 Jan 2020 12:29:03 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 7c488d17e3bf7b74fe9be43af8f527f078b68bb0
Author: Dennis Neufeld <address@hidden>
AuthorDate: Tue Jan 21 11:21:22 2020 +0000
Merge, worked on payment testing (policy upload)
---
src/backend/anastasis-httpd.c | 1 -
src/include/anastasis_service.h | 9 ++--
src/include/anastasis_testing_lib.h | 27 ++++++++++
src/lib/Makefile.am | 1 +
src/lib/anastasis_api_policy_store.c | 1 +
src/lib/test_anastasis_api.c | 10 ----
src/lib/testing_api_cmd_policy_store.c | 48 +++++++++++------
src/lib/testing_api_trait_payment_identifier.c | 74 ++++++++++++++++++++++++++
8 files changed, 139 insertions(+), 32 deletions(-)
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index a923e0c..ba4f8f7 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -266,7 +266,6 @@ url_handler (void *cls,
}
GNUNET_SCHEDULER_begin_async_scope (&aid);
-
if (NULL != correlation_id)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handling request for (%s) URL '%s', correlation_id=%s\n",
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 43644cf..e314bd0 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -206,9 +206,9 @@ struct ANASTASIS_KeyShareDownloadDetails
*/
const void *encrypted_key_share;
- /**
- * Number of bytes in truth_data.
- */
+ /**
+ * Number of bytes in truth_data.
+ */
size_t encrypted_key_share_size;
};
@@ -432,7 +432,8 @@ struct ANASTASIS_KeyShareLookupOperation;
typedef void
(*ANASTASIS_KeyShareLookupCallback) (void *cls,
unsigned int http_status,
- const struct
ANASTASIS_KeyShareDownloadDetails *kdd);
+ const struct
+ ANASTASIS_KeyShareDownloadDetails *kdd);
/**
* Does a GET /truth.
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index a617fb5..dde2b37 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -131,6 +131,33 @@ ANASTASIS_TESTING_make_trait_account_priv (unsigned int
index,
const struct
ANASTASIS_AccountPrivP *priv);
+/**
+ * Obtain an account public key from @a cmd.
+ *
+ * @param cmd command to extract the payment identifier from.
+ * @param index the payment identifier's index number.
+ * @param n[out] set to the payment identifier coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_payment_identifier (const struct
+ TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct
+ ANASTASIS_PaymentSecretP **
+ payment_identifier);
+
+/**
+ * Offer a payment identifier.
+ *
+ * @param index usually zero
+ * @param h the payment identifier to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_payment_identifier (unsigned int index,
+ const struct
+ ANASTASIS_PaymentSecretP *h);
/**
* Prepare the merchant execution. Create tables and check if
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d156841..e893b22 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -55,6 +55,7 @@ libanastasistesting_la_SOURCES = \
testing_api_helpers.c \
testing_api_trait_account_pub.c \
testing_api_trait_account_priv.c \
+ testing_api_trait_payment_identifier.c \
testing_api_trait_hash.c
libanastasistesting_la_LIBADD = \
libanastasisrest.la \
diff --git a/src/lib/anastasis_api_policy_store.c
b/src/lib/anastasis_api_policy_store.c
index 61b1da0..b569f7f 100644
--- a/src/lib/anastasis_api_policy_store.c
+++ b/src/lib/anastasis_api_policy_store.c
@@ -377,6 +377,7 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
"Payment-Identifier: %s",
val);
GNUNET_free (val);
+
ext = curl_slist_append (job_headers,
hdr);
GNUNET_free (hdr);
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 991853b..1203a6d 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -50,11 +50,6 @@
*/
#define EXCHANGE_URL "http://localhost:8081/"
-/**
- * Payment Secret for the test, set to a random value
- */
-static struct ANASTASIS_PaymentSecretP paymentSecret;
-
/**
* URL of the fakebank.
*/
@@ -225,11 +220,6 @@ static void
run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
- // fill data
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &paymentSecret,
- sizeof (paymentSecret));
-
struct TALER_TESTING_Command pay[] = {
/**
* Move money to the exchange's bank account.
diff --git a/src/lib/testing_api_cmd_policy_store.c
b/src/lib/testing_api_cmd_policy_store.c
index e5b2c09..606ccbf 100644
--- a/src/lib/testing_api_cmd_policy_store.c
+++ b/src/lib/testing_api_cmd_policy_store.c
@@ -95,7 +95,7 @@ struct PolicyStoreState
/**
* Payment identifier.
*/
- const struct ANASTASIS_PaymentSecretP *payment_id;
+ struct ANASTASIS_PaymentSecretP *payment_id;
/**
* Previous upload, or NULL for none. Used to calculate what THIS
@@ -202,6 +202,7 @@ policy_store_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Order ID from Anastasis service is `%s'\n",
pss->payment_order_id);
+
memset (&pss->curr_hash,
0,
sizeof (struct GNUNET_HashCode));
@@ -314,25 +315,41 @@ policy_store_run (void *cls,
}
pss->anastasis_pub = *pub;
}
- if (0 != (ANASTASIS_TESTING_PSO_REFERENCE_ORDER_ID & pss->psopt))
{
- const char *order_id;
+ const struct ANASTASIS_PaymentSecretP *payment_identifier;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_order_id (ref,
- 0,
- &order_id))
+ ANASTASIS_TESTING_get_trait_payment_identifier (ref,
+ 0,
+ &payment_identifier))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (pss->is);
return;
}
- pss->payment_order_req = order_id;
- if (NULL == pss->payment_order_req)
+ pss->payment_id = payment_identifier;
+ }
+ if (0 != (ANASTASIS_TESTING_PSO_REFERENCE_ORDER_ID & pss->psopt))
+ {
{
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
+ const char *order_id;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_order_id (ref,
+ 0,
+ &order_id))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pss->is);
+ return;
+ }
+ pss->payment_order_req = order_id;
+ if (NULL == pss->payment_order_req)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pss->is);
+ return;
+ }
}
}
}
@@ -376,9 +393,7 @@ policy_store_run (void *cls,
(0 !=
(ANASTASIS_TESTING_PSO_REQUEST_PAYMENT
& pss->psopt)),
- (NULL != pss->payment_id)
- ? pss->payment_id
- : NULL,
+ pss->payment_id,
&policy_store_cb,
pss);
if (NULL == pss->pso)
@@ -442,6 +457,8 @@ policy_store_traits (void *cls,
&pss->anastasis_priv),
TALER_TESTING_make_trait_order_id (0,
pss->payment_order_id),
+ ANASTASIS_TESTING_make_trait_payment_identifier (0,
+ &pss->payment_id),
TALER_TESTING_trait_end ()
};
@@ -460,9 +477,6 @@ policy_store_traits (void *cls,
* the policy store request.
* @param http_status expected HTTP status.
* @param pso policy store options
- * @param priv private account identifier
- * @param pub account identifier
- * @param payment_id payment identifier
* @param recovery_data recovery data to post
* @param recovery_data_size size of recovery/policy data
* @return the command
diff --git a/src/lib/testing_api_trait_payment_identifier.c
b/src/lib/testing_api_trait_payment_identifier.c
new file mode 100644
index 0000000..5256a79
--- /dev/null
+++ b/src/lib/testing_api_trait_payment_identifier.c
@@ -0,0 +1,74 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2019 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 lib/testing_api_trait_payment_identifier.c
+ * @brief traits to offer a payment identifier
+ * @author Dennis Neufeld
+ */
+#include "platform.h"
+#include "anastasis_service.h"
+#include "anastasis_testing_lib.h"
+
+#define ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER \
+ "anastasis-payment_identifier"
+
+
+/**
+ * Obtain an account public key from @a cmd.
+ *
+ * @param cmd command to extract the payment identifier from.
+ * @param index the payment identifier's index number.
+ * @param n[out] set to the payment identifier coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_payment_identifier
+ (const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_PaymentSecretP **payment_identifier)
+{
+ return cmd->traits (cmd->cls,
+ (const void **) payment_identifier,
+ ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER,
+ index);
+}
+
+
+/**
+ * Offer a payment identifier.
+ *
+ * @param index usually zero
+ * @param h the payment identifier to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_payment_identifier
+ (unsigned int index,
+ const struct ANASTASIS_PaymentSecretP *h)
+{
+ struct TALER_TESTING_Trait ret = {
+ .index = index,
+ .trait_name = ANASTASIS_TESTING_TRAIT_PAYMENT_IDENTIFIER,
+ .ptr = (const void *) h
+ };
+ return ret;
+}
+
+
+/* end of testing_api_trait_payment_identifier.c */
--
To stop receiving notification emails like this one, please contact
address@hidden.