diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-06-16 09:18:57 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-06-16 09:18:57 +0200 |
commit | 23f3f1aaadb448f520c45216645f160557a9658a (patch) | |
tree | 8dca188994a2677eebd186dbe86ef582de72572b /src/backend | |
parent | 629448f16c69a90cc84c72f131596aac4aea45e1 (diff) |
fix test by specifying rounding
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-token-families.c | 53 |
1 files changed, 36 insertions, 17 deletions
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 069f6b29..1fbbc44e 100644 --- a/src/backend/taler-merchant-httpd_private-post-token-families.c +++ b/src/backend/taler-merchant-httpd_private-post-token-families.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2023 Taler Systems SA + (C) 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -88,7 +88,6 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_json ("description_i18n", &details.description_i18n), NULL), - GNUNET_JSON_spec_string ("kind", &kind), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_timestamp ("valid_after", &details.valid_after), @@ -99,8 +98,12 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, &details.duration), GNUNET_JSON_spec_relative_time ("rounding", &details.rounding), + GNUNET_JSON_spec_string ("kind", + &kind), GNUNET_JSON_spec_end () }; + struct GNUNET_TIME_Timestamp now + = GNUNET_TIME_timestamp_get (); GNUNET_assert (NULL != mi); { @@ -117,15 +120,13 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, : MHD_NO; } } - - struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); - - if (no_valid_after) { + if (no_valid_after) details.valid_after = now; - } /* Ensure that valid_after is before valid_before */ - if (GNUNET_TIME_timestamp_cmp (details.valid_after, >=, details.valid_before)) + if (GNUNET_TIME_timestamp_cmp (details.valid_after, + >=, + details.valid_before)) { GNUNET_break (0); GNUNET_JSON_parse_free (spec); @@ -136,7 +137,9 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, } /* Ensure that valid_after is not in the past */ - if (GNUNET_TIME_timestamp_cmp (details.valid_after, <, now)) + if (GNUNET_TIME_timestamp_cmp (details.valid_after, + <, + now)) { GNUNET_break (0); GNUNET_JSON_parse_free (spec); @@ -146,9 +149,13 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, "valid_after"); } - if (strcmp (kind, "discount") == 0) + if (0 == + strcmp (kind, + "discount")) details.kind = TALER_MERCHANTDB_TFK_Discount; - else if (strcmp (kind, "subscription") == 0) + else if (0 == + strcmp (kind, + "subscription")) details.kind = TALER_MERCHANTDB_TFK_Subscription; else { @@ -173,17 +180,29 @@ TMH_private_post_token_families (const struct TMH_RequestHandler *rh, "description_i18n"); } - if ( GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_YEARS, !=, details.rounding) && - GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_MONTHS, !=, details.rounding) && - GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_DAYS, !=, details.rounding) && - GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_HOURS, !=, details.rounding) && - GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_MINUTES, !=, details.rounding) ) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_YEARS, + !=, + details.rounding) && + GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_MONTHS, + !=, + details.rounding) && + GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_DAYS, + !=, + details.rounding) && + GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_HOURS, + !=, + details.rounding) && + GNUNET_TIME_relative_cmp (GNUNET_TIME_UNIT_MINUTES, + !=, + details.rounding) + ) { GNUNET_break (0); GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received invalid rounding value: %s\n", - GNUNET_STRINGS_relative_time_to_string (details.rounding, GNUNET_YES)); + GNUNET_STRINGS_relative_time_to_string (details.rounding, + true)); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, |