[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 08/13: Initial work on testing policy creation
From: |
gnunet |
Subject: |
[taler-anastasis] 08/13: Initial work on testing policy creation |
Date: |
Sun, 03 May 2020 18:02:32 +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 bd2fab089423083e2bbd7fa99e122b3b1187d6f1
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sat May 2 08:25:45 2020 +0000
Initial work on testing policy creation
---
src/lib/testing_cmd_policy_create.c | 195 ++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/src/lib/testing_cmd_policy_create.c
b/src/lib/testing_cmd_policy_create.c
new file mode 100644
index 0000000..ad88bf3
--- /dev/null
+++ b/src/lib/testing_cmd_policy_create.c
@@ -0,0 +1,195 @@
+/*
+ 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_policy_create.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 "policy create" CMD.
+ */
+struct PolicyCreateState
+{
+ /**
+ * The interpreter state.
+ */
+ struct TALER_TESTING_Interpreter *is;
+
+ /**
+ * Label of this command.
+ */
+ const char *label;
+
+ /**
+ * References to upload commands of previous truth uploads.
+ */
+ const char **cmd_label_array;
+
+ /**
+ * References to upload commands of previous truth uploads.
+ */
+ const char **cmd_label_array;
+
+ /**
+ * Length of array of command labels (cmd_label_array).
+ */
+ unsigned int cmd_label_array_length;
+
+ /**
+ * Policy object
+ */
+ const struct ANASTASIS_Policy *policy;
+};
+
+
+/**
+ * Run a "policy create" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command currently being run.
+ * @param is interpreter state.
+ */
+static void
+policy_create_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct PolicyCreateState *pcs = cls;
+ const struct TALER_TESTING_Command *ref;
+ struct ANASTASIS_Truth truth;
+
+ pcs->is = is;
+ if (NULL != pcs->ap)
+ {
+ ref = TALER_TESTING_interpreter_lookup_command
+ (is,
+ tus->upload_reference);
+ if (NULL == ref)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (tus->is);
+ return;
+ }
+ if (GNUNET_OK !=
+ ANASTASIS_TESTING_get_trait_truth (ref,
+ 0,
+ &truth))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (pcs->is);
+ return;
+ }
+ }
+
+}
+
+
+/**
+ * Free the state of a "policy create" CMD, and possibly
+ * cancel it if it did not complete.
+ *
+ * @param cls closure.
+ * @param cmd command being freed.
+ */
+static void
+policy_create_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ // FIXME: Cleanup logic
+ struct PolicyCreateState *pcs = cls;
+
+ GNUNET_free (pcs);
+}
+
+
+/**
+ * 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
+policy_create_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct PolicyCreateState *pcs = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ ANASTASIS_TESTING_make_trait_policy (0,
+ pcs->policy),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+/**
+ * Make the "policy create" command.
+ *
+ * @param label command label
+ * @param ... NULL-terminated list of truth upload commands
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_policy_create (const char *label,
+ ...)
+{
+ struct PolicyCreateState *pcs;
+ va_list ap;
+
+ pcs = GNUNET_new (struct PolicyCreateState);
+ pcs->label = label;
+
+ va_start (label, ap);
+ char *truth_upload_cmd;
+ while (NULL != (truth_upload_cmd = va_arg (ap, const char *)))
+ {
+ GNUNET_array_append (pcs->cmd_label_array,
+ pcs->cmd_label_array_length,
+ truth_upload_cmd);
+ }
+ va_end (ap);
+
+ struct TALER_TESTING_Command cmd = {
+ .cls = pcs,
+ .label = label,
+ .run = &policy_create_run,
+ .cleanup = &policy_create_cleanup,
+ .traits = &policy_create_traits
+ };
+
+ return cmd;
+}
+
+
+/* end of testing_cmd_policy_create.c */
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-anastasis] branch master updated (a5b4c84 -> d0a484e), gnunet, 2020/05/03
- [taler-anastasis] 01/13: json_dumps with JSON_COMPACT and JSON_SORT_KEYS, gnunet, 2020/05/03
- [taler-anastasis] 06/13: big O to small o, json_pack, gnunet, 2020/05/03
- [taler-anastasis] 04/13: changed user identifier derivation to use GNUNET_CRYPTO_hash_pow(), gnunet, 2020/05/03
- [taler-anastasis] 02/13: deleted salt cb etc. from anastasis.c, gnunet, 2020/05/03
- [taler-anastasis] 09/13: created policy trait, gnunet, 2020/05/03
- [taler-anastasis] 10/13: modified Makefile, gnunet, 2020/05/03
- [taler-anastasis] 08/13: Initial work on testing policy creation,
gnunet <=
- [taler-anastasis] 03/13: changed user identifier derivation to use GNUNET_CRYPTO_hash_pow(), gnunet, 2020/05/03
- [taler-anastasis] 05/13: modified truth trait, gnunet, 2020/05/03
- [taler-anastasis] 07/13: fixed http server not shutting down, gnunet, 2020/05/03
- [taler-anastasis] 12/13: Some error fixes, gnunet, 2020/05/03
- [taler-anastasis] 11/13: worked on testing policy creation, gnunet, 2020/05/03
- [taler-anastasis] 13/13: fixed truth array problems, gnunet, 2020/05/03