[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/02: Created some files
From: |
gnunet |
Subject: |
[taler-anastasis] 02/02: Created some files |
Date: |
Fri, 01 Nov 2019 19:58:13 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit aa1073c04e669f9f35def6e671e64e5acd4468a8
Author: Dennis Neufeld <address@hidden>
AuthorDate: Fri Nov 1 18:57:06 2019 +0000
Created some files
---
src/backup-db/test_anastasis_db_postgres.conf | 7 +-
src/backup-db/test_anastasisdb.c | 198 ++++++++++++++++++++++++++
src/backup/anastasis-httpd_mhd.c | 4 +-
src/backup/anastasis-httpd_mhd.h | 117 +++++++++++++++
src/backup/anastasis-httpd_parsing.c | 4 +-
src/backup/anastasis-httpd_responses.c | 4 +-
src/backup/anastasis-httpd_responses.h | 0
src/include/anastasis_service.h | 3 +-
8 files changed, 328 insertions(+), 9 deletions(-)
diff --git a/src/backup-db/test_anastasis_db_postgres.conf
b/src/backup-db/test_anastasis_db_postgres.conf
index 504dfdc..f91dea1 100644
--- a/src/backup-db/test_anastasis_db_postgres.conf
+++ b/src/backup-db/test_anastasis_db_postgres.conf
@@ -1,2 +1,7 @@
+[anastasis]
+#The DB plugin to use
+DB = postgres
+
[anastasisdb-postgres]
-CONFIG = "postgres:///anastasis"
+#The connection string the plugin has to use for connecting to the database
+CONFIG = postgres:///anastasischeck
diff --git a/src/backup-db/test_anastasisdb.c b/src/backup-db/test_anastasisdb.c
new file mode 100644
index 0000000..ca81b19
--- /dev/null
+++ b/src/backup-db/test_anastasisdb.c
@@ -0,0 +1,198 @@
+/*
+ This file is part of TALER
+ (C) 2014-2017 INRIA
+
+ TALER 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.
+
+ 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file anastasis/test_anastasis_db.c
+ * @brief testcase for anastasis postgres db plugin
+ * @author Marcello Stanisci
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_db_lib.h>
+#include <taler/taler_util.h>
+#include "anastasis_database_lib.h"
+
+#define FAILIF(cond) \
+ do { \
+ if (! (cond)) { break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
+
+#define RND_BLK(ptr) \
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+
+/**
+ * Global return value for the test. Initially -1, set to 0 upon
+ * completion. Other values indicate some kind of error.
+ */
+static int result;
+
+/**
+ * Handle to the plugin we are testing.
+ */
+static struct ANASTASIS_DatabasePlugin *plugin;
+
+/**
+ * Payment Secret for the test, set to a random value
+ */
+static struct ANASTASIS_PaymentSecretP paymentSecretP;
+
+/**
+ * UUID of the Truth to test, set to a UUID value
+ */
+static struct ANASTASIS_uuid uuid;
+
+/**
+ * User public key, set to a random value
+ */
+static struct ANASTASIS_AccountPubP accountPubP;
+
+/**
+ * Amount which is deposited, set to random value
+ */
+static struct TALER_Amount amount;
+
+/**
+ * How many posts are paid by the payment
+ */
+const unsigned int *post_counter;
+
+/**
+ * Recoverydata which is stored into the Database, set to a random value
+ */
+const void *recovery_data;
+
+/**
+ * Truthdata which is stored into the Database, set to a random value
+ */
+const void *truth_data;
+
+/**
+ * Keyshare which is stored into the Database, set to a random value
+ */
+const void *key_share;
+
+/**
+ * Version of a Recoverydocument
+ */
+const unsigned int *version;
+
+
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure with config
+ */
+static void
+run (void *cls)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ struct GNUNET_TIME_Absolute fake_now;
+
+ if (NULL == (plugin = ANASTASIS_DB_plugin_load (cls)))
+ {
+ result = 77;
+ return;
+ }
+ if (GNUNET_OK != plugin->drop_tables (plugin->cls))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Dropping tables failed\n");
+ result = 77;
+ return;
+ }
+ ANASTASIS_DB_plugin_unload (plugin);
+ if (NULL == (plugin = ANASTASIS_DB_plugin_load (cls)))
+ {
+ result = 77;
+ return;
+ }
+
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->store_recovery_document (plugin->cls,
+ accountPubP,
+ recovery_data,
+ recovery_data_size,
+ paymentSecretP,
+ version));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->record_payment (plugin->cls,
+ amount,
+ accountPubP,
+ &post_counter,
+ fake_now,
+ paymentSecretP));
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ plugin->store_truth (plugin->cls,
+ uuid,
+ truth_data,
+ truth_data_size,
+ fake_now,
+ version));
+
+ if (-1 == result)
+ result = 0;
+
+drop:
+ GNUNET_break (GNUNET_OK ==
+ plugin->drop_tables (plugin->cls));
+ ANASTASIS_DB_plugin_unload (plugin);
+ plugin = NULL;
+}
+
+int
+main (int argc,
+ char *const argv[])
+{
+ const char *plugin_name;
+ char *config_filename;
+ char *testname;
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ result = -1;
+ if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
+ {
+ GNUNET_break (0);
+ return -1;
+ }
+ GNUNET_log_setup (argv[0], "DEBUG", NULL);
+ plugin_name++;
+ (void) GNUNET_asprintf (&testname,
+ "test_anastasis_db_%s",
+ plugin_name);
+ (void) GNUNET_asprintf (&config_filename,
+ "%s.conf",
+ testname);
+ cfg = GNUNET_CONFIGURATION_create ();
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_parse (cfg,
+ config_filename))
+ {
+ GNUNET_break (0);
+ GNUNET_free (config_filename);
+ GNUNET_free (testname);
+ return 2;
+ }
+ GNUNET_SCHEDULER_run (&run, cfg);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (config_filename);
+ GNUNET_free (testname);
+ return result;
+}
+
+/* end of test_anastasis_db.c */
diff --git a/src/backup/anastasis-httpd_mhd.c b/src/backup/anastasis-httpd_mhd.c
index af0023b..50e29b7 100644
--- a/src/backup/anastasis-httpd_mhd.c
+++ b/src/backup/anastasis-httpd_mhd.c
@@ -24,8 +24,8 @@
*/
#include "platform.h"
#include <jansson.h>
-#include "taler-merchant-httpd_mhd.h"
-#include "taler-merchant-httpd_responses.h"
+#include "anastasis-httpd_mhd.h"
+#include "anastasis-httpd_responses.h"
/**
diff --git a/src/backup/anastasis-httpd_mhd.h b/src/backup/anastasis-httpd_mhd.h
new file mode 100644
index 0000000..58e8070
--- /dev/null
+++ b/src/backup/anastasis-httpd_mhd.h
@@ -0,0 +1,117 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014, 2015 GNUnet e.V. and INRIA
+
+ 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 anastasis-httpd_mhd.h
+ * @brief helpers for MHD interaction, used to generate simple responses
+ * @author Florian Dold
+ * @author Benedikt Mueller
+ * @author Christian Grothoff
+ */
+#ifndef ANASTASIS_HTTPD_MHD_H
+#define ANASTASIS_HTTPD_MHD_H
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include "anastasis-httpd.h"
+
+
+/**
+ * Function to call to handle the request by sending
+ * back static data from the @a rh.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param mi merchant backend instance, NULL is allowed in this case!
+ * @return MHD result code
+ */
+int
+TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ struct MerchantInstance *mi);
+
+
+/**
+ * Function to call to handle the request by sending
+ * back a redirect to the AGPL source code.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param mi merchant backend instance, never NULL
+ * @return MHD result code
+ */
+int
+TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ struct MerchantInstance *mi);
+
+
+/**
+ * Function to call to handle the request by building a JSON
+ * reply from varargs.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param response_code HTTP response code to use
+ * @param do_cache can the response be cached? (0: no, 1: yes)
+ * @param fmt format string for pack
+ * @param ... varargs
+ * @return MHD result code
+ */
+int
+TMH_MHD_helper_send_json_pack (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void *connection_cls,
+ int response_code,
+ int do_cache,
+ const char *fmt,
+ ...);
+
+
+/**
+ * Function to call to handle the request by building a JSON
+ * reply with an error message from @a rh.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param mi merchant backend instance, never NULL
+ * @return MHD result code
+ */
+int
+TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ struct MerchantInstance *mi);
+
+
+#endif
diff --git a/src/backup/anastasis-httpd_parsing.c
b/src/backup/anastasis-httpd_parsing.c
index 242278f..b2295d3 100644
--- a/src/backup/anastasis-httpd_parsing.c
+++ b/src/backup/anastasis-httpd_parsing.c
@@ -28,8 +28,8 @@
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <taler/taler_json_lib.h>
-#include "taler-merchant-httpd_parsing.h"
-#include "taler-merchant-httpd_responses.h"
+#include "anastasis-httpd_parsing.h"
+#include "anastasis-httpd_responses.h"
/* FIXME: de-duplicate code with taler-exchange-httpd_parsing.c
and taler-exchange-httpd_response.c */
diff --git a/src/backup/anastasis-httpd_responses.c
b/src/backup/anastasis-httpd_responses.c
index bdd5884..f15fc89 100644
--- a/src/backup/anastasis-httpd_responses.c
+++ b/src/backup/anastasis-httpd_responses.c
@@ -23,8 +23,8 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include "taler-merchant-httpd.h"
-#include "taler-merchant-httpd_responses.h"
+#include "anastasis-httpd.h"
+#include "anastasis-httpd_responses.h"
#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
diff --git a/src/backup/anastasis-httpd_responses.h
b/src/backup/anastasis-httpd_responses.h
new file mode 100644
index 0000000..e69de29
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 2a9e25a..0eb59b4 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -25,8 +25,7 @@
#include <gnunet/gnunet_curl_lib.h>
#include <jansson.h>
-*
-/ struct Anastasis_MERCHANT_Pay *
+struct Anastasis_MERCHANT_Pay *
Anastasis_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
const char *merchant_url,
const char *instance,
--
To stop receiving notification emails like this one, please contact
address@hidden.