[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: misc. fixes
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: misc. fixes |
Date: |
Sat, 13 Feb 2021 20:29:57 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 60958ee misc. fixes
60958ee is described below
commit 60958eea5f53d5e106f78153463afd479a776173
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Feb 13 20:29:55 2021 +0100
misc. fixes
---
src/backend/anastasis-httpd_truth_upload.c | 33 +++++++++++++++------------
src/include/anastasis_database_plugin.h | 22 ------------------
src/stasis/plugin_anastasis_postgres.c | 7 ++++--
src/testing/test_anastasis_api.c | 28 ++++++++++++++++++-----
src/testing/testing_api_cmd_keyshare_lookup.c | 12 ++++++----
5 files changed, 53 insertions(+), 49 deletions(-)
diff --git a/src/backend/anastasis-httpd_truth_upload.c
b/src/backend/anastasis-httpd_truth_upload.c
index b8b23cb..f3f43a7 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -422,18 +422,22 @@ AH_handler_truth_post (
json_t *json;
MHD_RESULT ret;
int res;
- struct ANASTASIS_DB_Truth truth;
+ struct ANASTASIS_CRYPTO_EncryptedKeyShareP keyshare_data;
+ void *encrypted_truth;
+ size_t encrypted_truth_size;
+ const char *truth_mime;
+ const char *method;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("keyshare_data",
- &truth.keyshare_data),
+ &keyshare_data),
GNUNET_JSON_spec_string ("method",
- &truth.method),
+ &method),
GNUNET_JSON_spec_varsize ("encrypted_truth",
- &truth.encrypted_truth,
- &truth.encrypted_truth_size),
+ &encrypted_truth,
+ &encrypted_truth_size),
GNUNET_JSON_spec_string ("truth_mime",
- &truth.truth_mime),
+ &truth_mime),
GNUNET_JSON_spec_end ()
};
@@ -544,26 +548,27 @@ AH_handler_truth_post (
struct TALER_Amount dummy;
if ( (0 != strcmp ("question",
- truth.method)) &&
+ method)) &&
(NULL ==
- ANASTASIS_authorization_plugin_load (truth.method,
+ ANASTASIS_authorization_plugin_load (method,
AH_cfg,
&dummy)) )
{
+ GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_ANASTASIS_TRUTH_UPLOAD_METHOD_NOT_SUPPORTED,
- truth.method);
+ method);
}
}
qs = db->store_truth (db->cls,
truth_uuid,
- &truth.keyshare_data,
- truth.truth_mime,
- truth.encrypted_truth,
- truth.encrypted_truth_size,
- truth.method,
+ &keyshare_data,
+ truth_mime,
+ encrypted_truth,
+ encrypted_truth_size,
+ method,
AH_truth_expiration);
json_decref (json);
GNUNET_JSON_parse_free (spec);
diff --git a/src/include/anastasis_database_plugin.h
b/src/include/anastasis_database_plugin.h
index ab29c78..b63fefa 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -121,28 +121,6 @@ enum ANASTASIS_DB_StoreStatus
};
-/**
- * @brief Specification for a /truth operation.
- */
-struct ANASTASIS_DB_Truth
-{
- struct ANASTASIS_CRYPTO_EncryptedKeyShareP keyshare_data;
-
- struct ANASTASIS_CRYPTO_NonceP nonce;
-
- // AES_GCM_Tag
- struct ANASTASIS_CRYPTO_AesTagP aes_gcm_tag;
-
- void *encrypted_truth;
-
- size_t encrypted_truth_size;
-
- const char *truth_mime;
-
- const char *method;
-};
-
-
/**
* Function called on all pending payments for an account or challenge.
*
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index ded0423..4621537 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -892,8 +892,10 @@ postgres_check_truth_upload_paid (
struct GNUNET_TIME_Absolute *paid_until)
{
struct PostgresClosure *pg = cls;
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (uuid),
+ GNUNET_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -1832,8 +1834,9 @@ libanastasis_plugin_db_postgres_init (void *cls)
"SELECT"
" expiration"
" FROM anastasis_truth_payment"
- " WHERE truth_uuid=$1;",
- 1),
+ " WHERE truth_uuid=$1"
+ " AND expiration>$2;",
+ 2),
GNUNET_PQ_make_prepare ("challenge_payment_select",
"SELECT"
" creation_date"
diff --git a/src/testing/test_anastasis_api.c b/src/testing/test_anastasis_api.c
index a7e649a..797eb12 100644
--- a/src/testing/test_anastasis_api.c
+++ b/src/testing/test_anastasis_api.c
@@ -223,12 +223,20 @@ run (void *cls,
ANASTASIS_TESTING_TSO_NONE,
MHD_HTTP_NO_CONTENT),
ANASTASIS_TESTING_cmd_keyshare_lookup (
- "challenge-run-1",
+ "challenge-fail-1",
anastasis_url,
- "The-Answer",
+ "Wrong-Answer",
NULL,
"truth-store-1",
0,
+ ANASTASIS_KSD_INVALID_ANSWER),
+ ANASTASIS_TESTING_cmd_keyshare_lookup (
+ "file-challenge-run-1",
+ anastasis_url,
+ NULL, /* no answer */
+ NULL, /* payment ref */
+ "truth-store-2", /* upload ref */
+ 0,
ANASTASIS_KSD_PAYMENT_REQUIRED),
/* what would we have to pay? */
TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
@@ -247,12 +255,20 @@ run (void *cls,
NULL),
ANASTASIS_TESTING_cmd_keyshare_lookup (
- "challenge-run-2",
+ "file-challenge-run-2",
anastasis_url,
- "The-Answer",
- "challenge-run-1",
- "truth-store-1",
+ NULL, /* no answer */
+ "file-challenge-run-1", /* payment ref */
+ "truth-store-2",
0,
+ ANASTASIS_KSD_INVALID_ANSWER),
+ ANASTASIS_TESTING_cmd_keyshare_lookup (
+ "file-challenge-run-3",
+ anastasis_url,
+ "file-challenge-run-2", /* answer */
+ "file-challenge-run-1", /* payment ref */
+ "truth-store-2",
+ 1,
ANASTASIS_KSD_SUCCESS),
TALER_TESTING_cmd_end ()
};
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c
b/src/testing/testing_api_cmd_keyshare_lookup.c
index 83179d6..63b8064 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -213,16 +213,18 @@ keyshare_lookup_run (void *cls,
{
struct GNUNET_HashCode h_answer;
- GNUNET_CRYPTO_hash (ksls->answer,
- strlen (ksls->answer),
- &h_answer);
-
+ if (NULL != ksls->answer)
+ GNUNET_CRYPTO_hash (ksls->answer,
+ strlen (ksls->answer),
+ &h_answer);
ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
ksls->anastasis_url,
truth_uuid,
truth_key,
payment_secret,
- &h_answer,
+ (NULL != ksls->answer)
+ ? &h_answer
+ : NULL,
&keyshare_lookup_cb,
ksls);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: misc. fixes,
gnunet <=