[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: more fixes/tests for claim order
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: more fixes/tests for claim order and get tips |
Date: |
Thu, 16 Jul 2020 08:18:35 +0200 |
This is an automated email from the git hooks/post-receive script.
jonathan-buchanan pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new add99bf more fixes/tests for claim order and get tips
add99bf is described below
commit add99bf305d986cf14805cc99767cf665a1ccacb
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Thu Jul 16 02:18:22 2020 -0400
more fixes/tests for claim order and get tips
---
.../taler-merchant-httpd_post-orders-ID-claim.c | 2 +-
.../taler-merchant-httpd_private-get-tips.c | 51 ++++++-------
src/include/taler_merchant_testing_lib.h | 23 ++++++
src/testing/test_merchant_api.c | 30 ++++++++
src/testing/test_merchant_api_twisted.c | 14 ++--
src/testing/testing_api_cmd_get_tips.c | 83 +++++++++++++++++++---
6 files changed, 165 insertions(+), 38 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
index b1c1522..e7d0c84 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
@@ -69,8 +69,8 @@ claim_order (const char *instance_id,
uint64_t order_serial;
qs = TMH_db->lookup_contract_terms (TMH_db->cls,
- order_id,
instance_id,
+ order_id,
contract_terms,
&order_serial);
}
diff --git a/src/backend/taler-merchant-httpd_private-get-tips.c
b/src/backend/taler-merchant-httpd_private-get-tips.c
index 8aff670..47fe305 100644
--- a/src/backend/taler-merchant-httpd_private-get-tips.c
+++ b/src/backend/taler-merchant-httpd_private-get-tips.c
@@ -80,57 +80,60 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh,
TALER_EC_PARAMETER_MALFORMED,
"expired");
{
- const char *offset_str;
+ const char *limit_str;
- offset_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "offset");
- if (NULL == offset_str)
+ limit_str = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "limit");
+ if (NULL == limit_str)
{
- offset = INT64_MAX;
+ limit = -20;
}
else
{
char dummy[2];
- unsigned long long ull;
+ long long ll;
if (1 !=
- sscanf (offset_str,
- "%llu%1s",
- &ull,
+ sscanf (limit_str,
+ "%lld%1s",
+ &ll,
dummy))
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
- "date");
- offset = (uint64_t) ull;
+ "limit");
+ limit = (uint64_t) ll;
}
}
{
- const char *limit_str;
+ const char *offset_str;
- limit_str = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "limit");
- if (NULL == limit_str)
+ offset_str = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "offset");
+ if (NULL == offset_str)
{
- limit = -20;
+ if (limit > 0)
+ offset = 0;
+ else
+ offset = INT64_MAX;
}
else
{
char dummy[2];
- long long ll;
+ unsigned long long ull;
if (1 !=
- sscanf (limit_str,
- "%lld%1s",
- &ll,
+ sscanf (offset_str,
+ "%llu%1s",
+ &ull,
dummy))
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_PARAMETER_MALFORMED,
- "limit");
- limit = (uint64_t) ll;
+ "offset");
+ offset = (uint64_t) ull;
}
}
diff --git a/src/include/taler_merchant_testing_lib.h
b/src/include/taler_merchant_testing_lib.h
index d545306..41acf8b 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -955,6 +955,29 @@ TALER_TESTING_cmd_get_tips (const char *label,
...);
+/**
+ * Define a get tips CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * server the /tip-query request.
+ * @param http_status expected HTTP response code for the
+ * /tip-query request.
+ * @param offset row to start querying the database from.
+ * @param limit how many rows to return (with direction).
+ * @param ... NULL-terminated list of labels (const char *) of
+ * tip (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_get_tips2 (const char *label,
+ const char *merchant_url,
+ uint64_t offset,
+ int64_t limit,
+ unsigned int http_status,
+ ...);
+
+
/**
* Define a GET /private/tips/$TIP_ID CMD.
*
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 90d88bf..2b2eedd 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -209,6 +209,11 @@ run (void *cls,
TALER_TESTING_cmd_poll_orders_start ("poll-orders-1-start",
merchant_url,
GNUNET_TIME_UNIT_MINUTES),
+ TALER_TESTING_cmd_merchant_claim_order ("claim-order-nx",
+ merchant_url,
+ MHD_HTTP_NOT_FOUND,
+ NULL,
+ "1"),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1",
merchant_url,
MHD_HTTP_OK,
@@ -216,6 +221,16 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_FOREVER_ABS,
"EUR:5.0"),
+ TALER_TESTING_cmd_merchant_claim_order ("reclaim-1",
+ merchant_url,
+ MHD_HTTP_OK,
+ "create-proposal-1",
+ NULL),
+ TALER_TESTING_cmd_merchant_claim_order ("reclaim-1-bad-nonce",
+ merchant_url,
+ MHD_HTTP_CONFLICT,
+ NULL,
+ "1"),
TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1-pre-exists",
merchant_url,
MHD_HTTP_BAD_REQUEST,
@@ -656,6 +671,21 @@ run (void *cls,
"authorize-tip-2",
"authorize-tip-1",
NULL),
+ TALER_TESTING_cmd_get_tips2 ("get-tips-1-asc",
+ merchant_url,
+ 0,
+ 20,
+ MHD_HTTP_OK,
+ "authorize-tip-1",
+ "authorize-tip-2",
+ NULL),
+ TALER_TESTING_cmd_get_tips2 ("get-tips-1-asc-offset",
+ merchant_url,
+ 1,
+ 20,
+ MHD_HTTP_OK,
+ "authorize-tip-2",
+ NULL),
TALER_TESTING_cmd_merchant_get_reserves ("get-reserves-1",
merchant_url,
MHD_HTTP_OK,
diff --git a/src/testing/test_merchant_api_twisted.c
b/src/testing/test_merchant_api_twisted.c
index baf025d..282d18e 100644
--- a/src/testing/test_merchant_api_twisted.c
+++ b/src/testing/test_merchant_api_twisted.c
@@ -357,16 +357,20 @@ run (void *cls,
"1",
GNUNET_TIME_UNIT_ZERO_ABS,
GNUNET_TIME_UNIT_FOREVER_ABS,
- "EUR:5.0"),
- TALER_TESTING_cmd_malform_response ("malform-exchange-reponse-1",
- PROXY_EXCHANGE_CONFIG_FILE),
- TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
+ "EUR:6.0"),
+ TALER_TESTING_cmd_merchant_pay_order ("deposit-1",
merchant_url,
- MHD_HTTP_FAILED_DEPENDENCY,
+ MHD_HTTP_NOT_ACCEPTABLE,
"create-proposal-1",
"withdraw-coin-1",
"EUR:5",
"EUR:4.99"),
+ TALER_TESTING_cmd_malform_response ("malform-abort-merchant-exchange",
+ PROXY_EXCHANGE_CONFIG_FILE),
+ TALER_TESTING_cmd_merchant_order_abort ("pay-abort-1",
+ merchant_url,
+ "deposit-1",
+ MHD_HTTP_INTERNAL_SERVER_ERROR),
TALER_TESTING_cmd_end ()
};
diff --git a/src/testing/testing_api_cmd_get_tips.c
b/src/testing/testing_api_cmd_get_tips.c
index ae7ffb0..0ce9218 100644
--- a/src/testing/testing_api_cmd_get_tips.c
+++ b/src/testing/testing_api_cmd_get_tips.c
@@ -49,6 +49,16 @@ struct GetTipsState
*/
const char *merchant_url;
+ /**
+ * Row to start querying the database from.
+ */
+ uint64_t offset;
+
+ /**
+ * How many rows to return (with direction).
+ */
+ int64_t limit;
+
/**
* Expected HTTP response code.
*/
@@ -60,7 +70,7 @@ struct GetTipsState
unsigned int tips_length;
/**
- *
+ * References to tips that we expect to be found.
*/
const char **tips;
@@ -80,7 +90,6 @@ get_tips_cb (void *cls,
unsigned int tips_length,
const struct TALER_MERCHANT_TipEntry tips[])
{
- /* FIXME, deeper checks should be implemented here. */
struct GetTipsState *gts = cls;
gts->tgh = NULL;
@@ -97,8 +106,6 @@ get_tips_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gis->product_reference here to
- // check if the data returned matches that from the POST / PATCH
if (tips_length != gts->tips_length)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -184,10 +191,13 @@ get_tips_run (void *cls,
struct GetTipsState *gts = cls;
gts->is = is;
- gts->tgh = TALER_MERCHANT_tips_get (is->ctx,
- gts->merchant_url,
- &get_tips_cb,
- gts);
+ gts->tgh = TALER_MERCHANT_tips_get2 (is->ctx,
+ gts->merchant_url,
+ TALER_EXCHANGE_YNA_NO,
+ gts->limit,
+ gts->offset,
+ &get_tips_cb,
+ gts);
GNUNET_assert (NULL != gts->tgh);
}
@@ -238,6 +248,63 @@ TALER_TESTING_cmd_get_tips (const char *label,
gts = GNUNET_new (struct GetTipsState);
gts->merchant_url = merchant_url;
+ gts->offset = INT64_MAX;
+ gts->limit = -20;
+ gts->http_status = http_status;
+ {
+ const char *clabel;
+ va_list ap;
+
+ va_start (ap, http_status);
+ while (NULL != (clabel = va_arg (ap, const char *)))
+ {
+ GNUNET_array_append (gts->tips,
+ gts->tips_length,
+ clabel);
+ }
+ va_end (ap);
+ }
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gts,
+ .label = label,
+ .run = &get_tips_run,
+ .cleanup = &get_tips_cleanup
+ };
+
+ return cmd;
+ }
+}
+
+
+/**
+ * Define a get tips CMD.
+ *
+ * @param label the command label
+ * @param merchant_url base URL of the merchant which will
+ * server the /tip-query request.
+ * @param http_status expected HTTP response code for the
+ * /tip-query request.
+ * @param offset row to start querying the database from.
+ * @param limit how many rows to return (with direction).
+ * @param ... NULL-terminated list of labels (const char *) of
+ * tip (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_get_tips2 (const char *label,
+ const char *merchant_url,
+ uint64_t offset,
+ int64_t limit,
+ unsigned int http_status,
+ ...)
+{
+ struct GetTipsState *gts;
+
+ gts = GNUNET_new (struct GetTipsState);
+ gts->merchant_url = merchant_url;
+ gts->offset = offset;
+ gts->limit = limit;
gts->http_status = http_status;
{
const char *clabel;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: more fixes/tests for claim order and get tips,
gnunet <=