gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: get test_anastasis to pass


From: gnunet
Subject: [taler-anastasis] branch master updated: get test_anastasis to pass
Date: Sun, 14 Feb 2021 23:32:59 +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 f299ebc  get test_anastasis to pass
f299ebc is described below

commit f299ebcafb4a1b5162db508d03e75565ed6b6507
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 14 23:32:57 2021 +0100

    get test_anastasis to pass
---
 src/backend/anastasis-httpd_truth.c        |  4 +--
 src/include/anastasis_testing_lib.h        | 30 +++++++++++++++++--
 src/testing/test_anastasis.c               | 47 +++++++++++++-----------------
 src/testing/test_anastasis_api.conf        |  6 ++--
 src/testing/testing_cmd_challenge_answer.c | 11 ++++---
 src/testing/testing_cmd_recover_secret.c   | 23 ++-------------
 src/testing/testing_cmd_truth_upload.c     | 39 +++++++++++++++++++++++--
 7 files changed, 101 insertions(+), 59 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index c7decb0..bf4b182 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -906,8 +906,8 @@ AH_handler_truth_get (
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Wrong answer provided to secure question had %u bytes, 
wanted %u\n",
-                  (unsigned int) sizeof (challenge_response),
-                  (unsigned int) decrypted_truth_size);
+                  (unsigned int) decrypted_truth_size,
+                  (unsigned int) sizeof (challenge_response));
       GNUNET_free (decrypted_truth);
       GNUNET_free (truth_mime);
       /* for rate-limiting... */
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 0ab121c..f3d65ba 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -606,6 +606,34 @@ ANASTASIS_TESTING_cmd_truth_upload (
   const char *upload_ref);
 
 
+/**
+ * Make the "truth upload" command for a security question.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param id_data ID data to generate user identifier
+ * @param instructions specifies what the client/user has to do
+ * @param mime_type mime type of truth_data
+ * @param answer the answer to the security question
+ * @param paid_order_id already paid order ID for this truth upload, or NULL
+ * @param http_status expected HTTP status
+ * @param tso truth upload options
+ * @param upload_ref reference to the previous upload
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_upload_question (
+  const char *label,
+  const char *anastasis_url,
+  const json_t *id_data,
+  const char *instructions,
+  const char *mime_type,
+  const void *answer,
+  const char *paid_order_ref,
+  unsigned int http_status,
+  enum ANASTASIS_TESTING_TruthStoreOption tso,
+  const char *salt_ref);
+
 /* ********************* test policy create ********************* */
 
 /**
@@ -755,7 +783,6 @@ enum ANASTASIS_TESTING_RecoverSecretOption
  * @param anastasis_url base URL of the anastasis serving our requests.
  * @param id_data identfication data from the user
  * @param version of the recovery document to download
- * @param http_status expected HTTP status.
  * @param rso recover secret options
  * @param download_ref salt download reference
  * @return the command
@@ -766,7 +793,6 @@ ANASTASIS_TESTING_cmd_recover_secret (
   const char *anastasis_url,
   const json_t *id_data,
   unsigned int version,
-  unsigned int http_status,
   enum ANASTASIS_TESTING_RecoverSecretOption rso,
   const char *download_ref,
   const char *core_secret_ref);
diff --git a/src/testing/test_anastasis.c b/src/testing/test_anastasis.c
index 0b3b10c..206a8c6 100644
--- a/src/testing/test_anastasis.c
+++ b/src/testing/test_anastasis.c
@@ -183,30 +183,26 @@ run (void *cls,
     ANASTASIS_TESTING_cmd_salt ("salt-request-1",
                                 anastasis_url,
                                 MHD_HTTP_OK),
-    ANASTASIS_TESTING_cmd_truth_upload ("truth-create-1",
-                                        anastasis_url,
-                                        id_data,
-                                        "question",
-                                        "answer the question",
-                                        "text/plain",
-                                        "SomeTruth1",
-                                        strlen ("SomeTruth1"),
-                                        NULL,
-                                        MHD_HTTP_NO_CONTENT,
-                                        ANASTASIS_TESTING_TSO_NONE,
-                                        "salt-request-1"),
-    ANASTASIS_TESTING_cmd_truth_upload ("truth-create-2",
-                                        anastasis_url,
-                                        id_data,
-                                        "question",
-                                        "answer the question",
-                                        "text/plain",
-                                        "SomeTruth2",
-                                        strlen ("SomeTruth2"),
-                                        NULL,
-                                        MHD_HTTP_NO_CONTENT,
-                                        ANASTASIS_TESTING_TSO_NONE,
-                                        "salt-request-1"),
+    ANASTASIS_TESTING_cmd_truth_upload_question ("truth-create-1",
+                                                 anastasis_url,
+                                                 id_data,
+                                                 "answer the question",
+                                                 "text/plain",
+                                                 "SomeTruth1",
+                                                 NULL,
+                                                 MHD_HTTP_NO_CONTENT,
+                                                 ANASTASIS_TESTING_TSO_NONE,
+                                                 "salt-request-1"),
+    ANASTASIS_TESTING_cmd_truth_upload_question ("truth-create-2",
+                                                 anastasis_url,
+                                                 id_data,
+                                                 "answer the question",
+                                                 "text/plain",
+                                                 "SomeTruth2",
+                                                 NULL,
+                                                 MHD_HTTP_NO_CONTENT,
+                                                 ANASTASIS_TESTING_TSO_NONE,
+                                                 "salt-request-1"),
     ANASTASIS_TESTING_cmd_truth_upload ("truth-create-3",
                                         anastasis_url,
                                         id_data,
@@ -273,8 +269,7 @@ run (void *cls,
     ANASTASIS_TESTING_cmd_recover_secret ("recover-secret-1",
                                           anastasis_url,
                                           id_data,
-                                          0,
-                                          MHD_HTTP_PAYMENT_REQUIRED, // FIXME! 
WHY!?
+                                          0, /* version */
                                           ANASTASIS_TESTING_RSO_NONE,
                                           "salt-request-1",
                                           "secret-share-2"),
diff --git a/src/testing/test_anastasis_api.conf 
b/src/testing/test_anastasis_api.conf
index 40d5d29..d2a0bec 100644
--- a/src/testing/test_anastasis_api.conf
+++ b/src/testing/test_anastasis_api.conf
@@ -22,13 +22,13 @@ currency = EUR
 
 [taler-helper-crypto-rsa]
 # Reduce from 1 year to speed up test
-LOOKAHEAD_SIGN = 24 days
+LOOKAHEAD_SIGN = 12 days
 
 [taler-helper-crypto-eddsa]
 # Reduce from 1 year to speed up test
-LOOKAHEAD_SIGN = 24 days
+LOOKAHEAD_SIGN = 12 days
 # Reduce from 12 weeks to ensure we have multiple
-DURATION = 14 days
+DURATION = 7 days
 
 
 [bank]
diff --git a/src/testing/testing_cmd_challenge_answer.c 
b/src/testing/testing_cmd_challenge_answer.c
index f0a7d53..6b6e9f1 100644
--- a/src/testing/testing_cmd_challenge_answer.c
+++ b/src/testing/testing_cmd_challenge_answer.c
@@ -177,6 +177,7 @@ challenge_answer_run (void *cls,
   struct ChallengeState *cs = cls;
   const struct ANASTASIS_Challenge *c;
   const struct ANASTASIS_PaymentSecretP *ps;
+  const char *answer;
 
   cs->is = is;
   if (NULL != cs->challenge_ref)
@@ -204,7 +205,6 @@ challenge_answer_run (void *cls,
   }
   if (1 == cs->mode)
   {
-    const char *code;
     const struct TALER_TESTING_Command *ref;
 
     ref = TALER_TESTING_interpreter_lookup_command (is,
@@ -218,13 +218,16 @@ challenge_answer_run (void *cls,
     if (GNUNET_OK !=
         ANASTASIS_TESTING_get_trait_code (ref,
                                           0,
-                                          &code))
+                                          &answer))
     {
       GNUNET_break (0);
       TALER_TESTING_interpreter_fail (cs->is);
       return;
     }
-    cs->answer = code;
+  }
+  else
+  {
+    answer = cs->answer;
   }
 
   if (NULL != cs->payment_ref)
@@ -258,7 +261,7 @@ challenge_answer_run (void *cls,
   if (GNUNET_OK !=
       ANASTASIS_challenge_answer (cs->c,
                                   ps,
-                                  cs->answer,
+                                  answer,
                                   &challenge_answer_cb,
                                   cs))
   {
diff --git a/src/testing/testing_cmd_recover_secret.c 
b/src/testing/testing_cmd_recover_secret.c
index 5fb110f..f40219a 100644
--- a/src/testing/testing_cmd_recover_secret.c
+++ b/src/testing/testing_cmd_recover_secret.c
@@ -42,11 +42,6 @@ struct RecoverSecretState
    */
   const char *anastasis_url;
 
-  /**
-   * Expected status code.
-   */
-  unsigned int http_status;
-
   /**
    * The /policy GET operation handle.
    */
@@ -120,7 +115,9 @@ core_secret_cb (void *cls,
   struct RecoverSecretState *rss = cls;
 
   rss->recovery = NULL;
-  if (0 != memcmp (secret, rss->core_secret, secret_size))
+  if (0 != memcmp (secret,
+                   rss->core_secret,
+                   secret_size))
   {
     GNUNET_break (0);
     TALER_TESTING_interpreter_fail (rss->is);
@@ -277,25 +274,12 @@ recover_secret_traits (void *cls,
 }
 
 
-/**
- * Make the "recover secret" command.
- *
- * @param label command label
- * @param anastasis_url base URL of the anastasis serving our requests.
- * @param id_data identfication data from the user
- * @param version of the recovery document to download
- * @param http_status expected HTTP status.
- * @param rso recover secret options
- * @param download_ref salt download reference
- * @return the command
- */
 struct TALER_TESTING_Command
 ANASTASIS_TESTING_cmd_recover_secret (
   const char *label,
   const char *anastasis_url,
   const json_t *id_data,
   unsigned int version,
-  unsigned int http_status,
   enum ANASTASIS_TESTING_RecoverSecretOption rso,
   const char *download_ref,
   const char *core_secret_ref)
@@ -303,7 +287,6 @@ ANASTASIS_TESTING_cmd_recover_secret (
   struct RecoverSecretState *rss;
 
   rss = GNUNET_new (struct RecoverSecretState);
-  rss->http_status = http_status;
   rss->version = version;
   rss->id_data = json_incref ((json_t *) id_data);
   rss->rsopt = rso;
diff --git a/src/testing/testing_cmd_truth_upload.c 
b/src/testing/testing_cmd_truth_upload.c
index 36d16d0..92c9a52 100644
--- a/src/testing/testing_cmd_truth_upload.c
+++ b/src/testing/testing_cmd_truth_upload.c
@@ -71,7 +71,7 @@ struct TruthUploadState
   /**
    * The truth_data (e.g. hash of answer to a secure question)
    */
-  const void *truth_data;
+  void *truth_data;
 
   /**
    * Command to a previous truth upload from which to take the
@@ -277,6 +277,7 @@ truth_upload_cleanup (void *cls,
     ANASTASIS_truth_free (tus->truth);
     tus->truth = NULL;
   }
+  GNUNET_free (tus->truth_data);
   GNUNET_free (tus);
 }
 
@@ -353,7 +354,8 @@ ANASTASIS_TESTING_cmd_truth_upload (
   tus->mime_type = mime_type;
   tus->paid_order_ref = paid_order_ref;
   tus->truth_data_size = truth_data_size;
-  tus->truth_data = truth_data;
+  tus->truth_data = GNUNET_memdup (truth_data,
+                                   truth_data_size);
   {
     struct TALER_TESTING_Command cmd = {
       .cls = tus,
@@ -368,4 +370,37 @@ ANASTASIS_TESTING_cmd_truth_upload (
 }
 
 
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_upload_question (
+  const char *label,
+  const char *anastasis_url,
+  const json_t *id_data,
+  const char *instructions,
+  const char *mime_type,
+  const void *answer,
+  const char *paid_order_ref,
+  unsigned int http_status,
+  enum ANASTASIS_TESTING_TruthStoreOption tso,
+  const char *salt_ref)
+{
+  struct GNUNET_HashCode answer_h;
+
+  GNUNET_CRYPTO_hash (answer,
+                      strlen (answer),
+                      &answer_h);
+  return ANASTASIS_TESTING_cmd_truth_upload (label,
+                                             anastasis_url,
+                                             id_data,
+                                             "question",
+                                             instructions,
+                                             mime_type,
+                                             &answer_h,
+                                             sizeof (answer_h),
+                                             paid_order_ref,
+                                             http_status,
+                                             tso,
+                                             salt_ref);
+}
+
+
 /* end of testing_cmd_truth_upload.c */

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