gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: initial work on testing anastas


From: gnunet
Subject: [taler-anastasis] branch master updated: initial work on testing anastasis.c
Date: Thu, 23 Apr 2020 16:08:13 +0200

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 762c0d6  initial work on testing anastasis.c
762c0d6 is described below

commit 762c0d6f435f20c48b3960fef711581adbae3fd5
Author: Dennis Neufeld <address@hidden>
AuthorDate: Thu Apr 23 14:08:04 2020 +0000

    initial work on testing anastasis.c
---
 src/include/anastasis_testing_lib.h  |  84 ++++++++++
 src/lib/Makefile.am                  |  33 +++-
 src/lib/test_anastasis               | 228 ++++++++++++++++++++++++++
 src/lib/test_anastasis.c             | 302 +++++++++++++++++++++++++++++++++++
 src/lib/testing_cmd_recover_secret.c | 176 ++++++++++++++++++++
 src/lib/testing_cmd_secret_share.c   | 176 ++++++++++++++++++++
 6 files changed, 997 insertions(+), 2 deletions(-)

diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index f4f8bd7..f708771 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -429,4 +429,88 @@ ANASTASIS_TESTING_cmd_salt (const char *label,
                             const char *anastasis_url,
                             unsigned int http_status);
 
+
+/* ********************* test secret share ********************* */
+
+/**
+ * Types of options for performing the secret sharing. Used as a bitmask.
+ */
+enum ANASTASIS_TESTING_SecretShareOption
+{
+  /**
+   * Do everything by the book.
+   */
+  ANASTASIS_TESTING_SSO_NONE = 0,
+
+  /**
+   * Request payment.
+   */
+  ANASTASIS_TESTING_SSO_REQUEST_PAYMENT = 2,
+
+  /**
+   * Reference payment order ID from linked previous upload.
+   */
+  ANASTASIS_TESTING_SSO_REFERENCE_ORDER_ID = 4
+
+};
+
+/**
+ * Make the "secret share" command.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param http_status expected HTTP status.
+ * @param sso secret share options
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_secret_share (const char *label,
+                                    const char *anastasis_url,
+                                    unsigned int http_status,
+                                    enum
+                                    ANASTASIS_TESTING_SecretShareOption sso,
+                                    const char *upload_ref);
+
+/* ********************* test recover secret ********************* */
+
+/**
+ * Types of options for performing the secret recovery. Used as a bitmask.
+ */
+enum ANASTASIS_TESTING_RecoverSecretOption
+{
+  /**
+   * Do everything by the book.
+   */
+  ANASTASIS_TESTING_RSO_NONE = 0,
+
+  /**
+   * Request payment.
+   */
+  ANASTASIS_TESTING_RSO_REQUEST_PAYMENT = 2,
+
+  /**
+   * Reference payment order ID from linked previous download.
+   */
+  ANASTASIS_TESTING_RSO_REFERENCE_ORDER_ID = 4
+
+};
+
+/**
+ * Make the "recover secret" command.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param http_status expected HTTP status.
+ * @param rso recover secret options
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_recover_secret (const char *label,
+                                      const char *anastasis_url,
+                                      unsigned int http_status,
+                                      enum
+                                      ANASTASIS_TESTING_RecoverSecretOption 
rso,
+                                      const char *download_ref);
+
+
 #endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d6706c5..46deac6 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -66,7 +66,9 @@ libanastasistesting_la_SOURCES = \
   testing_api_trait_account_priv.c \
   testing_api_trait_payment_identifier.c \
   testing_api_trait_uuid.c \
-  testing_api_trait_hash.c
+  testing_api_trait_hash.c \
+  testing_cmd_secret_share.c \
+  testing_cmd_recover_secret.c
 libanastasistesting_la_LIBADD = \
   $(top_builddir)/src/lib/libanastasisrest.la \
   -ltalerexchange \
@@ -82,7 +84,8 @@ libanastasistesting_la_LIBADD = \
 
 
 check_PROGRAMS = \
-  test_anastasisrest_api
+  test_anastasisrest_api \
+  test_anastasis
 
 TESTS = \
   $(check_PROGRAMS)
@@ -107,10 +110,36 @@ test_anastasisrest_api_LDADD = \
   -lgnunetutil \
   -ljansson
 
+test_anastasis_SOURCES = \
+  test_anastasis.c
+test_anastasis_LDADD = \
+  $(top_builddir)/src/stasis/libanastasisdb.la \
+  libanastasis.la \
+  $(LIBGCRYPT_LIBS) \
+  -ltalertesting \
+  libanastasistesting.la \
+  -ltalermerchanttesting \
+  -ltalerfakebank \
+  -ltalerbank \
+  -ltalerexchange \
+  -ltalermerchant \
+  -ltalerjson \
+  -ltalerutil \
+  -lgnunetjson \
+  -lgnunetcurl \
+  -lgnunetutil \
+  -ljansson
+
 EXTRA_DIST = \
   test_anastasis_api.conf \
+  test_anastasis.conf \
   test_anastasis_api_home/.config/taler/exchange/account-2.json \
   test_anastasis_api_home/.local/share/taler/exchange/offline-keys/master.priv 
\
   #test_anastasis_api_home/.config/taler/merchant/wire/test.json \
   #test_anastasis_api_home/.config/taler/test.json \
+  test_anastasis.conf \
+  test_anastasis_home/.config/taler/exchange/account-2.json \
+  test_anastasis_home/.local/share/taler/exchange/offline-keys/master.priv \
+  #test_anastasis_home/.config/taler/merchant/wire/test.json \
+  #test_anastasis_home/.config/taler/test.json \
   #test_merchant.priv
diff --git a/src/lib/test_anastasis b/src/lib/test_anastasis
new file mode 100755
index 0000000..3348625
--- /dev/null
+++ b/src/lib/test_anastasis
@@ -0,0 +1,228 @@
+#! /bin/sh
+
+# test_anastasis - temporary wrapper script for .libs/test_anastasis
+# Generated by libtool (GNU libtool) 2.4.6.42-b88ce-dirty
+#
+# The test_anastasis program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command="(cd 
/home/dennis/Nextcloud/Studium-BFH/Aktuell_FS2020/Bachelor-Thesis/ANASTASIS/anastasis/src/lib;
 { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; 
export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset 
COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z 
\"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; 
export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN 
[...]
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='2.4.6.42-b88ce-dirty'
+  notinst_deplibs=' ../../src/stasis/libanastasisdb.la libanastasis.la 
libanastasistesting.la 
/home/dennis/Nextcloud/Studium-BFH/Aktuell_FS2020/Bachelor-Thesis/ANASTASIS/anastasis/src/lib/libanastasisrest.la'
+else
+  # When we are sourced in execute mode, $file and $ECHO are already set.
+  if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+    file="$0"
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+    ECHO="printf %s\\n"
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ that is used only on
+# windows platforms, and (c) all begin with the string --lt-
+# (application programs are unlikely to have options that match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's ../../libtool value, followed by no.
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=$0
+  shift
+  for lt_opt
+  do
+    case "$lt_opt" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 
's%/[^/]*$%%'`
+        test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
+        lt_dump_F=`$ECHO "X$lt_script_arg0" | /usr/bin/sed -e 's/^X//' -e 
's%^.*/%%'`
+        cat "$lt_dump_D/$lt_dump_F"
+        exit 0
+      ;;
+    --lt-*)
+        $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+
+  # Print the debug banner immediately:
+  if test -n "$lt_option_debug"; then
+    echo "test_anastasis:test_anastasis:$LINENO: libtool wrapper (GNU libtool) 
2.4.6.42-b88ce-dirty" 1>&2
+  fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    $ECHO "test_anastasis:test_anastasis:$LINENO: newargv[$lt_dump_args_N]: 
$lt_arg"
+    lt_dump_args_N=`expr $lt_dump_args_N + 1`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+
+      if test -n "$lt_option_debug"; then
+        $ECHO "test_anastasis:test_anastasis:$LINENO: newargv[0]: 
$progdir/$program" 1>&2
+        func_lt_dump_args ${1+"$@"} 1>&2
+      fi
+      exec "$progdir/$program" ${1+"$@"}
+
+      $ECHO "$0: cannot exec $program $*" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from $@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  case " $* " in
+  *\ --lt-*)
+    for lt_wr_arg
+    do
+      case $lt_wr_arg in
+      --lt-*) ;;
+      *) set x "$@" "$lt_wr_arg"; shift;;
+      esac
+      shift
+    done ;;
+  esac
+  func_exec_program_core ${1+"$@"}
+}
+
+  # Parse options
+  func_parse_lt_options "$0" ${1+"$@"}
+
+  # Find the directory that this script lives in.
+  thisdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
+  test "x$thisdir" = "x$file" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
+  while test -n "$file"; do
+    destdir=`$ECHO "$file" | /usr/bin/sed 's%/[^/]*$%%'`
+
+    # If there was a directory component, then change thisdir.
+    if test "x$destdir" != "x$file"; then
+      case "$destdir" in
+      [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+      *) thisdir="$thisdir/$destdir" ;;
+      esac
+    fi
+
+    file=`$ECHO "$file" | /usr/bin/sed 's%^.*/%%'`
+    file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
+  done
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+  if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+    # special case for '.'
+    if test "$thisdir" = "."; then
+      thisdir=`pwd`
+    fi
+    # remove .libs from thisdir
+    case "$thisdir" in
+    *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /usr/bin/sed 
's%[\\/][^\\/]*$%%'` ;;
+    .libs )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=`cd "$thisdir" && pwd`
+  test -n "$absdir" && thisdir="$absdir"
+
+  program=lt-'test_anastasis'
+  progdir="$thisdir/.libs"
+
+  if test ! -f "$progdir/$program" ||
+     { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | 
/usr/bin/sed 1q`; \
+       test "X$file" != "X$progdir/$program"; }; then
+
+    file="$$-$program"
+
+    if test ! -d "$progdir"; then
+      mkdir "$progdir"
+    else
+      rm -f "$progdir/$file"
+    fi
+
+    # relink executable if necessary
+    if test -n "$relink_command"; then
+      if relink_command_output=`eval $relink_command 2>&1`; then :
+      else
+       $ECHO "$relink_command_output" >&2
+       rm -f "$progdir/$file"
+       exit 1
+      fi
+    fi
+
+    mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
+    { rm -f "$progdir/$program";
+      mv -f "$progdir/$file" "$progdir/$program"; }
+    rm -f "$progdir/$file"
+  fi
+
+  if test -f "$progdir/$program"; then
+    if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+      # Run the actual program with our arguments.
+      func_exec_program ${1+"$@"}
+    fi
+  else
+    # The program doesn't exist.
+    $ECHO "$0: error: '$progdir/$program' does not exist" 1>&2
+    $ECHO "This script is just a wrapper for $program." 1>&2
+    $ECHO "See the libtool documentation for more information." 1>&2
+    exit 1
+  fi
+fi
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
new file mode 100644
index 0000000..c89c879
--- /dev/null
+++ b/src/lib/test_anastasis.c
@@ -0,0 +1,302 @@
+/*
+  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/test_anastasis.c
+ * @brief testcase to test anastasis
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ */
+#include "platform.h"
+#include <taler/taler_util.h>
+#include <taler/taler_signatures.h>
+#include <taler/taler_exchange_service.h>
+#include <taler/taler_json_lib.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include <taler/taler_bank_service.h>
+#include <taler/taler_fakebank_lib.h>
+#include <taler/taler_testing_lib.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_merchant_testing_lib.h>
+#include "anastasis_testing_lib.h"
+#include "anastasis_service.h"
+
+/**
+ * Configuration file we use.  One (big) configuration is used
+ * for the various components for this test.
+ */
+#define CONFIG_FILE "test_anastasis_api.conf"
+
+/**
+ * Exchange base URL.  Could also be taken from config.
+ */
+#define EXCHANGE_URL "http://localhost:8081/";
+
+/**
+ * Account number of the exchange at the bank.
+ */
+#define EXCHANGE_ACCOUNT_NAME "2"
+
+/**
+ * Account number of some user.
+ */
+#define USER_ACCOUNT_NAME "62"
+
+/**
+ * Account number used by the merchant
+ */
+#define MERCHANT_ACCOUNT_NAME "3"
+
+/**
+ * Configuration of the bank.
+ */
+static struct TALER_TESTING_BankConfiguration bc;
+
+/**
+ * Configuration of the exchange.
+ */
+static struct TALER_TESTING_ExchangeConfiguration ec;
+
+/**
+ * Payto URI of the customer (payer).
+ */
+static char *payer_payto;
+
+/**
+ * Payto URI of the exchange (escrow account).
+ */
+static char *exchange_payto;
+
+/**
+ * Payto URI of the merchant (receiver).
+ */
+static char *merchant_payto;
+
+/**
+ * Merchant base URL.
+ */
+static char *merchant_url;
+
+/**
+ * Anastasis base URL.
+ */
+static char *anastasis_url;
+
+/**
+ * Merchant process.
+ */
+static struct GNUNET_OS_Process *merchantd;
+
+/**
+ * Anastasis process.
+ */
+static struct GNUNET_OS_Process *anastasisd;
+
+
+/**
+ * Execute the taler-exchange-wirewatch command with
+ * our configuration file.
+ *
+ * @param label label to use for the command.
+ */
+static struct TALER_TESTING_Command
+cmd_exec_wirewatch (char *label)
+{
+  return TALER_TESTING_cmd_exec_wirewatch (label,
+                                           CONFIG_FILE);
+}
+
+
+/**
+ * Run wire transfer of funds from some user's account to the
+ * exchange.
+ *
+ * @param label label to use for the command.
+ * @param amount amount to transfer, i.e. "EUR:1"
+ * @param url exchange_url
+ */
+static struct TALER_TESTING_Command
+cmd_transfer_to_exchange (const char *label,
+                          const char *amount)
+{
+  return TALER_TESTING_cmd_admin_add_incoming (label,
+                                               amount,
+                                               &bc.exchange_auth,
+                                               payer_payto);
+}
+
+
+/**
+ * Main function that will tell the interpreter what commands to
+ * run.
+ *
+ * @param cls closure
+ */
+static void
+run (void *cls,
+     struct TALER_TESTING_Interpreter *is)
+{
+  struct TALER_TESTING_Command pay[] = {
+    /**
+     * Move money to the exchange's bank account.
+     */
+    cmd_transfer_to_exchange ("create-reserve-1",
+                              "EUR:10.02"),
+    /**
+     * Make a reserve exist, according to the previous
+     * transfer.
+     */
+    cmd_exec_wirewatch ("wirewatch-1"),
+    TALER_TESTING_cmd_withdraw_amount
+      ("withdraw-coin-1",
+      "create-reserve-1",
+      "EUR:5",
+      MHD_HTTP_OK),
+    TALER_TESTING_cmd_withdraw_amount
+      ("withdraw-coin-2",
+      "create-reserve-1",
+      "EUR:5",
+      MHD_HTTP_OK),
+
+    /**
+     * Check the reserve is depleted.
+     */
+    TALER_TESTING_cmd_status ("withdraw-status-1",
+                              "create-reserve-1",
+                              "EUR:0",
+                              MHD_HTTP_OK),
+
+    TALER_TESTING_cmd_end ()
+  };
+
+  struct TALER_TESTING_Command anastasis[] = {
+    // FIXME: testing logic here
+    ANASTASIS_TESTING_cmd_secret_share ("secret-share-1",
+                                        anastasis_url,
+                                        MHD_HTTP_PAYMENT_REQUIRED,
+                                        ANASTASIS_TESTING_SSO_NONE,
+                                        NULL),
+
+    ANASTASIS_TESTING_cmd_recover_secret ("recover-secret-1",
+                                          anastasis_url,
+                                          MHD_HTTP_PAYMENT_REQUIRED,
+                                          ANASTASIS_TESTING_RSO_NONE,
+                                          NULL),
+
+    TALER_TESTING_cmd_end ()
+  };
+
+  struct TALER_TESTING_Command commands[] = {
+
+    TALER_TESTING_cmd_batch ("pay",
+                             pay),
+
+    TALER_TESTING_cmd_batch ("anastasis",
+                             anastasis),
+
+
+    /**
+     * End the suite.  Fixme: better to have a label for this
+     * too, as it shows a "(null)" token on logs.
+     */
+    TALER_TESTING_cmd_end ()
+  };
+
+  TALER_TESTING_run_with_fakebank (is,
+                                   commands,
+                                   bc.exchange_auth.wire_gateway_url);
+}
+
+
+int
+main (int argc,
+      char *const *argv)
+{
+  unsigned int ret;
+  /* These environment variables get in the way... */
+  unsetenv ("XDG_DATA_HOME");
+  unsetenv ("XDG_CONFIG_HOME");
+
+  GNUNET_log_setup ("test-anastasis",
+                    "DEBUG",
+                    NULL);
+  if (GNUNET_OK !=
+      TALER_TESTING_prepare_fakebank (CONFIG_FILE,
+                                      "exchange-account-exchange",
+                                      &bc))
+    return 77;
+  payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME);
+  exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME);
+  merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME);
+  if (NULL ==
+      (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
+    return 77;
+  TALER_TESTING_cleanup_files (CONFIG_FILE);
+
+  if (NULL ==
+      (anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE)))
+    return 77;
+  TALER_TESTING_cleanup_files (CONFIG_FILE);
+
+  switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+                                          GNUNET_YES,
+                                          &ec))
+  {
+  case GNUNET_SYSERR:
+    GNUNET_break (0);
+    return 1;
+  case GNUNET_NO:
+    return 77;
+
+  case GNUNET_OK:
+    if (NULL == (merchantd =
+                   TALER_TESTING_run_merchant (CONFIG_FILE,
+                                               merchant_url)))
+      return 1;
+
+    if (NULL == (anastasisd =
+                   ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
+                                                    anastasis_url)))
+      return 1;
+
+    ret = TALER_TESTING_setup_with_exchange (&run,
+                                             NULL,
+                                             CONFIG_FILE);
+
+    GNUNET_OS_process_kill (merchantd,
+                            SIGTERM);
+    GNUNET_OS_process_kill (anastasisd,
+                            SIGTERM);
+    GNUNET_OS_process_wait (merchantd);
+    GNUNET_OS_process_wait (anastasisd);
+    GNUNET_OS_process_destroy (merchantd);
+    GNUNET_OS_process_destroy (anastasisd);
+    GNUNET_free (merchant_url);
+    GNUNET_free (anastasis_url);
+
+    if (GNUNET_OK != ret)
+      return 1;
+    break;
+  default:
+    GNUNET_break (0);
+    return 1;
+  }
+  return 0;
+}
+
+
+/* end of test_anastasis.c */
\ No newline at end of file
diff --git a/src/lib/testing_cmd_recover_secret.c 
b/src/lib/testing_cmd_recover_secret.c
new file mode 100644
index 0000000..16b94ca
--- /dev/null
+++ b/src/lib/testing_cmd_recover_secret.c
@@ -0,0 +1,176 @@
+/*
+  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_cmd_recover_secret.c
+ * @brief command to execute the anastasis recovery service
+ * @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 "recover secret" CMD.
+ */
+struct RecoverSecretState
+{
+  /**
+   * 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_Recovery *rso;
+
+  /**
+   * Reference to download command we expect to lookup.
+   */
+  const char *download_reference;
+
+  /**
+   * Options for how we are supposed to do the download.
+   */
+  enum ANASTASIS_TESTING_RecoverSecretOption rsopt;
+};
+
+
+/**
+ * Run a "recover secret" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command currently being run.
+ * @param is interpreter state.
+ */
+static void
+recover_secret_run (void *cls,
+                    const struct TALER_TESTING_Command *cmd,
+                    struct TALER_TESTING_Interpreter *is)
+{
+  struct RecoverSecretState *rss = cls;
+
+  rss->is = is;
+  // FIXME: Whole secret share procedure here
+
+  if (NULL == rss->rso)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (rss->is);
+    return;
+  }
+}
+
+
+/**
+ * Free the state of a "recover secret" CMD, and possibly
+ * cancel it if it did not complete.
+ *
+ * @param cls closure.
+ * @param cmd command being freed.
+ */
+static void
+recover_secret_cleanup (void *cls,
+                        const struct TALER_TESTING_Command *cmd)
+{
+  // FIXME: Cleanup logic
+  struct RecoverSecretState *rss = cls;
+
+  GNUNET_free (rss);
+}
+
+
+/**
+ * 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
+recover_secret_traits (void *cls,
+                       const void **ret,
+                       const char *trait,
+                       unsigned int index)
+{
+  struct RecoverSecretState *rss = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    // FIXME: What traits are usefull?
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
+/**
+ * Make the "recover secret" command.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param http_status expected HTTP status.
+ * @param rso recover secret options
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_recover_secret (const char *label,
+                                      const char *anastasis_url,
+                                      unsigned int http_status,
+                                      enum
+                                      ANASTASIS_TESTING_RecoverSecretOption 
rso,
+                                      const char *download_ref)
+{
+  struct RecoverSecretState *rss;
+
+  rss = GNUNET_new (struct RecoverSecretState);
+  rss->http_status = http_status;
+  rss->rsopt = rso;
+  rss->anastasis_url = anastasis_url;
+  rss->download_reference = download_ref;
+
+  struct TALER_TESTING_Command cmd = {
+    .cls = rss,
+    .label = label,
+    .run = &recover_secret_run,
+    .cleanup = &recover_secret_cleanup,
+    .traits = &recover_secret_traits
+  };
+
+  return cmd;
+}
+
+
+/* end of testing_cmd_recover_secret.c */
\ No newline at end of file
diff --git a/src/lib/testing_cmd_secret_share.c 
b/src/lib/testing_cmd_secret_share.c
new file mode 100644
index 0000000..5e95f24
--- /dev/null
+++ b/src/lib/testing_cmd_secret_share.c
@@ -0,0 +1,176 @@
+/*
+  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_cmd_secret_share.c
+ * @brief command to execute the anastasis secret share service
+ * @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 "secret share" CMD.
+ */
+struct SecretShareState
+{
+  /**
+   * 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_SecretShare *sso;
+
+  /**
+   * Reference to upload command we expect to lookup.
+   */
+  const char *upload_reference;
+
+  /**
+   * Options for how we are supposed to do the upload.
+   */
+  enum ANASTASIS_TESTING_SecretShareOption ssopt;
+};
+
+
+/**
+ * Run a "secret share" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command currently being run.
+ * @param is interpreter state.
+ */
+static void
+secret_share_run (void *cls,
+                  const struct TALER_TESTING_Command *cmd,
+                  struct TALER_TESTING_Interpreter *is)
+{
+  struct SecretShareState *sss = cls;
+
+  sss->is = is;
+  // FIXME: Whole secret share procedure here
+
+  if (NULL == sss->sso)
+  {
+    GNUNET_break (0);
+    TALER_TESTING_interpreter_fail (sss->is);
+    return;
+  }
+}
+
+
+/**
+ * Free the state of a "secret share" CMD, and possibly
+ * cancel it if it did not complete.
+ *
+ * @param cls closure.
+ * @param cmd command being freed.
+ */
+static void
+secret_share_cleanup (void *cls,
+                      const struct TALER_TESTING_Command *cmd)
+{
+  // FIXME: Cleanup logic
+  struct SecretShareState *sss = cls;
+
+  GNUNET_free (sss);
+}
+
+
+/**
+ * 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
+secret_share_traits (void *cls,
+                     const void **ret,
+                     const char *trait,
+                     unsigned int index)
+{
+  struct SecretShareState *sss = cls;
+  struct TALER_TESTING_Trait traits[] = {
+    // FIXME: What traits are usefull?
+    TALER_TESTING_trait_end ()
+  };
+
+  return TALER_TESTING_get_trait (traits,
+                                  ret,
+                                  trait,
+                                  index);
+}
+
+
+/**
+ * Make the "secret share" command.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving our requests.
+ * @param http_status expected HTTP status.
+ * @param sso secret share options
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_secret_share (const char *label,
+                                    const char *anastasis_url,
+                                    unsigned int http_status,
+                                    enum
+                                    ANASTASIS_TESTING_SecretShareOption sso,
+                                    const char *upload_ref)
+{
+  struct SecretShareState *sss;
+
+  sss = GNUNET_new (struct SecretShareState);
+  sss->http_status = http_status;
+  sss->ssopt = sso;
+  sss->anastasis_url = anastasis_url;
+  sss->upload_reference = upload_ref;
+
+  struct TALER_TESTING_Command cmd = {
+    .cls = sss,
+    .label = label,
+    .run = &secret_share_run,
+    .cleanup = &secret_share_cleanup,
+    .traits = &secret_share_traits
+  };
+
+  return cmd;
+}
+
+
+/* end of testing_cmd_secret_share.c */
\ 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]