[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: improve error handling, use conf
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: improve error handling, use configuration option names as per latest docs |
Date: |
Sat, 04 Apr 2020 15:52:09 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 3c61e83 improve error handling, use configuration option names as per
latest docs
3c61e83 is described below
commit 3c61e8385ca4822cf1d39ec021237fc213a526f1
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Apr 4 15:52:07 2020 +0200
improve error handling, use configuration option names as per latest docs
---
src/backend/taler-merchant-httpd_auditors.c | 33 ++++++++++++++++++---------
src/backend/taler-merchant-httpd_exchanges.c | 34 ++++++++++++++++++++++++----
src/backend/taler-merchant-httpd_exchanges.h | 2 +-
src/backend/taler-merchant-httpd_pay.c | 2 +-
src/lib/test_merchant_api.conf | 7 +++---
src/lib/test_merchant_api_twisted.conf | 4 ++--
6 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_auditors.c
b/src/backend/taler-merchant-httpd_auditors.c
index 852654f..225fa15 100644
--- a/src/backend/taler-merchant-httpd_auditors.c
+++ b/src/backend/taler-merchant-httpd_auditors.c
@@ -152,27 +152,38 @@ parse_auditors (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
char *pks;
struct Auditor auditor;
+ char *currency;
if (0 != strncasecmp (section,
- "auditor-",
- strlen ("auditor-")))
+ "merchant-auditor-",
+ strlen ("merchant-auditor-")))
return;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "NAME",
- &auditor.name))
+ "CURRENCY",
+ ¤cy))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section,
- "NAME");
+ "CURRENCY");
return;
}
- // FIXME: url -> auditor_url
+ if (0 != strcasecmp (currency,
+ TMH_currency))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Auditor given in section `%s' is for another currency.
Skipping.\n",
+ section);
+ GNUNET_free (currency);
+ return;
+ }
+ GNUNET_free (currency);
+ auditor.name = GNUNET_strdup (§ion[strlen ("merchant-auditor-")]);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "URL",
+ "AUDITOR_BASE_URL",
&auditor.url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
@@ -184,12 +195,12 @@ parse_auditors (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "PUBLIC_KEY",
+ "AUDITOR_KEY",
&pks))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section,
- "PUBLIC_KEY");
+ "AUDITOR_KEY");
GNUNET_free (auditor.name);
GNUNET_free (auditor.url);
return;
@@ -201,8 +212,8 @@ parse_auditors (void *cls,
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
section,
- "PUBLIC_KEY",
- "valid public key");
+ "AUDITOR_KEY",
+ "need a valid EdDSA public key");
GNUNET_free (auditor.name);
GNUNET_free (auditor.url);
GNUNET_free (pks);
diff --git a/src/backend/taler-merchant-httpd_exchanges.c
b/src/backend/taler-merchant-httpd_exchanges.c
index a987151..2ea00a1 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -292,7 +292,7 @@ retry_exchange (void *cls)
/* might be a scheduled reload and not our first attempt */
exchange->retry_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting to exchange exchange %s in retry_exchange\n",
+ "Connecting to exchange %s in retry_exchange()\n",
exchange->url);
if (NULL != exchange->conn)
{
@@ -304,6 +304,8 @@ retry_exchange (void *cls)
&keys_mgmt_cb,
exchange,
TALER_EXCHANGE_OPTION_END);
+ /* Note: while the API spec says 'returns NULL on error', the implementation
+ actually never returns NULL. */
GNUNET_break (NULL != exchange->conn);
}
@@ -1028,6 +1030,7 @@ accept_exchanges (void *cls,
char *url;
char *mks;
struct Exchange *exchange;
+ char *currency;
if (0 != strncasecmp (section,
"merchant-exchange-",
@@ -1036,12 +1039,33 @@ accept_exchanges (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
section,
- "BASE_URL",
+ "CURRENCY",
+ ¤cy))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "CURRENCY");
+ return;
+ }
+ if (0 != strcasecmp (currency,
+ TMH_currency))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Exchange given in section `%s' is for another currency.
Skipping.\n",
+ section);
+ GNUNET_free (currency);
+ return;
+ }
+ GNUNET_free (currency);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "EXCHANGE_BASE_URL",
&url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
section,
- "BASE_URL");
+ "EXCHANGE_BASE_URL");
return;
}
exchange = GNUNET_new (struct Exchange);
@@ -1065,7 +1089,7 @@ accept_exchanges (void *cls,
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
section,
"MASTER_KEY",
- _ ("ill-formed key"));
+ _ ("ill-formed EdDSA key"));
}
GNUNET_free (mks);
}
@@ -1183,6 +1207,8 @@ TMH_EXCHANGES_done ()
GNUNET_SCHEDULER_cancel (exchange->retry_task);
exchange->retry_task = NULL;
}
+ GNUNET_assert (NULL == exchange->fo_head);
+ GNUNET_assert (NULL == exchange->fo_tail);
GNUNET_free (exchange->url);
GNUNET_free (exchange);
}
diff --git a/src/backend/taler-merchant-httpd_exchanges.h
b/src/backend/taler-merchant-httpd_exchanges.h
index 61a5c79..eca69af 100644
--- a/src/backend/taler-merchant-httpd_exchanges.h
+++ b/src/backend/taler-merchant-httpd_exchanges.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2014, 2015 INRIA
+ (C) 2014-2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
diff --git a/src/backend/taler-merchant-httpd_pay.c
b/src/backend/taler-merchant-httpd_pay.c
index b0178cd..9d725b5 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1232,7 +1232,7 @@ process_pay_with_exchange (void *cls,
pc,
hc,
TALER_MHD_make_json_pack ("{s:s, s:I, s:o}",
- "hint", "invalid denomination",
+ "hint", "denomination not accepted",
"code", (json_int_t) ec,
"h_denom_pub", GNUNET_JSON_from_data_auto (
&denom_details->h_key)));
diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf
index cb0d25e..2bab1ec 100644
--- a/src/lib/test_merchant_api.conf
+++ b/src/lib/test_merchant_api.conf
@@ -118,9 +118,10 @@ ACTIVE_nulltip = YES
# Sections starting with "merchant-exchange-" specify trusted exchanges
# (by the merchant)
-[merchant-exchange-kudos]
-MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
-BASE_URL = http://localhost:8081/
+[merchant-exchange-test]
+MASTER_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
+EXCHANGE_BASE_URL = http://localhost:8081/
+CURRENCY = EUR
# only fixes skips.
[auditor]
diff --git a/src/lib/test_merchant_api_twisted.conf
b/src/lib/test_merchant_api_twisted.conf
index e00c44e..5cc28b4 100644
--- a/src/lib/test_merchant_api_twisted.conf
+++ b/src/lib/test_merchant_api_twisted.conf
@@ -1,9 +1,9 @@
# This file is in the public domain.
@INLINE@ test_merchant_api.conf
-[merchant-exchange-kudos]
+[merchant-exchange-test]
# must target the twister's http port.
-BASE_URL = http://localhost:8888/
+EXCHANGE_BASE_URL = http://localhost:8888/
[exchange]
BASE_URL = http://localhost:8888/
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: improve error handling, use configuration option names as per latest docs,
gnunet <=