[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: fix refund logic: pass correct
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: fix refund logic: pass correct refund delay, other minor fixes |
Date: |
Sun, 11 Apr 2021 01:36:26 +0200 |
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 5aae20e fix refund logic: pass correct refund delay, other minor fixes
5aae20e is described below
commit 5aae20e6896528db5a6236a84e4fa570503ea704
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 11 01:36:23 2021 +0200
fix refund logic: pass correct refund delay, other minor fixes
---
.../anastasis_authorization_plugin_sms.c | 2 +-
src/backend/anastasis-httpd_truth.c | 23 +++++++---
src/reducer/anastasis_api_backup_redux.c | 49 ++++++++++++++++------
src/stasis/plugin_anastasis_postgres.c | 7 +++-
4 files changed, 62 insertions(+), 19 deletions(-)
diff --git a/src/authorization/anastasis_authorization_plugin_sms.c
b/src/authorization/anastasis_authorization_plugin_sms.c
index 7b37b7b..70bcff7 100644
--- a/src/authorization/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -588,7 +588,7 @@ libanastasis_plugin_authorization_sms_init (void *cls)
* @return NULL (always)
*/
void *
-libanastasis_plugin_authorization_email_done (void *cls)
+libanastasis_plugin_authorization_sms_done (void *cls)
{
struct ANASTASIS_AuthorizationPlugin *plugin = cls;
struct SMS_Context *ctx = plugin->cls;
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index 4dd3f26..98f7726 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -230,7 +230,11 @@ AH_truth_shutdown (void)
GNUNET_CONTAINER_DLL_remove (re_head,
re_tail,
re);
- TALER_MERCHANT_post_order_refund_cancel (re->ro);
+ if (NULL != re->ro)
+ {
+ TALER_MERCHANT_post_order_refund_cancel (re->ro);
+ re->ro = NULL;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Refund `%s' failed due to shutdown\n",
re->order_id);
@@ -296,6 +300,9 @@ refund_cb (
{
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Refund `%s' succeeded\n",
+ re->order_id);
qs = db->record_challenge_refund (db->cls,
&re->truth_uuid,
&re->payment_identifier);
@@ -322,6 +329,7 @@ refund_cb (
hr->http_status,
hr->hint,
(unsigned int) hr->ec);
+ break;
}
GNUNET_CONTAINER_DLL_remove (re_head,
re_tail,
@@ -357,6 +365,13 @@ begin_refund (const struct GetContext *gc)
"failed to issue challenge",
&refund_cb,
re);
+ if (NULL == re->ro)
+ {
+ GNUNET_break (0);
+ GNUNET_free (re->order_id);
+ GNUNET_free (re);
+ return;
+ }
GNUNET_CONTAINER_DLL_insert (re_head,
re_tail,
re);
@@ -712,20 +727,18 @@ begin_payment (struct GetContext *gc)
pay_deadline = GNUNET_TIME_relative_to_absolute (
ANASTASIS_CHALLENGE_OFFER_LIFETIME);
GNUNET_TIME_round_abs (&pay_deadline);
- order = json_pack ("{s:o, s:s, s:s, s:o, s:o, s:o}",
+ order = json_pack ("{s:o, s:s, s:s, s:o, s:o}",
"amount", TALER_JSON_from_amount (&gc->challenge_cost),
"summary", "challenge fee for anastasis service",
"order_id", order_id,
"auto_refund", GNUNET_JSON_from_time_rel (
AUTO_REFUND_TIMEOUT),
- "refund_delay", GNUNET_JSON_from_time_rel (
- AUTO_REFUND_TIMEOUT),
"pay_deadline", GNUNET_JSON_from_time_abs (
pay_deadline));
gc->po = TALER_MERCHANT_orders_post2 (AH_ctx,
AH_backend_url,
order,
- GNUNET_TIME_UNIT_ZERO,
+ AUTO_REFUND_TIMEOUT,
NULL, /* no payment target */
0,
NULL, /* no inventory products */
diff --git a/src/reducer/anastasis_api_backup_redux.c
b/src/reducer/anastasis_api_backup_redux.c
index b4fcd55..4f42f2b 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -485,6 +485,7 @@ eval_provider_selection (struct PolicyBuilder *pb,
mspec,
NULL, NULL))
{
+ GNUNET_break (0);
pb->ec = TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID;
pb->hint = "'authentication_method' content malformed";
return;
@@ -495,8 +496,9 @@ eval_provider_selection (struct PolicyBuilder *pb,
pspec,
NULL, NULL))
{
- pb->ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
- pb->hint = "'methods' of provider not found";
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Skipping provider %s: no suitable configuration\n",
+ prov_sel[i]);
GNUNET_JSON_parse_free (mspec);
return;
}
@@ -517,6 +519,7 @@ eval_provider_selection (struct PolicyBuilder *pb,
spec,
NULL, NULL))
{
+ GNUNET_break (0);
pb->ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
pb->hint = "'methods' of provider";
GNUNET_JSON_parse_free (pspec);
@@ -897,7 +900,7 @@ add_policy (json_t *state,
methods = json_array ();
GNUNET_assert (NULL != methods);
- /* Add all methods from 'arg_array' to 'methods', and sum up 'recovery_cost'
*/
+ /* Add all methods from 'arg_array' to 'methods' */
{
size_t index;
json_t *method;
@@ -906,7 +909,7 @@ add_policy (json_t *state,
{
const char *provider_url;
uint32_t method_idx;
- const json_t *prov_methods;
+ json_t *prov_methods;
const char *method_type;
struct GNUNET_JSON_Specification spec[] = {
@@ -931,6 +934,15 @@ add_policy (json_t *state,
{
const json_t *prov_cfg;
+ uint32_t limit;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
+ &limit),
+ GNUNET_JSON_spec_json ("methods",
+ &prov_methods),
+ GNUNET_JSON_spec_end ()
+ };
+
prov_cfg = json_object_get (auth_providers,
provider_url);
if (NULL == prov_cfg)
@@ -942,11 +954,23 @@ add_policy (json_t *state,
"provider URL unknown");
return NULL;
}
- prov_methods = json_object_get (prov_cfg,
- "methods");
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (prov_cfg,
+ spec,
+ NULL, NULL))
+ {
+ json_decref (methods);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "provider lacks authentication methods");
+ return NULL;
+
+ }
if (! json_is_array (prov_methods))
{
json_decref (methods);
+ json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
@@ -963,6 +987,7 @@ add_policy (json_t *state,
if (NULL == auth_method)
{
json_decref (methods);
+ json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
@@ -974,6 +999,7 @@ add_policy (json_t *state,
if (NULL == method_type)
{
json_decref (methods);
+ json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
@@ -1004,6 +1030,7 @@ add_policy (json_t *state,
NULL, NULL))
{
json_decref (methods);
+ json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
@@ -1019,6 +1046,7 @@ add_policy (json_t *state,
if (! found)
{
json_decref (methods);
+ json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
@@ -1029,6 +1057,7 @@ add_policy (json_t *state,
GNUNET_assert (0 ==
json_array_append (methods,
method));
+ json_decref (prov_methods);
} /* end of json_array_foreach (arg_array, index, method) */
}
@@ -2644,12 +2673,8 @@ enter_secret (json_t *state,
spec,
NULL, NULL))
{
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "'authentication_method' content malformed");
- GNUNET_free (secret);
- return NULL;
+ /* skip malformed provider, likely /config failed */
+ continue;
}
if (0 == limit)
{
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 6750e47..21f2ae7 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -629,7 +629,6 @@ postgres_increment_lifetime (
struct GNUNET_TIME_Relative lifetime)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute expiration;
enum GNUNET_DB_QueryStatus qs;
check_connection (pg);
@@ -667,6 +666,7 @@ postgres_increment_lifetime (
GNUNET_PQ_query_param_auto_from_type (anastasis_pub),
GNUNET_PQ_query_param_end
};
+ struct GNUNET_TIME_Absolute expiration;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("expiration_date",
&expiration),
@@ -694,6 +694,8 @@ postgres_increment_lifetime (
};
expiration = GNUNET_TIME_relative_to_absolute (lifetime);
+ GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
+ expiration.abs_value_us);
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_insert",
params);
@@ -710,6 +712,8 @@ postgres_increment_lifetime (
expiration = GNUNET_TIME_absolute_add (expiration,
lifetime);
+ GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
+ expiration.abs_value_us);
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_update",
params);
@@ -814,6 +818,7 @@ postgres_record_recdoc_payment (
GNUNET_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end
};
+
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_insert",
params);
--
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: fix refund logic: pass correct refund delay, other minor fixes,
gnunet <=