gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: worked on salt api testing


From: gnunet
Subject: [taler-anastasis] 01/02: worked on salt api testing
Date: Wed, 15 Apr 2020 17:00:36 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit f3d5abe89c13487dbea4c6f60970656f8348a4b7
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Apr 15 13:30:18 2020 +0000

    worked on salt api testing
---
 src/lib/anastasis_api_curl_defaults.h |   2 +-
 src/lib/testing_api_cmd_salt.c        | 167 ++++++++++++++++++++++++++++++++++
 2 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/src/lib/anastasis_api_curl_defaults.h 
b/src/lib/anastasis_api_curl_defaults.h
index 4bfac15..275886d 100644
--- a/src/lib/anastasis_api_curl_defaults.h
+++ b/src/lib/anastasis_api_curl_defaults.h
@@ -15,7 +15,7 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file lib/sync_api_curl_defaults.h
+ * @file lib/anastasis_api_curl_defaults.h
  * @brief curl easy handle defaults
  * @author Florian Dold
  */
diff --git a/src/lib/testing_api_cmd_salt.c b/src/lib/testing_api_cmd_salt.c
new file mode 100644
index 0000000..d67b32e
--- /dev/null
+++ b/src/lib/testing_api_cmd_salt.c
@@ -0,0 +1,167 @@
+/*
+  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 Affero 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 Affero General Public License for more 
details.
+
+  You should have received a copy of the GNU Affero General Public License 
along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file lib/testing_api_cmd_salt.c
+ * @brief command to execute the anastasis backend service.
+ * @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 "salt" CMD.
+ */
+struct SaltState
+{
+  /**
+   * 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 /salt GET operation handle.
+   */
+  struct ANASTASIS_SaltOperation *so;
+};
+
+
+/**
+ * Function called with the results of a #ANASTASIS_salt().
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param salt salt from the server
+ */
+static void
+salt_cb (void *cls,
+         unsigned int http_status,
+         const struct ANASTASIS_CRYPTO_Salt *salt)
+{
+  struct SaltState *ss = cls;
+
+  ss->plo = NULL;
+  if (http_status != ss->http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u to command %s in %s:%u\n",
+                http_status,
+                ss->is->commands[ss->is->ip].label,
+                __FILE__,
+                __LINE__);
+    TALER_TESTING_interpreter_fail (ss->is);
+    return;
+  }
+}
+
+
+/**
+ * Run a "salt" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command currently being run.
+ * @param is interpreter state.
+ */
+static void
+salt_run (void *cls,
+          const struct TALER_TESTING_Command *cmd,
+          struct TALER_TESTING_Interpreter *is)
+{
+  struct SaltState *ss = cls;
+
+  ss->is = is;
+  ss->so = ANASTASIS_salt (is->ctx,
+                           ss->anastasis_url,
+                           &salt_cb,
+                           ss);
+  if (NULL == ss->so)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (ss->is);
+    return;
+  }
+}
+
+
+/**
+ * Free the state of a "salt" CMD, and possibly
+ * cancel it if it did not complete.
+ *
+ * @param cls closure.
+ * @param cmd command being freed.
+ */
+static void
+salt_cleanup (void *cls,
+              const struct TALER_TESTING_Command *cmd)
+{
+  struct SaltState *ss = cls;
+
+  if (NULL != ss->so)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Command '%s' did not complete (salt)\n",
+                cmd->label);
+    ANASTASIS_salt_cancel (ss->so);
+    ss->so = NULL;
+  }
+  GNUNET_free (ss);
+}
+
+
+/**
+ * Make the "salt" command.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the ANASTASIS serving
+ *        the salt request.
+ * @param http_status expected HTTP status.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_salt (const char *label,
+                            const char *anastasis_url,
+                            unsigned int http_status)
+{
+  struct SaltState *ss;
+
+  ss = GNUNET_new (struct SaltState);
+  ss->http_status = http_status;
+  ss->anastasis_url = anastasis_url;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .cls = ss,
+      .label = label,
+      .run = &salt_run,
+      .cleanup = &salt_cleanup
+    };
+
+    return cmd;
+  }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]