[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 01/02: fixed salt api test
From: |
gnunet |
Subject: |
[taler-anastasis] 01/02: fixed salt api test |
Date: |
Thu, 16 Apr 2020 09:19:24 +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 0edea087bca8bc9a397f7b5e5310d5f7dbe3c456
Author: Dennis Neufeld <address@hidden>
AuthorDate: Thu Apr 16 07:06:18 2020 +0000
fixed salt api test
---
src/backend/anastasis-httpd_salt.c | 9 +++------
src/include/anastasis_crypto_lib.h | 2 +-
src/include/anastasis_testing_lib.h | 14 ++++++++++++++
src/lib/Makefile.am | 1 +
src/lib/anastasis_api_salt.c | 29 ++++++++++++++++++++---------
src/lib/test_anastasis_api.c | 12 ++++++++++--
src/lib/testing_api_cmd_salt.c | 15 +++++++++++++--
7 files changed, 62 insertions(+), 20 deletions(-)
diff --git a/src/backend/anastasis-httpd_salt.c
b/src/backend/anastasis-httpd_salt.c
index 44e4525..7b27b7f 100644
--- a/src/backend/anastasis-httpd_salt.c
+++ b/src/backend/anastasis-httpd_salt.c
@@ -38,15 +38,12 @@ AH_handler_salt (struct MHD_Connection *connection,
const char *url,
void **con_cls)
{
- struct ANASTASIS_CRYPTO_Salt salt;
- salt.salt = (char *) AH_server_salt;
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Server Salt: %s\n",
- salt.salt);
+ (char *) AH_server_salt);
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:o}",
+ "{s:s}",
"server_salt",
- GNUNET_JSON_from_data_auto (&salt));
+ (char *) AH_server_salt);
}
\ No newline at end of file
diff --git a/src/include/anastasis_crypto_lib.h
b/src/include/anastasis_crypto_lib.h
index 9bfd407..4358442 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -57,7 +57,7 @@ struct ANASTASIS_CRYPTO_TruthKey
*/
struct ANASTASIS_CRYPTO_Salt
{
- char*salt;
+ const char *salt;
};
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index a9d9962..b6cda89 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -366,4 +366,18 @@ ANASTASIS_TESTING_cmd_truth_lookup (const char *label,
unsigned int http_status,
const char *upload_ref);
+/**
+ * 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);
+
#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index ea2da4a..2ff47a5 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -58,6 +58,7 @@ libanastasistesting_la_SOURCES = \
testing_api_cmd_policy_store.c \
testing_api_cmd_truth_store.c \
testing_api_cmd_policy_lookup.c \
+ testing_api_cmd_salt.c \
testing_api_helpers.c \
testing_api_trait_account_pub.c \
testing_api_trait_account_priv.c \
diff --git a/src/lib/anastasis_api_salt.c b/src/lib/anastasis_api_salt.c
index 67cdaea..b36888d 100644
--- a/src/lib/anastasis_api_salt.c
+++ b/src/lib/anastasis_api_salt.c
@@ -97,7 +97,7 @@ handle_salt_finished (void *cls,
case MHD_HTTP_OK:
{
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("server_salt", &so->salt),
+ GNUNET_JSON_spec_string ("server_salt", &so->salt.salt),
GNUNET_JSON_spec_end ()
};
@@ -105,8 +105,19 @@ handle_salt_finished (void *cls,
GNUNET_JSON_parse (json,
spec,
NULL, NULL));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Salt json from download: %s\n\n",
+ json_dumps (json, JSON_COMPACT));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Salt from download: %s\n\n",
+ so->salt.salt);
+ so->cb (so->cb_cls,
+ response_code,
+ &so->salt);
+ ANASTASIS_salt_cancel (so);
+ return;
}
- break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the anastasis server is buggy
(or API version conflict); just pass JSON reply to the application */
@@ -131,7 +142,7 @@ handle_salt_finished (void *cls,
{
so->cb (so->cb_cls,
response_code,
- &so->salt);
+ NULL);
so->cb = NULL;
}
ANASTASIS_salt_cancel (so);
@@ -149,17 +160,17 @@ ANASTASIS_salt (struct GNUNET_CURL_Context *ctx,
so = GNUNET_new (struct ANASTASIS_SaltOperation);
so->url = TALER_url_join (base_url,
- "/salt",
+ "salt",
NULL);
so->ctx = ctx;
so->cb = cb;
so->cb_cls = cb_cls;
eh = ANASTASIS_curl_easy_get_ (so->url);
- so->job = GNUNET_CURL_job_add (ctx,
- eh,
- GNUNET_NO,
- &handle_salt_finished,
- so);
+ so->job = GNUNET_CURL_job_add2 (ctx,
+ eh,
+ GNUNET_NO,
+ &handle_salt_finished,
+ so);
return so;
}
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index ed81e12..984699a 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -236,8 +236,6 @@ run (void *cls,
};
struct TALER_TESTING_Command truth[] = {
- // FIXME: Code for truth handling
-
ANASTASIS_TESTING_cmd_truth_store ("truth-store-1",
anastasis_url,
NULL,
@@ -249,6 +247,13 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
+ struct TALER_TESTING_Command salt[] = {
+ ANASTASIS_TESTING_cmd_salt ("salt-request-1",
+ anastasis_url,
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_end ()
+ };
+
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_batch ("pay",
@@ -260,6 +265,9 @@ run (void *cls,
TALER_TESTING_cmd_batch ("truth",
truth),
+ TALER_TESTING_cmd_batch ("salt",
+ salt),
+
/**
* End the suite. Fixme: better to have a label for this
diff --git a/src/lib/testing_api_cmd_salt.c b/src/lib/testing_api_cmd_salt.c
index d67b32e..31dd81d 100644
--- a/src/lib/testing_api_cmd_salt.c
+++ b/src/lib/testing_api_cmd_salt.c
@@ -67,7 +67,7 @@ salt_cb (void *cls,
{
struct SaltState *ss = cls;
- ss->plo = NULL;
+ ss->so = NULL;
if (http_status != ss->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -79,6 +79,17 @@ salt_cb (void *cls,
TALER_TESTING_interpreter_fail (ss->is);
return;
}
+ if (NULL == salt)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Salt is NULL, command %s in %s:%u\n",
+ ss->is->commands[ss->is->ip].label,
+ __FILE__,
+ __LINE__);
+ TALER_TESTING_interpreter_fail (ss->is);
+ return;
+ }
+ TALER_TESTING_interpreter_next (ss->is);
}
@@ -99,7 +110,7 @@ salt_run (void *cls,
ss->is = is;
ss->so = ANASTASIS_salt (is->ctx,
ss->anastasis_url,
- &salt_cb,
+ salt_cb,
ss);
if (NULL == ss->so)
{
--
To stop receiving notification emails like this one, please contact
address@hidden.