gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: work on testing for #6753


From: gnunet
Subject: [taler-anastasis] branch master updated: work on testing for #6753
Date: Tue, 06 Apr 2021 22:58:07 +0200

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 f238ac3  work on testing for #6753
f238ac3 is described below

commit f238ac3c50ccaab8304cc4bafb985934118aa03d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Apr 6 22:58:05 2021 +0200

    work on testing for #6753
---
 src/backend/anastasis-httpd_truth.c        |  2 +-
 src/include/anastasis_testing_lib.h        |  2 +-
 src/testing/test_anastasis.c               | 32 ++++++++++++++
 src/testing/testing_cmd_challenge_answer.c | 71 ++++++++++++++++++++++++++++--
 4 files changed, 101 insertions(+), 6 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 3794463..9d1eee5 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -526,7 +526,7 @@ begin_payment (struct GetContext *gc)
 
     order = json_pack ("{s:o, s:s, s:s}",
                        "amount", TALER_JSON_from_amount (&gc->challenge_cost),
-                       "summary", "annual fee for anastasis service",
+                       "summary", "challenge fee for anastasis service",
                        "order_id", order_id);
     gc->po = TALER_MERCHANT_orders_post2 (AH_ctx,
                                           AH_backend_url,
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 7ee540f..844823f 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -730,7 +730,7 @@ enum ANASTASIS_TESTING_SecretShareOption
  * @param prev_secret_share reference to a previous secret share command
  * @param id_data ID data to generate user identifier
  * @param core_secret core secret to backup/recover
- * @param core_secret_size size of core_secret
+ * @param core_secret_size size of @a core_secret
  * @param http_status expected HTTP status.
  * @param sso secret share options
  * @param ... NULL-terminated list of policy create commands
diff --git a/src/testing/test_anastasis.c b/src/testing/test_anastasis.c
index 8b6ed32..73c0d13 100644
--- a/src/testing/test_anastasis.c
+++ b/src/testing/test_anastasis.c
@@ -277,6 +277,7 @@ run (void *cls,
                                             "SomeTruth1",
                                             0,  /* mode */
                                             ANASTASIS_CHALLENGE_STATUS_SOLVED),
+#if 0
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
                                             NULL, /* payment ref */
                                             "recover-secret-1",
@@ -284,6 +285,37 @@ run (void *cls,
                                             "SomeTruth2",
                                             0, /* mode */
                                             ANASTASIS_CHALLENGE_STATUS_SOLVED),
+#endif
+    ANASTASIS_TESTING_cmd_challenge_start ("challenge-start-3-pay",
+                                           NULL,  /* payment ref */
+                                           "recover-secret-1",
+                                           2,  /* challenge index */
+                                           
ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED),
+    TALER_TESTING_cmd_merchant_claim_order ("fetch-challenge-pay-proposal",
+                                            merchant_url,
+                                            MHD_HTTP_OK,
+                                            "challenge-start-3-pay",
+                                            NULL),
+    TALER_TESTING_cmd_merchant_pay_order ("pay-file-challenge",
+                                          merchant_url,
+                                          MHD_HTTP_OK,
+                                          "fetch-challenge-pay-proposal",
+                                          "withdraw-coin-2",
+                                          "EUR:1",
+                                          "EUR:1", /* must match COST in 
config! */
+                                          NULL),
+    ANASTASIS_TESTING_cmd_challenge_start ("challenge-start-3-paid",
+                                           "challenge-start-3-pay",  /* 
payment ref */
+                                           "recover-secret-1",
+                                           2,  /* challenge index */
+                                           
ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS),
+    ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
+                                            "challenge-start-3-pay", /* 
payment ref */
+                                            "recover-secret-1",
+                                            2, /* challenge index */
+                                            "challenge-start-3-paid", /* 
answer */
+                                            1, /* mode */
+                                            ANASTASIS_CHALLENGE_STATUS_SOLVED),
     ANASTASIS_TESTING_cmd_recover_secret_finish ("recover-finish-1",
                                                  "recover-secret-1",
                                                  GNUNET_TIME_UNIT_SECONDS),
diff --git a/src/testing/testing_cmd_challenge_answer.c 
b/src/testing/testing_cmd_challenge_answer.c
index 881cf7b..693e604 100644
--- a/src/testing/testing_cmd_challenge_answer.c
+++ b/src/testing/testing_cmd_challenge_answer.c
@@ -25,6 +25,7 @@
 #include "anastasis_testing_lib.h"
 #include <taler/taler_util.h>
 #include <taler/taler_testing_lib.h>
+#include <taler/taler_merchant_service.h>
 
 
 /**
@@ -62,6 +63,11 @@ struct ChallengeState
    */
   char *payment_uri;
 
+  /**
+   * Order ID extracted from @e payment_uri, or NULL.
+   */
+  char *order_id;
+
   /**
    * Payment order ID we are to provide in the request, may be NULL.
    */
@@ -100,6 +106,10 @@ challenge_answer_cb (void *af_cls,
   if (csr->cs != cs->expected_cs)
   {
     GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Expected status %u, got %u\n",
+                cs->expected_cs,
+                csr->cs);
     TALER_TESTING_interpreter_fail (cs->is);
     return;
   }
@@ -112,8 +122,39 @@ challenge_answer_cb (void *af_cls,
       FILE *file;
       char *fn;
 
-      fn = GNUNET_strndup (csr->details.open_challenge.body,
-                           csr->details.open_challenge.body_size);
+      if (0 == strcasecmp (csr->details.open_challenge.content_type,
+                           "application/json"))
+      {
+        const char *filename;
+        json_t *in;
+
+        in = json_loadb (csr->details.open_challenge.body,
+                         csr->details.open_challenge.body_size,
+                         JSON_REJECT_DUPLICATES,
+                         NULL);
+        if (NULL == in)
+        {
+          GNUNET_break (0);
+          TALER_TESTING_interpreter_fail (cs->is);
+          return;
+        }
+        filename = json_string_value (json_object_get (in,
+                                                       "filename"));
+        if (NULL == filename)
+        {
+          GNUNET_break (0);
+          json_decref (in);
+          TALER_TESTING_interpreter_fail (cs->is);
+          return;
+        }
+        fn = GNUNET_strdup (filename);
+        json_decref (in);
+      }
+      else
+      {
+        fn = GNUNET_strndup (csr->details.open_challenge.body,
+                             csr->details.open_challenge.body_size);
+      }
       file = fopen (fn,
                     "r");
       if (NULL == file)
@@ -144,15 +185,32 @@ challenge_answer_cb (void *af_cls,
     }
   case ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED:
     if (0 != strncmp (csr->details.payment_required.taler_pay_uri,
-                      "taler://pay/http",
-                      strlen ("taler://pay/http")))
+                      "taler+http://pay/";,
+                      strlen ("taler+http://pay/";)))
     {
       GNUNET_break (0);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Invalid payment URI `%s'\n",
+                  csr->details.payment_required.taler_pay_uri);
       TALER_TESTING_interpreter_fail (cs->is);
       return;
     }
     cs->payment_uri = GNUNET_strdup (
       csr->details.payment_required.taler_pay_uri);
+    {
+      struct TALER_MERCHANT_PayUriData pud;
+
+      if (GNUNET_OK !=
+          TALER_MERCHANT_parse_pay_uri (cs->payment_uri,
+                                        &pud))
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (cs->is);
+        return;
+      }
+      cs->order_id = GNUNET_strdup (pud.order_id);
+      TALER_MERCHANT_parse_pay_uri_free (&pud);
+    }
     TALER_TESTING_interpreter_next (cs->is);
     return;
   case ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN:
@@ -380,6 +438,8 @@ challenge_cleanup (void *cls,
     ANASTASIS_challenge_abort (cs->c);
     cs->c = NULL;
   }
+  GNUNET_free (cs->payment_uri);
+  GNUNET_free (cs->order_id);
   GNUNET_free (cs);
 }
 
@@ -407,6 +467,8 @@ challenge_create_traits (void *cls,
                                                  &cs->payment_order_req),
     TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
                                   cs->payment_uri),
+    TALER_TESTING_make_trait_order_id (0,
+                                       cs->order_id),
     TALER_TESTING_trait_end ()
   };
 
@@ -461,6 +523,7 @@ ANASTASIS_TESTING_cmd_challenge_answer (
   cs = GNUNET_new (struct ChallengeState);
   cs->expected_cs = expected_cs;
   cs->challenge_ref = challenge_ref;
+  cs->payment_ref = payment_ref;
   cs->answer = answer;
   cs->challenge_index = challenge_index;
   cs->mode = mode;

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