[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 02/04: worked on truth upload api
From: |
gnunet |
Subject: |
[taler-anastasis] 02/04: worked on truth upload api |
Date: |
Wed, 22 Jan 2020 12:46:10 +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 58bb9c18a892d9e6e610e9c1584f8032aea65f29
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Jan 22 08:35:54 2020 +0000
worked on truth upload api
---
src/include/anastasis_service.h | 5 +--
src/lib/Makefile.am | 1 +
src/lib/anastasis_api_keyshare_lookup.c | 4 +-
src/lib/anastasis_api_truth_store.c | 67 +++++++++++++++++++--------------
src/lib/test_anastasis_api.c | 8 ++--
src/lib/test_anastasisrest_api | 2 +-
src/lib/testing_api_cmd_truth_store.c | 15 +++++---
7 files changed, 58 insertions(+), 44 deletions(-)
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index ff8b677..83c2ee5 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -450,7 +450,7 @@ typedef void
struct ANASTASIS_KeyShareLookupOperation *
ANASTASIS_key_share_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct ANASTASIS_UuidP *truth_uuid,
+ uuid_t *truth_uuid,
const struct ANASTASIS_TruthKey *truth_key,
const struct GNUNET_HashCode *hashed_answer,
ANASTASIS_KeyShareLookupCallback cb,
@@ -501,8 +501,7 @@ typedef void
struct ANASTASIS_TruthStoreOperation *
ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct
- ANASTASIS_UuidP *truth_uuid,
+ uuid_t *truth_uuid,
const struct
GNUNET_HashCode *prev_truth_data_hash,
json_t *truth_data,
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d41e1c0..d12aa28 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -68,6 +68,7 @@ libanastasistesting_la_LIBADD = \
-lgnunetjson \
-lgnunetutil \
-ljansson \
+ -luuid \
-ltalertesting \
$(XLIB)
diff --git a/src/lib/anastasis_api_keyshare_lookup.c
b/src/lib/anastasis_api_keyshare_lookup.c
index 4412eb8..b6aac20 100644
--- a/src/lib/anastasis_api_keyshare_lookup.c
+++ b/src/lib/anastasis_api_keyshare_lookup.c
@@ -70,7 +70,7 @@ struct ANASTASIS_KeyShareLookupOperation
/**
* Identification of the Truth Object
*/
- struct ANASTASIS_UuidP truth_uuid;
+ uuid_t truth_uuid;
/**
* Key to decrypt the truth on the server
@@ -257,7 +257,7 @@ handle_header (char *buffer,
struct ANASTASIS_KeyShareLookupOperation *
ANASTASIS_key_share_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct ANASTASIS_UuidP *truth_uuid,
+ uuid_t *truth_uuid,
const struct ANASTASIS_TruthKey *truth_key,
const struct GNUNET_HashCode *hashed_answer,
ANASTASIS_KeyShareLookupCallback cb,
diff --git a/src/lib/anastasis_api_truth_store.c
b/src/lib/anastasis_api_truth_store.c
index 24322b8..473ff6d 100644
--- a/src/lib/anastasis_api_truth_store.c
+++ b/src/lib/anastasis_api_truth_store.c
@@ -255,8 +255,7 @@ handle_header (char *buffer,
struct ANASTASIS_TruthStoreOperation *
ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct
- ANASTASIS_UuidP *truth_uuid,
+ uuid_t *truth_uuid,
const struct
GNUNET_HashCode *prev_truth_data_hash,
json_t *truth_data,
@@ -325,28 +324,52 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
}
}
/* Finished setting up headers */
-
tso = GNUNET_new (struct ANASTASIS_TruthStoreOperation);
tso->new_truth_data_hash = new_truth_data_hash;
{
- char *uuid_str;
- char *path;
+ if (NULL != truth_uuid)
+ {
+ char uuid_str[37];
+ char *path;
+
+ uuid_unparse (truth_uuid, uuid_str);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "UUID: %s\n",
+ uuid_str);
+ GNUNET_asprintf (&path,
+ "truth/%s",
+ uuid_str);
+ tso->url = (GNUNET_YES == payment_requested)
+ ? TALER_url_join (backend_url,
+ path,
+ "pay",
+ "y",
+ (NULL != paid_order_id)
+ ? "paying"
+ : NULL,
+ paid_order_id,
+ NULL)
+ : TALER_url_join (backend_url,
+ path,
+ (NULL != paid_order_id)
+ ? "paying"
+ : NULL,
+ paid_order_id,
+ NULL);
+ GNUNET_free (path);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "No uuid set");
+ return NULL;
+ }
- uuid_str = GNUNET_STRINGS_data_to_string_alloc (&truth_uuid,
- sizeof (truth_uuid));
- GNUNET_asprintf (&path,
- "truth/%s",
- uuid_str);
- GNUNET_free (uuid_str);
- tso->url = TALER_url_join (backend_url,
- path);
- GNUNET_free (path);
}
tso->ctx = ctx;
tso->cb = cb;
tso->cb_cls = cb_cls;
eh = ANASTASIS_curl_easy_get_ (tso->url);
- /*
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_POSTFIELDS,
@@ -363,20 +386,6 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
curl_easy_setopt (eh,
CURLOPT_HEADERDATA,
tso));
- */
- if (GNUNET_OK !=
- TALER_curl_easy_post (ctx,
- eh,
- truth_data))
- {
- GNUNET_break (0);
- curl_easy_cleanup (eh);
- json_decref (truth_data);
- GNUNET_free (tso->url);
- GNUNET_free (tso);
- return NULL;
- }
- json_decref (truth_data);
tso->job = GNUNET_CURL_job_add2 (ctx,
eh,
job_headers,
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 2ac0bad..f41440a 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -303,7 +303,7 @@ run (void *cls,
struct TALER_TESTING_Command truth[] = {
// FIXME: Code for truth handling
- ANASTASIS_TESTING_cmd_truth_store ("truth-strore-1",
+ ANASTASIS_TESTING_cmd_truth_store ("truth-store-1",
anastasis_url,
NULL,
MHD_HTTP_NO_CONTENT,
@@ -318,12 +318,12 @@ run (void *cls,
TALER_TESTING_cmd_batch ("pay",
pay),
- TALER_TESTING_cmd_batch ("truth",
- truth),
-
TALER_TESTING_cmd_batch ("policy",
policy),
+ TALER_TESTING_cmd_batch ("truth",
+ truth),
+
/**
* End the suite. Fixme: better to have a label for this
diff --git a/src/lib/test_anastasisrest_api b/src/lib/test_anastasisrest_api
index 6bc0246..a6f6ba8 100755
--- a/src/lib/test_anastasisrest_api
+++ b/src/lib/test_anastasisrest_api
@@ -31,7 +31,7 @@ DUALCASE=1; export DUALCASE # for MKS sh
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-relink_command="(cd
/home/dennis/Nextcloud/Studium-BFH/Aktuell_HS2019/Project2/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_PATH || { LD_RUN [...]
+relink_command="(cd
/home/dennis/Nextcloud/Studium-BFH/Aktuell_HS2019/Project2/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_PATH || { LD_RUN [...]
# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
diff --git a/src/lib/testing_api_cmd_truth_store.c
b/src/lib/testing_api_cmd_truth_store.c
index ba9be35..712044f 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -24,6 +24,7 @@
*/
#include "platform.h"
+#include <uuid/uuid.h>
#include "anastasis_service.h"
#include "anastasis_testing_lib.h"
#include <taler/taler_util.h>
@@ -52,7 +53,7 @@ struct TruthStoreState
*/
struct GNUNET_HashCode prev_hash;
- struct ANASTASIS_UuidP truth_uuid;
+ uuid_t truth_uuid;
/**
* Hash of the current upload.
@@ -294,10 +295,14 @@ truth_store_run (void *cls,
}
}
{
- // hash truth data
- GNUNET_CRYPTO_hash (tss->truth_data,
- sizeof (tss->truth_data),
- &tss->curr_hash);
+ // Create an uuid
+ uuid_generate (tss->truth_uuid);
+ }
+ {
+ // create json
+ // FIXME: create an example TruthUploadRequest-Json-Object
+ json_t *truth_json;
+ tss->truth_data = truth_json;
}
tss->tso = ANASTASIS_truth_store (is->ctx,
tss->anastasis_url,
--
To stop receiving notification emails like this one, please contact
address@hidden.