aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-03-19 15:19:00 +0100
committerChristian Grothoff <christian@grothoff.org>2024-03-19 15:19:00 +0100
commit110b61ff12208ffbb022296097b85d28cc1cfe7e (patch)
tree414c0de1ffe90685effe7230883c085239f7ce46 /src
parent88a23388c11a755fece7221579be1143e48d32c5 (diff)
address TODOsCodeBlau-NGI-t2.7
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-exchange.c2
-rw-r--r--src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c7
-rw-r--r--src/backend/taler-merchant-httpd_private-patch-templates-ID.c52
-rw-r--r--src/backend/taler-merchant-httpd_private-patch-token-families-SLUG.c3
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c118
-rw-r--r--src/backend/taler-merchant-httpd_private-post-templates.c52
-rw-r--r--src/backend/taler-merchant-httpd_private-post-token-families.c3
7 files changed, 152 insertions, 85 deletions
diff --git a/src/backend/taler-merchant-exchange.c b/src/backend/taler-merchant-exchange.c
index f77ca3a5..e3b0d6c4 100644
--- a/src/backend/taler-merchant-exchange.c
+++ b/src/backend/taler-merchant-exchange.c
@@ -725,7 +725,7 @@ check_transfer (void *cls,
/* Build the `TrackTransferConflictDetails` */
ctc->ec = TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS;
ctc->failure = true;
- /* TODO: this should be reported to the auditor! */
+ /* FIXME: this should be reported to the auditor (once the auditor has an API for this) */
return;
}
ctc->check_transfer_result = GNUNET_OK;
diff --git a/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c b/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
index b7c8ab4d..06dbbdf9 100644
--- a/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
+++ b/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
@@ -72,9 +72,9 @@ TMH_private_get_tokenfamilies_SLUG (const struct TMH_RequestHandler *rh,
}
else
{
+ GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
- // TODO: What error code to use here?
TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
"invalid_token_family_kind");
}
@@ -86,12 +86,13 @@ TMH_private_get_tokenfamilies_SLUG (const struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
GNUNET_JSON_pack_string ("name", details.name),
GNUNET_JSON_pack_string ("description", details.description),
- GNUNET_JSON_pack_object_steal ("description_i18n", details.description_i18n),
+ GNUNET_JSON_pack_object_steal ("description_i18n",
+ details.description_i18n),
GNUNET_JSON_pack_timestamp ("valid_after", details.valid_after),
GNUNET_JSON_pack_timestamp ("valid_before", details.valid_before),
GNUNET_JSON_pack_time_rel ("duration", details.duration),
GNUNET_JSON_pack_string ("kind", kind)
- );
+ );
GNUNET_free (details.name);
GNUNET_free (details.description);
diff --git a/src/backend/taler-merchant-httpd_private-patch-templates-ID.c b/src/backend/taler-merchant-httpd_private-patch-templates-ID.c
index 6aebc033..e8a6c531 100644
--- a/src/backend/taler-merchant-httpd_private-patch-templates-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-templates-ID.c
@@ -146,8 +146,56 @@ TMH_private_patch_templates_ID (const struct TMH_RequestHandler *rh,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"template_contract");
}
- // FIXME: sanity check on required_currency
- // FIXME: sanity check on editable_defaults
+ if ( (NULL != tp.required_currency) &&
+ (GNUNET_OK !=
+ TALER_check_currency (tp.required_currency)) )
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "required_currency");
+ }
+ if ( (NULL != tp.required_currency) &&
+ (NULL != json_object_get (tp.template_contract,
+ "amount")) )
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "required_currency and contract::amount specified");
+ }
+ if (NULL != tp.editable_defaults)
+ {
+ const char *key;
+ json_t *val;
+
+ json_object_foreach (tp.editable_defaults, key, val)
+ {
+ if (NULL !=
+ json_object_get (tp.template_contract,
+ key))
+ {
+ char *msg;
+ MHD_RESULT ret;
+
+ GNUNET_break_op (0);
+ GNUNET_asprintf (&msg,
+ "editable_defaults::%s conflicts with template_contract",
+ key);
+ GNUNET_JSON_parse_free (spec);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ msg);
+ GNUNET_free (msg);
+ return ret;
+ }
+ }
+ }
qs = TMH_db->update_template (TMH_db->cls,
mi->settings.id,
diff --git a/src/backend/taler-merchant-httpd_private-patch-token-families-SLUG.c b/src/backend/taler-merchant-httpd_private-patch-token-families-SLUG.c
index c49d80d7..755ed4c9 100644
--- a/src/backend/taler-merchant-httpd_private-patch-token-families-SLUG.c
+++ b/src/backend/taler-merchant-httpd_private-patch-token-families-SLUG.c
@@ -136,10 +136,9 @@ TMH_private_patch_token_family_SLUG (const struct TMH_RequestHandler *rh,
"unexpected serialization problem");
break;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- // TODO: Add error code for token family not found
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
- 0,
+ TALER_EC_MERCHANT_PATCH_TOKEN_FAMILY_NOT_FOUND,
slug);
break;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index 92d35b78..be8b8d1d 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -303,25 +303,9 @@ struct OrderContext
const json_t *products;
/**
- * TODO: Maybe remove this and set it from settings where we serialize
- * the order to JSON?
- *
- * Information like name, website, email, etc. about the merchant.
+ * Gross amount value of the contract. Used to
+ * compute @e max_stefan_fee.
*/
- json_t *merchant;
-
- /**
- * TODO: Maybe remove this and set it from settings where we serialize
- * the order to JSON?
- *
- * Merchant's public key
- */
- struct TALER_MerchantPublicKeyP merchant_pub;
-
- /**
- * Gross amount value of the contract. Used to
- * compute @e max_stefan_fee.
- */
struct TALER_Amount brutto;
/**
@@ -620,11 +604,6 @@ clean_order (void *cls)
json_decref (oc->set_exchanges.exchanges);
oc->set_exchanges.exchanges = NULL;
}
- if (NULL != oc->parse_order.merchant)
- {
- json_decref (oc->parse_order.merchant);
- oc->parse_order.merchant = NULL;
- }
if (NULL != oc->parse_order.fulfillment_message_i18n)
{
json_decref (oc->parse_order.fulfillment_message_i18n);
@@ -652,7 +631,6 @@ clean_order (void *cls)
oc->parse_request.uuids_length,
0);
json_decref (oc->parse_request.order);
- /* TODO: Check that all other fields are cleaned up! */
json_decref (oc->serialize_order.contract);
GNUNET_free (oc->parse_order.merchant_base_url);
GNUNET_free (oc);
@@ -1285,6 +1263,47 @@ get_exchange_keys (void *cls,
static void
serialize_order (struct OrderContext *oc)
{
+ const struct TALER_MERCHANTDB_InstanceSettings *settings =
+ &oc->hc->instance->settings;
+ json_t *merchant;
+
+ merchant = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("name",
+ settings->name),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("website",
+ settings->website)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("email",
+ settings->email)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("logo",
+ settings->logo)));
+ GNUNET_assert (NULL != merchant);
+ {
+ json_t *loca = settings->address;
+
+ if (NULL != loca)
+ {
+ GNUNET_assert (0 ==
+ json_object_set (merchant,
+ "address",
+ loca));
+ }
+ }
+ {
+ json_t *juri = settings->jurisdiction;
+
+ /* Handle merchant jurisdiction */
+ if (NULL != juri)
+ {
+ GNUNET_assert (0 ==
+ json_object_set (merchant,
+ "jurisdiction",
+ juri));
+ }
+ }
+
oc->serialize_order.contract = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("summary",
oc->parse_order.summary),
@@ -1325,8 +1344,8 @@ serialize_order (struct OrderContext *oc)
oc->parse_order.delivery_location)),
GNUNET_JSON_pack_string ("merchant_base_url",
oc->parse_order.merchant_base_url),
- GNUNET_JSON_pack_object_incref ("merchant",
- oc->parse_order.merchant),
+ GNUNET_JSON_pack_object_steal ("merchant",
+ merchant),
GNUNET_JSON_pack_data_auto ("merchant_pub",
&oc->hc->instance->merchant_pub),
GNUNET_JSON_pack_array_incref ("exchanges",
@@ -1857,53 +1876,6 @@ parse_order (struct OrderContext *oc)
return;
}
- {
- oc->parse_order.merchant = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("name",
- settings->name),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("website",
- settings->website)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("email",
- settings->email)),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("logo",
- settings->logo)));
- GNUNET_assert (NULL != oc->parse_order.merchant);
- {
- json_t *loca;
-
- /* Handle merchant address */
- loca = settings->address;
- if (NULL != loca)
- {
- loca = json_deep_copy (loca);
- GNUNET_assert (NULL != loca);
- GNUNET_assert (0 ==
- json_object_set_new (oc->parse_order.merchant,
- "address",
- loca));
- }
- }
- {
- json_t *juri;
-
- /* Handle merchant jurisdiction */
- juri = settings->jurisdiction;
- if (NULL != juri)
- {
- juri = json_deep_copy (juri);
- GNUNET_assert (NULL != juri);
- GNUNET_assert (0 ==
- json_object_set_new (oc->parse_order.merchant,
- "jurisdiction",
- juri));
- }
- }
- }
-
- oc->parse_order.merchant_pub = oc->hc->instance->merchant_pub;
if ( (NULL != oc->parse_order.delivery_location) &&
(! TMH_location_object_valid (oc->parse_order.delivery_location)) )
{
diff --git a/src/backend/taler-merchant-httpd_private-post-templates.c b/src/backend/taler-merchant-httpd_private-post-templates.c
index 70052f02..7aa72992 100644
--- a/src/backend/taler-merchant-httpd_private-post-templates.c
+++ b/src/backend/taler-merchant-httpd_private-post-templates.c
@@ -124,8 +124,56 @@ TMH_private_post_templates (const struct TMH_RequestHandler *rh,
"template_contract");
}
- // FIXME: sanity check on required_currency
- // FIXME: sanity check on editable_defaults
+ if ( (NULL != tp.required_currency) &&
+ (GNUNET_OK !=
+ TALER_check_currency (tp.required_currency)) )
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "required_currency");
+ }
+ if ( (NULL != tp.required_currency) &&
+ (NULL != json_object_get (tp.template_contract,
+ "amount")) )
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "required_currency and contract::amount specified");
+ }
+ if (NULL != tp.editable_defaults)
+ {
+ const char *key;
+ json_t *val;
+
+ json_object_foreach (tp.editable_defaults, key, val)
+ {
+ if (NULL !=
+ json_object_get (tp.template_contract,
+ key))
+ {
+ char *msg;
+ MHD_RESULT ret;
+
+ GNUNET_break_op (0);
+ GNUNET_asprintf (&msg,
+ "editable_defaults::%s conflicts with template_contract",
+ key);
+ GNUNET_JSON_parse_free (spec);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ msg);
+ GNUNET_free (msg);
+ return ret;
+ }
+ }
+ }
if (NULL != tp.otp_id)
{
diff --git a/src/backend/taler-merchant-httpd_private-post-token-families.c b/src/backend/taler-merchant-httpd_private-post-token-families.c
index b9be59d8..f4472c39 100644
--- a/src/backend/taler-merchant-httpd_private-post-token-families.c
+++ b/src/backend/taler-merchant-httpd_private-post-token-families.c
@@ -195,10 +195,9 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh,
NULL,
NULL,
0)
- // TODO: Use proper error code
: TALER_MHD_reply_with_error (connection,
MHD_HTTP_CONFLICT,
- 0,
+ TALER_EC_MERCHANT_POST_TOKEN_FAMILY_CONFLICT,
details.slug);
}
} /* end switch (qs) */