[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: work on test library, remove ob
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: work on test library, remove obsolete logic |
Date: |
Tue, 09 Feb 2021 19:52:04 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new f36de84 work on test library, remove obsolete logic
f36de84 is described below
commit f36de84a309127777cd90f3ad6c8e70bb1bd0575
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Feb 9 19:52:02 2021 +0100
work on test library, remove obsolete logic
---
src/include/anastasis_service.h | 136 +++------
src/include/anastasis_testing_lib.h | 247 +++++++--------
src/restclient/Makefile.am | 1 -
src/restclient/anastasis_api_challenge_run.c | 340 ---------------------
src/testing/Makefile.am | 1 -
src/testing/testing_api_cmd_challenge_run.c | 417 --------------------------
src/testing/testing_api_cmd_keyshare_lookup.c | 66 ++--
src/testing/testing_api_cmd_policy_store.c | 179 ++++-------
src/testing/testing_api_cmd_truth_store.c | 161 +++++-----
9 files changed, 311 insertions(+), 1237 deletions(-)
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 684480c..35f526f 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -29,53 +29,6 @@
#include <jansson.h>
-struct ANASTASIS_SaltOperation;
-
-
-/**
- * Detailed results from the successful download.
- */
-struct ANASTASIS_DownloadDetails
-{
- /**
- * Signature (already verified).
- */
- struct ANASTASIS_AccountSignatureP sig;
-
- /**
- * Hash over @e policy and @e policy_size.
- */
- struct GNUNET_HashCode curr_policy_hash;
-
- /**
- * The backup we downloaded.
- */
- const void *policy;
-
- /**
- * Number of bytes in @e backup.
- */
- size_t policy_size;
-};
-
-
-/**
- * Detailed results from the successful download.
- */
-struct ANASTASIS_KeyShareDownloadDetails
-{
- /**
- * The backup we downloaded
- */
- const void *encrypted_key_share;
-
- /**
- * Number of bytes in truth_data.
- */
- size_t encrypted_keyshare_size;
-};
-
-
typedef void
(*ANASTASIS_ConfigCallback)(void *cls,
unsigned int http_status,
@@ -103,6 +56,9 @@ void
ANASTASIS_config_cancel (struct ANASTASIS_ConfigOperation *co);
+struct ANASTASIS_SaltOperation;
+
+
typedef void
(*ANASTASIS_SaltCallback)(void *cls,
unsigned int http_status,
@@ -159,6 +115,34 @@ struct ANASTASIS_SaltOperation
/****** POLICY API ******/
+
+/**
+ * Detailed results from the successful download.
+ */
+struct ANASTASIS_DownloadDetails
+{
+ /**
+ * Signature (already verified).
+ */
+ struct ANASTASIS_AccountSignatureP sig;
+
+ /**
+ * Hash over @e policy and @e policy_size.
+ */
+ struct GNUNET_HashCode curr_policy_hash;
+
+ /**
+ * The backup we downloaded.
+ */
+ const void *policy;
+
+ /**
+ * Number of bytes in @e backup.
+ */
+ size_t policy_size;
+};
+
+
/**
* Handle for a GET /policy operation.
*/
@@ -396,56 +380,22 @@ ANASTASIS_policy_store_cancel (
/****** TRUTH API ******/
-/**
- * Handle for a GET /truth which starts a challenge.
- */
-struct ANASTASIS_ChallengeRunOperation;
/**
- * Callback to process a GET /truth request
- *
- * @param cls closure
- * @param http_status HTTP status code for this request
- * @param ec anastasis-specific error code
- * @param obj the response body
+ * Detailed results from the successful download.
*/
-typedef void
-(*ANASTASIS_ChallengeRunCallback) (
- void *cls,
- unsigned int http_status,
- char *response_string);
-
-
-/**
- * Cancel a GET /truth request.
- *
- * @param tlo cancel the truth lookup operation
-*/
-void
-ANASTASIS_challenge_run_cancel (
- struct ANASTASIS_ChallengeRunOperation *cro);
-
+struct ANASTASIS_KeyShareDownloadDetails
+{
+ /**
+ * The backup we downloaded
+ */
+ const void *encrypted_key_share;
-/**
- * Does a GET /truth to start a challenge (not question)
- *
- * @param ctx execution context
- * @param backend_url base URL of the backend
- * @param truth_public_key identification of the Truth
- * @param truth_key Key used to Decrypt the Truth on the Server
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @return handle for this operation, NULL upon errors
- */
-struct ANASTASIS_ChallengeRunOperation *
-ANASTASIS_challenge_run (
- struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key,
- const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- const struct ANASTASIS_PaymentSecretP *payment_secret,
- ANASTASIS_ChallengeRunCallback cb,
- void *cb_cls);
+ /**
+ * Number of bytes in @e encrypted_key_share.
+ */
+ size_t encrypted_keyshare_size;
+};
/**
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index a68d239..6263f03 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -48,7 +48,7 @@
* @param cmd command to extract the number from.
* @param index the number's index number,
#ANASTASIS_TESTING_TRAIT_HASH_CURRENT or
* #SYNC_TESTING_TRAIT_HASH_PREVIOUS
- * @param h[out] set to the hash coming from @a cmd.
+ * @param[out] h set to the hash coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
@@ -69,21 +69,48 @@ ANASTASIS_TESTING_make_trait_hash (unsigned int index,
const struct GNUNET_HashCode *h);
+/**
+ * Obtain a truth decryption key from @a cmd.
+ *
+ * @param cmd command to extract the public key from.
+ * @param index usually 0
+ * @param[out] key set to the account public key used in @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_truth_key (
+ const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_TruthKeyP **key);
+
+
+/**
+ * Offer an truth decryption key.
+ *
+ * @param index usually zero
+ * @param h the account_pub to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_truth_key (
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *h);
+
+
/**
* Obtain an account public key from @a cmd.
*
* @param cmd command to extract the public key from.
* @param index usually 0
- * @param pub[out] set to the account public key used in @a cmd.
+ * @param[out] pub set to the account public key used in @a cmd.
* @return #GNUNET_OK on success.
*/
int
-ANASTASIS_TESTING_get_trait_account_pub (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct
- ANASTASIS_CRYPTO_AccountPublicKeyP **
- pub);
+ANASTASIS_TESTING_get_trait_account_pub (
+ const struct
+ TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP **pub);
/**
@@ -94,9 +121,9 @@ ANASTASIS_TESTING_get_trait_account_pub (const struct
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_pub (unsigned int index,
- const struct
- ANASTASIS_CRYPTO_AccountPublicKeyP
*h);
+ANASTASIS_TESTING_make_trait_account_pub (
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *h);
/**
@@ -104,16 +131,15 @@ ANASTASIS_TESTING_make_trait_account_pub (unsigned int
index,
*
* @param cmd command to extract the number from.
* @param index must be 0
- * @param priv[out] set to the account private key used in @a cmd.
+ * @param[out] priv set to the account private key used in @a cmd.
* @return #GNUNET_OK on success.
*/
int
-ANASTASIS_TESTING_get_trait_account_priv (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct
- ANASTASIS_CRYPTO_AccountPrivateKeyP
**
- priv);
+ANASTASIS_TESTING_get_trait_account_priv (
+ const struct
+ TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_AccountPrivateKeyP **priv);
/**
@@ -124,80 +150,109 @@ ANASTASIS_TESTING_get_trait_account_priv (const struct
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_priv (unsigned int index,
- const struct
- ANASTASIS_CRYPTO_AccountPrivateKeyP
*
- priv);
+ANASTASIS_TESTING_make_trait_account_priv (
+ unsigned int index,
+ const struct
+ ANASTASIS_CRYPTO_AccountPrivateKeyP *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.
+ * @param[out] payment_secret set to the payment secret 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);
+ANASTASIS_TESTING_get_trait_payment_secret (
+ const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_PaymentSecretP **payment_secret);
+
/**
- * Offer a payment identifier.
+ * Offer a payment secret.
*
* @param index usually zero
- * @param h the payment identifier to offer.
+ * @param h the payment secret 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);
+ANASTASIS_TESTING_make_trait_payment_secret (
+ unsigned int index,
+ const struct ANASTASIS_PaymentSecretP *h);
+
/**
- * Obtain an truth public key from @a cmd.
+ * Obtain an truth UUID from @a cmd.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
- * @param tpk[out] set to the number coming from @a cmd.
+ * @param[out] uuid set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
-ANASTASIS_TESTING_get_trait_truth_public_key (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct
- ANASTASIS_CRYPTO_TruthUUIDP *
- *tpk);
+ANASTASIS_TESTING_get_trait_truth_uuid (
+ const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP **uuid);
+
/**
- * Offer a truth public key.
+ * Offer a truth UUID.
*
* @param index the number's index number.
- * @param tpk the public key to offer.
+ * @param uuid the UUID to offer.
* @return #GNUNET_OK on success.
*/
struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth_public_key (unsigned int index,
- const struct
- ANASTASIS_CRYPTO_TruthUUIDP
- *tpk);
+ANASTASIS_TESTING_make_trait_truth_uuid (
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid);
+
+
+/**
+ * Obtain an encrypted key share from @a cmd.
+ *
+ * @param cmd command to extract the number from.
+ * @param index the number's index number.
+ * @param[out] uuid set to the number coming from @a cmd.
+ * @return #GNUNET_OK on success.
+ */
+int
+ANASTASIS_TESTING_get_trait_eks (
+ const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_EncryptedKeyShareP **eks);
+
+
+/**
+ * Offer an encrypted key share.
+ *
+ * @param index the number's index number.
+ * @param eks the encrypted key share to offer.
+ * @return #GNUNET_OK on success.
+ */
+struct TALER_TESTING_Trait
+ANASTASIS_TESTING_make_trait_eks (
+ unsigned int index,
+ const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks);
+
+
+#if 0
/**
* Obtain a code from @a cmd.
*
* @param cmd command to extract the number from.
* @param index the number's index number.
- * @param tpk[out] set to the number coming from @a cmd.
+ * @param[out] code set to the number coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
-ANASTASIS_TESTING_get_trait_code (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **code);
+ANASTASIS_TESTING_get_trait_code (
+ const struct TALER_TESTING_Command *cmd,
+ unsigned int index,
+ const char **code);
/**
* Offer a filename.
@@ -210,6 +265,9 @@ struct TALER_TESTING_Trait
ANASTASIS_TESTING_make_trait_code (unsigned int index,
const char *code);
+#endif
+
+
/**
* Prepare the merchant execution. Create tables and check if
* the port is available.
@@ -297,8 +355,9 @@ enum ANASTASIS_TESTING_PolicyStoreOption
};
+
/**
- * Make the "policy store" command.
+ * Make a "policy store" command.
*
* @param label command label
* @param anastasis_url base URL of the anastasis serving
@@ -321,6 +380,7 @@ ANASTASIS_TESTING_cmd_policy_store (
const void *recovery_data,
size_t recovery_data_size);
+
/**
* Make the "policy lookup" command.
*
@@ -365,41 +425,6 @@ enum ANASTASIS_TESTING_TruthStoreOption
};
-/**
- * Creates a truth key.
- *
- * @param key_str a str you want to be a truth key
- * @return truthkey
- */
-struct ANASTASIS_CRYPTO_TruthKeyP
-ANASTASIS_TESTING_make_truthkey (const char *key_str);
-
-/**
- * Creates hash of an answer
- *
- * @param answer the answer to a challenge (e.g. a secure question)
- * @param size_answer size of the answer
- * @return hash of the answer
- */
-struct GNUNET_HashCode
-ANASTASIS_TESTING_make_hashed_answer (const void *answer,
- size_t size_answer);
-
-/**
- * Creates a sample of truth.
- *
- * @param method the challenge method
- * @param mime_type mime type of the truth
- * @param answer the hashed answer (part of truth) to a challenge
- * @param key the key to encrypt the truth
- * @return truth in json format
- */
-json_t *
-ANASTASIS_TESTING_make_truth_example (const char *method,
- const char *mime_type,
- const struct GNUNET_HashCode answer,
- const struct
- ANASTASIS_CRYPTO_TruthKeyP key);
/**
* Make the "truth store" command.
@@ -415,9 +440,13 @@ struct TALER_TESTING_Command
ANASTASIS_TESTING_cmd_truth_store (const char *label,
const char *anastasis_url,
const char *prev_upload,
- unsigned int http_status,
+ const char *method,
+ const char *mime_type,
+ size_t truth_data_size,
+ const void *truth_data,
enum ANASTASIS_TESTING_TruthStoreOption tso,
- json_t *truth_data);
+ unsigned int http_status);
+
/**
* Make the "keyshare lookup" command.
@@ -427,10 +456,8 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
* the keyshare lookup request.
* @param http_status expected HTTP status.
* @param answer (response to challenge)
- * @param key key to decrypt truth
* @param payment_ref reference to the payment request
* @param upload_ref reference to upload command
- * @param lookup_mode defines the mode (0= secure question, 1 code based)
* @return the command
*/
struct TALER_TESTING_Command
@@ -438,32 +465,12 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (
const char *label,
const char *anastasis_url,
unsigned int http_status,
- char *answer,
- const struct ANASTASIS_CRYPTO_TruthKeyP key,
+ const char *answer,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *key,
const char *payment_ref,
const char *upload_ref,
int lookup_mode);
-/**
- * Make the "challenge run" command.
- *
- * @param label command label
- * @param anastasis_url base URL of the ANASTASIS serving
- * the challenge run request.
- * @param http_status expected HTTP status.
- * @param key key to decrypt truth
- * @param upload_ref reference to upload command
- * @param payment_ref reference to payment command
- * @return the command
- */
-struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_challenge_run (const char *label,
- const char *anastasis_url,
- unsigned int http_status,
- const struct
- ANASTASIS_CRYPTO_TruthKeyP key,
- const char *upload_ref,
- const char *payment_ref);
struct TALER_TESTING_Command
ANASTASIS_TESTING_cmd_challenge_start (const char *label,
@@ -476,7 +483,7 @@ ANASTASIS_TESTING_cmd_challenge_start (const char *label,
*
* @param cmd command to extract the salt from.
* @param index the salt's index number.
- * @param s[out] set to the salt coming from @a cmd.
+ * @param[out] s set to the salt coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
@@ -518,7 +525,7 @@ ANASTASIS_TESTING_cmd_salt (const char *label,
*
* @param cmd command to extract the truth from.
* @param index the index of the truth
- * @param t[out] set to the truth coming from @a cmd.
+ * @param[out] t set to the truth coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
@@ -588,7 +595,7 @@ ANASTASIS_TESTING_cmd_truth_upload (
*
* @param cmd command to extract the policy from.
* @param index the index of the policy
- * @param t[out] set to the policy coming from @a cmd.
+ * @param[out] p set to the policy coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
@@ -628,7 +635,7 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label,
*
* @param cmd command to extract the core secret from.
* @param index the index of the core secret (usually 0)
- * @param s[out] set to the core secret coming from @a cmd.
+ * @param[out] s set to the core secret coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
@@ -751,7 +758,7 @@ ANASTASIS_TESTING_cmd_recover_secret (const char *label,
*
* @param cmd command to extract the challenge from.
* @param index the index of the challenge
- * @param c[out] set to the challenge coming from @a cmd.
+ * @param[out] c set to the challenge coming from @a cmd.
* @return #GNUNET_OK on success.
*/
int
diff --git a/src/restclient/Makefile.am b/src/restclient/Makefile.am
index cdec57e..7e5d72d 100644
--- a/src/restclient/Makefile.am
+++ b/src/restclient/Makefile.am
@@ -21,7 +21,6 @@ libanastasisrest_la_SOURCES = \
anastasis_api_truth_store.c \
anastasis_api_policy_lookup.c \
anastasis_api_keyshare_lookup.c \
- anastasis_api_challenge_run.c \
anastasis_api_curl_defaults.c anastasis_api_curl_defaults.h
libanastasisrest_la_LIBADD = \
-lgnunetcurl \
diff --git a/src/restclient/anastasis_api_challenge_run.c
b/src/restclient/anastasis_api_challenge_run.c
deleted file mode 100644
index 3a79e78..0000000
--- a/src/restclient/anastasis_api_challenge_run.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
-
- Anastasis is free software; you can redistribute it and/or modify it under
the
- terms of the GNU Lesser General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- Anastasis 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
- Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/anastasis_api_challenge_run.c
- * @brief Implementation of the /truth GET
- * @author Christian Grothoff
- * @author Dennis Neufeld
- * @author Dominik Meister
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <jansson.h>
-#include <microhttpd.h> /* just for HTTP status codes */
-#include "anastasis_service.h"
-#include "anastasis_api_curl_defaults.h"
-
-
-struct ANASTASIS_ChallengeRunOperation
-{
- /**
- * The url for this request, including parameters.
- */
- char *url;
-
- /**
- * Handle for the request.
- */
- struct GNUNET_CURL_Job *job;
-
- /**
- * Function to call with the result.
- */
- ANASTASIS_ChallengeRunCallback cb;
-
- /**
- * Closure for @a cb.
- */
- void *cb_cls;
-
- /**
- * Reference to the execution context.
- */
- struct GNUNET_CURL_Context *ctx;
-
- /**
- * Identification of the Truth Object
- */
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key;
-
- /**
- * Key to decrypt the truth on the server
- */
- const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
-
- /**
- * challenge run response from server(look at number xxx, look at email xxx)
- */
- char *response_string;
-
- /**
- * Payment URI we received from the service, or NULL.
- */
- char *pay_uri;
-
-};
-
-
-void
-ANASTASIS_challenge_run_cancel (
- struct ANASTASIS_ChallengeRunOperation *cro)
-{
- if (NULL != cro->job)
- {
- GNUNET_CURL_job_cancel (cro->job);
- cro->job = NULL;
- }
- GNUNET_free (cro->response_string);
- GNUNET_free (cro->url);
- GNUNET_free (cro->pay_uri);
- GNUNET_free (cro);
-}
-
-
-/**
- * Process GET /truth response
- */
-static void
-handle_challenge_run_finished (void *cls,
- long response_code,
- const void *data,
- size_t data_size)
-{
- struct ANASTASIS_ChallengeRunOperation *cro = cls;
-
- cro->job = NULL;
- switch (response_code)
- {
- case 0:
- /* Hard error */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Backend didn't even return from GET /truth\n");
- break;
- case MHD_HTTP_OK:
- {
- cro->response_string = GNUNET_STRINGS_data_to_string_alloc (data,
- data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Response from backend: %s",cro->response_string);
- cro->cb (cro->cb_cls,
- response_code,
- cro->response_string);
- ANASTASIS_challenge_run_cancel (cro);
- return;
- }
- case MHD_HTTP_PAYMENT_REQUIRED:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Payment URL offered: %s",cro->pay_uri);
- cro->cb (cro->cb_cls,
- response_code,
- cro->pay_uri);
- ANASTASIS_challenge_run_cancel (cro);
- return;
- case MHD_HTTP_BAD_REQUEST:
- /* This should never happen, either us or the anastasis server is buggy
- (or API version conflict); just pass JSON reply to the application */
- break;
- case MHD_HTTP_NOT_FOUND:
- /* Nothing really to verify */
- break;
- case MHD_HTTP_INTERNAL_SERVER_ERROR:
- /* Server had an internal issue; we should retry, but this API
- leaves this to the application */
- break;
- default:
- /* unexpected response code */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
- break;
- }
- if (NULL != cro->cb)
- {
- cro->cb (cro->cb_cls,
- response_code,
- "run failed");
- cro->cb = NULL;
- }
- ANASTASIS_challenge_run_cancel (cro);
-}
-
-
-/**
- * Handle HTTP header received by curl.
- *
- * @param buffer one line of HTTP header data
- * @param size size of an item
- * @param nitems number of items passed
- * @param userdata our `struct ANASTASIS_KeyShareLookupOperation *`
- * @return `size * nitems`
- */
-static size_t
-handle_header (char *buffer,
- size_t size,
- size_t nitems,
- void *userdata)
-{
- struct ANASTASIS_ChallengeRunOperation *cro = userdata;
- size_t total = size * nitems;
- char *ndup;
- const char *hdr_type;
- char *hdr_val;
- char *sp;
-
- ndup = GNUNET_strndup (buffer,
- total);
- hdr_type = strtok_r (ndup,
- ":",
- &sp);
- if (NULL == hdr_type)
- {
- GNUNET_free (ndup);
- return total;
- }
- hdr_val = strtok_r (NULL,
- "\n\r",
- &sp);
- if (NULL == hdr_val)
- {
- GNUNET_free (ndup);
- return total;
- }
- if (' ' == *hdr_val)
- hdr_val++;
-
- if (0 == strcasecmp (hdr_type,
- "Taler"))
- {
- size_t len;
-
- /* found payment URI we care about! */
- cro->pay_uri = GNUNET_strdup (hdr_val);
- len = strlen (cro->pay_uri);
- while ( (len > 0) &&
- ( ('\n' == cro->pay_uri[len - 1]) ||
- ('\r' == cro->pay_uri[len - 1]) ) )
- {
- len--;
- cro->pay_uri[len] = '\0';
- }
- }
- GNUNET_free (ndup);
- return total;
-}
-
-
-struct ANASTASIS_ChallengeRunOperation *
-ANASTASIS_challenge_run (
- struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key,
- const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- const struct ANASTASIS_PaymentSecretP *payment_secret,
- ANASTASIS_ChallengeRunCallback cb,
- void *cb_cls)
-{
- struct ANASTASIS_ChallengeRunOperation *cro;
- CURL *eh;
- struct curl_slist *job_headers;
- char *path;
-
- job_headers = NULL;
- {
- struct curl_slist *ext;
- char *val;
- char *hdr;
-
- /* Set Truth-Decryption-Key header */
- val = GNUNET_STRINGS_data_to_string_alloc (truth_key,
- sizeof (*truth_key));
- GNUNET_asprintf (&hdr,
- "Truth-Decryption-Key: %s",
- val);
- GNUNET_free (val);
- ext = curl_slist_append (job_headers,
- hdr);
- GNUNET_free (hdr);
- if (NULL == ext)
- {
- GNUNET_break (0);
- curl_slist_free_all (job_headers);
- return NULL;
- }
- job_headers = ext;
-
- /* Setup Payment-Identifier header */
- if (NULL != payment_secret)
- {
- char *paid_order_id;
-
- paid_order_id = GNUNET_STRINGS_data_to_string_alloc (
- payment_secret,
- sizeof (*payment_secret));
- GNUNET_asprintf (&hdr,
- "Payment-Identifier: %s",
- paid_order_id);
- GNUNET_free (paid_order_id);
- ext = curl_slist_append (job_headers,
- hdr);
- GNUNET_free (hdr);
- if (NULL == ext)
- {
- GNUNET_break (0);
- curl_slist_free_all (job_headers);
- return NULL;
- }
- job_headers = ext;
- }
- }
- cro = GNUNET_new (struct ANASTASIS_ChallengeRunOperation);
- cro->ctx = ctx;
- cro->truth_key = truth_key;
- {
- char *pub_key_str;
-
- pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
- sizeof
(*truth_public_key));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "truth public key in challenge run: %s\n",
- pub_key_str);
-
- GNUNET_asprintf (&path,
- "truth/%s",
- pub_key_str);
- GNUNET_free (pub_key_str);
- }
- cro->url = TALER_url_join (backend_url,
- path,
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Url get request (challenge run): %s\n",
- cro->url);
- eh = ANASTASIS_curl_easy_get_ (cro->url);
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_HEADERFUNCTION,
- &handle_header));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_HEADERDATA,
- cro));
- cro->cb = cb;
- cro->cb_cls = cb_cls;
- cro->job = GNUNET_CURL_job_add_raw (ctx,
- eh,
- job_headers,
- &handle_challenge_run_finished,
- cro);
- GNUNET_free (path);
- curl_slist_free_all (job_headers);
- return cro;
-}
-
-
-/* end of anastasis_api_challenge_run.c */
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 973c63a..947f87a 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -17,7 +17,6 @@ libanastasistesting_la_SOURCES = \
testing_api_cmd_truth_store.c \
testing_api_cmd_policy_lookup.c \
testing_api_cmd_keyshare_lookup.c \
- testing_api_cmd_challenge_run.c \
testing_api_cmd_salt.c \
testing_api_helpers.c \
testing_api_trait_account_pub.c \
diff --git a/src/testing/testing_api_cmd_challenge_run.c
b/src/testing/testing_api_cmd_challenge_run.c
deleted file mode 100644
index 8e8f15d..0000000
--- a/src/testing/testing_api_cmd_challenge_run.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
-
- Anastasis is free software; you can redistribute it and/or modify it under
the
- terms of the GNU Lesser General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- Anastasis 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
- Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/testing_api_cmd_challenge_run.c
- * @brief Testing of Implementation of the /truth GET
- * @author Christian Grothoff
- * @author Dennis Neufeld
- * @author Dominik Meister
- */
-
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-#include <taler/taler_util.h>
-#include <taler/taler_testing_lib.h>
-
-
-/**
- * State for a "Challenge run state" CMD.
- */
-struct ChallengeRunState
-{
- /**
- * Claim token we got back, if any. Otherwise all zeros.
- */
- struct TALER_ClaimTokenP token;
-
- /**
- * Payment identifier.
- */
- struct ANASTASIS_PaymentSecretP payment_id;
-
- /**
- * Payment order ID we got back, if any. Otherwise NULL.
- */
- char *payment_order_id;
-
- /**
- * Payment order ID we are to provide in the request, may be NULL.
- */
- struct ANASTASIS_PaymentSecretP payment_order_req;
-
- /**
- * The interpreter state.
- */
- struct TALER_TESTING_Interpreter *is;
-
- /**
- * URL of the anastasis backend.
- */
- const char *anastasis_url;
-
- /**
- * Expected status code.
- */
- unsigned int http_status;
-
- /**
- * The /truth GET operation handle.
- */
- struct ANASTASIS_ChallengeRunOperation *cro;
-
- /**
- * Key to decrypt truth
- */
- struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
-
- /**
- * Identification of the Truth Object
- */
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key;
-
- /**
- * Reference to upload command we expect to lookup.
- */
- const char *upload_reference;
- /**
- * Reference to payment command we expect to lookup.
- */
- const char *payment_ref;
-
- /**
- * code we read in the file generated by the plugin
- */
- char *code;
-};
-
-/**
- * Function called with the results of a #ANASTASIS_challenge_run().
- *
- * @param cls closure
- * @param http_status HTTP status of the request
- * @param response_string payment request or instructions
- */
-static void
-challenge_run_cb (void *cls,
- unsigned int http_status,
- char *response_string)
-{
- struct ChallengeRunState *crs = cls;
- crs->cro = NULL;
- if (http_status != crs->http_status)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
- crs->is->commands[crs->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
-
- if (http_status == MHD_HTTP_PAYMENT_REQUIRED)
- {
- const char *m;
-
- if (0 != strncmp (response_string,
- "taler://pay/http",
- strlen ("taler://pay/http")))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- response_string);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- m = strstr (response_string, "/-/-/");
- if (NULL == m)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- response_string);
- TALER_TESTING_interpreter_fail (crs->is);
- /* NOTE: The above is a simplifying assumption for the
- test-logic, hitting this code merely means that
- the assumptions for the test (i.e. no instance) are
- not satisfied, it is not inherently the case that
- the above token must appear in the payment request!
-
- So if you hit this, you might just want to modify
- the code here to handle this better! */
- return;
- }
- crs->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Order ID from Anastasis service is `%s'\n",
- crs->payment_order_id);
- TALER_TESTING_interpreter_next (crs->is);
- return;
- }
-
-
- FILE *file;
- crs->code = malloc (sizeof(char) * 22);
- file = fopen (response_string, "r");
-
- if (file == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "could not find file: %s to command %s in %s:%u\n",
- response_string,
- crs->is->commands[crs->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- if (0 == fscanf (file, "%s", crs->code))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "could not read file: %s to command %s in %s:%u\n",
- response_string,
- crs->is->commands[crs->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
-
- TALER_TESTING_interpreter_next (crs->is);
-}
-
-
-/**
- * Offer internal data to other commands.
- *
- * @param cls closure
- * @param ret[out] result (could be anything)
- * @param trait name of the trait
- * @param index index number of the object to extract.
- * @return #GNUNET_OK on success
- */
-static int
-challenge_run_create_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- struct ChallengeRunState *crs = cls;
- struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_code (0,
- crs->code),
- TALER_TESTING_make_trait_claim_token (0,
- &crs->token),
- TALER_TESTING_make_trait_order_id (0,
- crs->payment_order_id),
- TALER_TESTING_trait_end ()
- };
-
- return TALER_TESTING_get_trait (traits,
- ret,
- trait,
- index);
-}
-
-
-/**
- * Run a "challenge run" CMD.
- *
- * @param cls closure.
- * @param cmd command currently being run.
- * @param is interpreter state.
- */
-static void
-challenge_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
-{
- struct ChallengeRunState *crs = cls;
-
- crs->is = is;
- if (NULL != crs->upload_reference)
- {
- const struct TALER_TESTING_Command *upload_cmd;
-
- upload_cmd = TALER_TESTING_interpreter_lookup_command
- (is,
- crs->upload_reference);
- if (NULL == upload_cmd)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- {
- if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_truth_public_key (upload_cmd,
- 0,
-
&crs->truth_public_key))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- if (NULL == crs->truth_public_key)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Truth public key from trait: %s\n",
- TALER_B2S (crs->truth_public_key));
- }
- }
-
- if (NULL != crs->payment_ref)
- {
- const struct TALER_TESTING_Command *payment_cmd;
-
- payment_cmd = TALER_TESTING_interpreter_lookup_command
- (is,
- crs->payment_ref);
- if (NULL == payment_cmd)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- const char *order_id;
-
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_order_id (payment_cmd,
- 0,
- &order_id))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (order_id,
- strlen (order_id),
- &crs->payment_order_req,
- sizeof (struct
- ANASTASIS_PaymentSecretP)))
- {
- GNUNET_break_op (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
- }
-
- char *pub_key_str;
- pub_key_str = GNUNET_STRINGS_data_to_string_alloc (crs->truth_public_key,
- sizeof (*crs->
-
truth_public_key));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "truth public key in challenge run testing cmd: %s\n",
- pub_key_str);
-
- crs->cro = ANASTASIS_challenge_run (is->ctx,
- crs->anastasis_url,
- crs->truth_public_key,
- &crs->truth_key,
- (NULL != crs->payment_ref)
- ? &crs->payment_order_req
- : NULL,
- &challenge_run_cb,
- crs);
- if (NULL == crs->cro)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (crs->is);
- return;
- }
-}
-
-
-/**
- * Free the state of a "keyshare lookup" CMD, and possibly
- * cancel it if it did not complete.
- *
- * @param cls closure.
- * @param cmd command being freed.
- */
-static void
-challenge_run_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
-{
- struct ChallengeRunState *crs = cls;
-
- if (NULL != crs->cro)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command '%s' did not complete (challenge run)\n",
- cmd->label);
- ANASTASIS_challenge_run_cancel (crs->cro);
- crs->cro = NULL;
- }
- GNUNET_free (crs);
-}
-
-
-/**
- * Make the "challenge run" command.
- *
- * @param label command label
- * @param anastasis_url base URL of the ANASTASIS serving
- * the keyshare lookup request.
- * @param http_status expected HTTP status.
- * @param key key to decrypt truth
- * @param upload_ref reference to upload command
- * @return the command
- */
-struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_challenge_run
- (const char *label,
- const char *anastasis_url,
- unsigned int http_status,
- const struct ANASTASIS_CRYPTO_TruthKeyP key,
- const char *upload_ref,
- const char *payment_ref)
-{
- struct ChallengeRunState *crs;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TruthKey in keyshare lookup cmd: %s\n",
- TALER_B2S (&key));
-
- GNUNET_assert (NULL != upload_ref);
- crs = GNUNET_new (struct ChallengeRunState);
- crs->http_status = http_status;
- crs->anastasis_url = anastasis_url;
- crs->upload_reference = upload_ref;
- crs->truth_key = key;
- crs->payment_ref = payment_ref;
- {
- struct TALER_TESTING_Command cmd = {
- .cls = crs,
- .label = label,
- .run = &challenge_run,
- .cleanup = &challenge_run_cleanup,
- .traits = &challenge_run_create_traits
- };
- return cmd;
- }
-}
-
-
-/* end of testing_api_cmd_keyshare_lookup.c */
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c
b/src/testing/testing_api_cmd_keyshare_lookup.c
index 26f51fd..a4177ed 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -65,7 +65,7 @@ struct KeyShareLookupState
/**
* Identification of the Truth Object
*/
- const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_public_key;
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid;
/**
* Reference to upload command we expect to lookup.
@@ -77,15 +77,16 @@ struct KeyShareLookupState
*/
const char *payment_reference;
- /**
- * Mode for the lookup(0 = question, 1 = code based)
- */
- int lookup_mode;
/**
* Payment secret used for the payment
*/
struct ANASTASIS_PaymentSecretP payment_secret;
+ /**
+ * Mode for the lookup(0 = question, 1 = code based)
+ */
+ int lookup_mode;
+
};
static void
@@ -134,23 +135,20 @@ keyshare_lookup_run (void *cls,
}
{
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_truth_public_key (upload_cmd,
- 0,
-
&ksls->truth_public_key))
+ ANASTASIS_TESTING_get_trait_truth_uuid (upload_cmd,
+ 0,
+ &ksls->truth_uuid))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
- if (NULL == ksls->truth_public_key)
+ if (NULL == ksls->truth_uuid)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Truth public key from trait: %s\n",
- TALER_B2S (ksls->truth_public_key));
}
}
@@ -229,7 +227,7 @@ keyshare_lookup_run (void *cls,
ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
ksls->anastasis_url,
- ksls->truth_public_key,
+ ksls->truth_uuid,
&ksls->truth_key,
&ksls->payment_secret,
&h_answer,
@@ -263,41 +261,19 @@ keyshare_lookup_cleanup (void *cls,
}
-struct GNUNET_HashCode
-ANASTASIS_TESTING_make_hashed_answer (const void *answer,
- size_t size_answer)
-{
- struct GNUNET_HashCode hashed_answer;
- GNUNET_CRYPTO_hash (answer,
- size_answer,
- &hashed_answer);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hashed answer: %s\n",
- TALER_B2S (&hashed_answer));
- return hashed_answer;
-}
-
-
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
- const char *anastasis_url,
- unsigned int http_status,
- char *answer,
- const struct
- ANASTASIS_CRYPTO_TruthKeyP key,
- const char *payment_ref,
- const char *upload_ref,
- int lookup_mode)
+ANASTASIS_TESTING_cmd_keyshare_lookup (
+ const char *label,
+ const char *anastasis_url,
+ unsigned int http_status,
+ const char *answer,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *key,
+ const char *payment_ref,
+ const char *upload_ref,
+ int lookup_mode)
{
struct KeyShareLookupState *ksls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hashed answer in keyshare lookup cmd: %s\n",
- TALER_B2S (&answer));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TruthKey in keyshare lookup cmd: %s\n",
- TALER_B2S (&key));
-
GNUNET_assert (NULL != upload_ref);
ksls = GNUNET_new (struct KeyShareLookupState);
ksls->http_status = http_status;
@@ -305,7 +281,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
ksls->upload_reference = upload_ref;
ksls->payment_reference = payment_ref;
ksls->answer = answer;
- ksls->truth_key = key;
+ ksls->truth_key = *key;
ksls->lookup_mode = lookup_mode;
{
struct TALER_TESTING_Command cmd = {
diff --git a/src/testing/testing_api_cmd_policy_store.c
b/src/testing/testing_api_cmd_policy_store.c
index aaa0fd8..069b095 100644
--- a/src/testing/testing_api_cmd_policy_store.c
+++ b/src/testing/testing_api_cmd_policy_store.c
@@ -68,14 +68,7 @@ struct PolicyStoreState
struct ANASTASIS_CRYPTO_AccountPrivateKeyP anastasis_priv;
/**
- * Hash of the previous upload (maybe bogus if
- * #ANASTASIS_TESTING_UO_PREV_HASH_WRONG is set in @e uo).
- * Maybe all zeros if there was no previous upload.
- */
- struct GNUNET_HashCode prev_hash;
-
- /**
- * Hash of the current upload.
+ * Hash of uploaded data, used to verify the response.
*/
struct GNUNET_HashCode curr_hash;
@@ -99,11 +92,6 @@ struct PolicyStoreState
*/
struct TALER_TESTING_Interpreter *is;
- /**
- * Payment identifier.
- */
- struct ANASTASIS_PaymentSecretP payment_id;
-
/**
* Previous upload, or NULL for none. Used to calculate what THIS
* upload is based on.
@@ -111,14 +99,14 @@ struct PolicyStoreState
const char *prev_upload;
/**
- * Payment order ID we got back, if any. Otherwise NULL.
+ * Payment order ID we are to provide in the request, or zero.
*/
- char *payment_order_id;
+ struct ANASTASIS_PaymentSecretP payment_secret_request;
/**
- * Payment order ID we are to provide in the request, may be NULL.
+ * Payment order ID we are to provide in the response, or zero.
*/
- struct ANASTASIS_PaymentSecretP payment_order_req;
+ struct ANASTASIS_PaymentSecretP payment_secret_response;
/**
* Options for how we are supposed to do the upload.
@@ -126,9 +114,9 @@ struct PolicyStoreState
enum ANASTASIS_TESTING_PolicyStoreOption psopt;
/**
- * True if @e payment_order_req is initialized.
+ * True if @e payment_secret_request is initialized.
*/
- bool payment_order_set;
+ bool payment_secret_set;
};
/**
@@ -140,72 +128,50 @@ struct PolicyStoreState
*/
static void
policy_store_cb (void *cls,
- unsigned int http_status,
const struct ANASTASIS_UploadDetails *ud)
{
struct PolicyStoreState *pss = cls;
+
pss->pso = NULL;
- if (http_status != pss->http_status)
+ if (ud->http_status != pss->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ ud->http_status,
pss->is->commands[pss->is->ip].label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (pss->is);
return;
}
- if (NULL != ud)
+ switch (ud->us)
{
- switch (ud->us)
+ case ANASTASIS_US_SUCCESS:
+ if (0 != GNUNET_memcmp (&pss->curr_hash,
+ ud->details.curr_backup_hash))
{
- case ANASTASIS_US_SUCCESS:
- if (0 != GNUNET_memcmp (&pss->curr_hash,
- ud->details.curr_backup_hash))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- }
- break;
- case ANASTASIS_US_PAYMENT_REQUIRED:
- {
- struct TALER_MERCHANT_PayUriData pd;
-
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
- &pd))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- }
- pss->payment_order_id = GNUNET_strdup (pd.order_id);
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- 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));
- }
- break;
- case ANASTASIS_US_HTTP_ERROR:
- break;
- case ANASTASIS_US_CLIENT_ERROR:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- case ANASTASIS_US_SERVER_ERROR:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- default:
GNUNET_break (0);
TALER_TESTING_interpreter_fail (pss->is);
return;
}
+ break;
+ case ANASTASIS_US_PAYMENT_REQUIRED:
+ pss->payment_secret_response = ud->details.payment.ps;
+ break;
+ case ANASTASIS_US_HTTP_ERROR:
+ break;
+ case ANASTASIS_US_CLIENT_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pss->is);
+ return;
+ case ANASTASIS_US_SERVER_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pss->is);
+ return;
+ default:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pss->is);
+ return;
}
TALER_TESTING_interpreter_next (pss->is);
}
@@ -230,29 +196,14 @@ policy_store_run (void *cls,
{
const struct TALER_TESTING_Command *ref;
- ref = TALER_TESTING_interpreter_lookup_command
- (is,
- pss->prev_upload);
+ ref = TALER_TESTING_interpreter_lookup_command (is,
+ pss->prev_upload);
if (NULL == ref)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (pss->is);
return;
}
- {
- const struct GNUNET_HashCode *h;
-
- if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_hash (ref,
-
ANASTASIS_TESTING_TRAIT_HASH_CURRENT,
- &h))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- }
- pss->prev_hash = *h;
- }
{
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *priv;
@@ -282,30 +233,19 @@ policy_store_run (void *cls,
pss->anastasis_pub = *pub;
}
{
- const char *order_id;
+ const struct ANASTASIS_PaymentSecretP *ps;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_order_id (ref,
- 0,
- &order_id))
+ ANASTASIS_TESTING_get_trait_payment_secret (ref,
+ 0,
+ &ps))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (pss->is);
return;
}
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (order_id,
- strlen (order_id),
- &pss->payment_order_req,
- sizeof (struct
- ANASTASIS_PaymentSecretP)))
- {
- GNUNET_break_op (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- }
- pss->payment_order_set = true;
+ pss->payment_secret_request = *ps;
+ pss->payment_secret_set = true;
}
}
else
@@ -315,27 +255,19 @@ policy_store_run (void *cls,
&pss->anastasis_pub.pub);
}
- if (0 != (ANASTASIS_TESTING_PSO_PREV_HASH_WRONG & pss->psopt))
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &pss->prev_hash,
- sizeof (struct GNUNET_HashCode));
- // hash recovery data
GNUNET_CRYPTO_hash (pss->recovery_data,
pss->recovery_data_size,
&pss->curr_hash);
- pss->pso = ANASTASIS_policy_store (is->ctx,
- pss->anastasis_url,
- &pss->anastasis_priv,
- pss->recovery_data,
- pss->recovery_data_size,
- (0 !=
- (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT
- & pss->psopt)),
- pss->payment_order_set
- ? &pss->payment_order_req
- : NULL,
- &policy_store_cb,
- pss);
+ pss->pso = ANASTASIS_policy_store (
+ is->ctx,
+ pss->anastasis_url,
+ &pss->anastasis_priv,
+ pss->recovery_data,
+ pss->recovery_data_size,
+ (0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)),
+ pss->payment_secret_set ? &pss->payment_secret_request : NULL,
+ &policy_store_cb,
+ pss);
if (NULL == pss->pso)
{
GNUNET_break (0);
@@ -366,7 +298,6 @@ policy_store_cleanup (void *cls,
ANASTASIS_policy_store_cancel (pss->pso);
pss->pso = NULL;
}
- GNUNET_free (pss->payment_order_id);
GNUNET_free (pss);
}
@@ -375,7 +306,7 @@ policy_store_cleanup (void *cls,
* Offer internal data to other commands.
*
* @param cls closure
- * @param ret[out] result (could be anything)
+ * @param[out] ret result (could be anything)
* @param trait name of the trait
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
@@ -390,16 +321,12 @@ policy_store_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_claim_token (0,
&pss->token),
- ANASTASIS_TESTING_make_trait_hash (ANASTASIS_TESTING_TRAIT_HASH_CURRENT,
- &pss->curr_hash),
- ANASTASIS_TESTING_make_trait_hash (ANASTASIS_TESTING_TRAIT_HASH_PREVIOUS,
- &pss->prev_hash),
ANASTASIS_TESTING_make_trait_account_pub (0,
&pss->anastasis_pub),
ANASTASIS_TESTING_make_trait_account_priv (0,
&pss->anastasis_priv),
- TALER_TESTING_make_trait_order_id (0,
- pss->payment_order_id),
+ ANASTASIS_TESTING_make_trait_payment_secret (0,
+
&pss->payment_secret_response),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_truth_store.c
b/src/testing/testing_api_cmd_truth_store.c
index 6656614..8740775 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -33,12 +33,12 @@ struct TruthStoreState
/**
* UUID of the uploaded truth
*/
- struct ANASTASIS_CRYPTO_TruthUUID uuid;
+ struct ANASTASIS_CRYPTO_TruthUUIDP uuid;
/**
* Key used to encrypt the @e truth_data on the server.
*/
- struct ANASTASIS_CRYPTO_TruthKeyP;
+ struct ANASTASIS_CRYPTO_TruthKeyP key;
/**
* "Encrypted" key share data we store at the server.
@@ -122,81 +122,50 @@ struct TruthStoreState
*/
static void
truth_store_cb (void *cls,
- enum TALER_ErrorCode ec,
- unsigned int http_status,
const struct ANASTASIS_UploadDetails *ud)
{
struct TruthStoreState *tss = cls;
tss->tso = NULL;
- if (http_status != tss->http_status)
+ if (ud->http_status != tss->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
- http_status,
+ ud->http_status,
tss->is->commands[tss->is->ip].label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (tss->is);
return;
}
- if (NULL != ud)
+ switch (ud->us)
{
- switch (ud->us)
- {
- case ANASTASIS_US_SUCCESS:
- break;
- case ANASTASIS_US_PAYMENT_REQUIRED:
- {
- struct TALER_MERCHANT_PayUriData pd;
-
- tss->pay_uri = GNUNET_strdup (ud->details.payment_request);
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
- &pd))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- }
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (
- pd.order_id,
- strlen (pd.order_id),
- &tss->payment_secret_response,
- sizeof (tss->payment_secret_response)))
- {
- GNUNET_break (0);
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- }
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- }
- break;
- case ANASTASIS_US_CONFLICTING_TRUTH:
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- }
- case ANASTASIS_US_HTTP_ERROR:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- case ANASTASIS_US_CLIENT_ERROR:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- case ANASTASIS_US_SERVER_ERROR:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- default:
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (tss->is);
- return;
- }
+ case ANASTASIS_US_SUCCESS:
+ break;
+ case ANASTASIS_US_PAYMENT_REQUIRED:
+ tss->pay_uri = GNUNET_strdup (ud->details.payment.payment_request);
+ tss->payment_secret_response = ud->details.payment.ps;
+ break;
+ case ANASTASIS_US_CONFLICTING_TRUTH:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tss->is);
+ return;
+ case ANASTASIS_US_HTTP_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tss->is);
+ return;
+ case ANASTASIS_US_CLIENT_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tss->is);
+ return;
+ case ANASTASIS_US_SERVER_ERROR:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tss->is);
+ return;
+ default:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tss->is);
+ return;
}
TALER_TESTING_interpreter_next (tss->is);
}
@@ -235,9 +204,9 @@ truth_store_run (void *cls,
const struct ANASTASIS_PaymentSecretP *ps_req;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_payment_secret (ref,
- 0,
- &ps_req))
+ ANASTASIS_TESTING_get_trait_payment_secret (ref,
+ 0,
+ &ps_req))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tss->is);
@@ -248,13 +217,13 @@ truth_store_run (void *cls,
if (0 != (ANASTASIS_TESTING_TSO_REFERENCE_UUID & tss->tsopt))
{
- struct ANASTASIS_CRYPTO_TruthUUID *uuid;
- struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks;
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid;
+ const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_uuid (ref,
- 0,
- &uuid))
+ ANASTASIS_TESTING_get_trait_truth_uuid (ref,
+ 0,
+ &uuid))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tss->is);
@@ -262,9 +231,9 @@ truth_store_run (void *cls,
}
tss->uuid = *uuid;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_encrypted_key_share (ref,
- 0,
- &eks))
+ ANASTASIS_TESTING_get_trait_eks (ref,
+ 0,
+ &eks))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tss->is);
@@ -276,19 +245,23 @@ truth_store_run (void *cls,
else
{
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
- &tss->truth_uuid,
- sizeof (struct ANASTASIS_CRYPTO_TruthUUID));
+ &tss->uuid,
+ sizeof (struct ANASTASIS_CRYPTO_TruthUUIDP));
GNUNET_CRYPTO_random_block (
GNUNET_CRYPTO_QUALITY_WEAK,
&tss->encrypted_keyshare,
sizeof (struct ANASTASIS_CRYPTO_EncryptedKeyShareP));
}
+ GNUNET_CRYPTO_random_block (
+ GNUNET_CRYPTO_QUALITY_WEAK,
+ &tss->key,
+ sizeof (struct ANASTASIS_CRYPTO_TruthKeyP));
{
void *encrypted_truth;
size_t size_encrypted_truth;
- ANASTASIS_CRYPTO_truth_encrypt (&key,
+ ANASTASIS_CRYPTO_truth_encrypt (&tss->key,
tss->truth_data,
tss->truth_data_size,
&encrypted_truth,
@@ -296,10 +269,10 @@ truth_store_run (void *cls,
tss->tso = ANASTASIS_truth_store (
is->ctx,
tss->anastasis_url,
- &tss->truth_public_key,
+ &tss->uuid,
tss->method,
- &tss->keyshare_data,
- tss->truth_mime,
+ &tss->encrypted_keyshare,
+ tss->mime_type,
size_encrypted_truth,
encrypted_truth,
(0 != (ANASTASIS_TESTING_TSO_REQUEST_PAYMENT & tss->tsopt)),
@@ -365,12 +338,14 @@ truth_store_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
ANASTASIS_TESTING_make_trait_truth_uuid (0,
&tss->uuid),
- ANASTASIS_TESTING_make_trait_encrypted_key_share (0,
-
&tss->encrypted_keyshare),
+ ANASTASIS_TESTING_make_trait_truth_key (0,
+ &tss->key),
+ ANASTASIS_TESTING_make_trait_eks (0,
+ &tss->encrypted_keyshare),
ANASTASIS_TESTING_make_trait_payment_secret (0,
&tss->payment_secret_response),
- TALER_TESTING_make_trait_url (TALER_TESTING_PT_TALER_URL,
- &tss->pay_uri),
+ TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
+ tss->pay_uri),
TALER_TESTING_trait_end ()
};
@@ -382,21 +357,19 @@ truth_store_traits (void *cls,
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_truth_store (
- const char *label,
- const char *anastasis_url,
- const char *prev_upload,
- const char *method,
- const char *mime_type,
- size_t truth_data_size,
- const void *truth_data,
- unsigned int http_status,
- enum ANASTASIS_TESTING_TruthStoreOption tso)
+ANASTASIS_TESTING_cmd_truth_store (const char *label,
+ const char *anastasis_url,
+ const char *prev_upload,
+ const char *method,
+ const char *mime_type,
+ size_t truth_data_size,
+ const void *truth_data,
+ enum ANASTASIS_TESTING_TruthStoreOption tso,
+ unsigned int http_status)
{
struct TruthStoreState *tss;
tss = GNUNET_new (struct TruthStoreState);
- tss->truth_data = truth_data;
tss->http_status = http_status;
tss->tsopt = tso;
tss->anastasis_url = anastasis_url;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: work on test library, remove obsolete logic,
gnunet <=