diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-16 02:18:22 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-16 02:18:22 -0400 |
commit | add99bf305d986cf14805cc99767cf665a1ccacb (patch) | |
tree | 4b14c62cce38bf0f8997c49946aa039cf2fd94d4 /src/testing | |
parent | 46fdfc6cf7001a1e158690ca30468b68ab887a02 (diff) | |
download | merchant-add99bf305d986cf14805cc99767cf665a1ccacb.tar.gz merchant-add99bf305d986cf14805cc99767cf665a1ccacb.tar.bz2 merchant-add99bf305d986cf14805cc99767cf665a1ccacb.zip |
more fixes/tests for claim order and get tips
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_merchant_api.c | 30 | ||||
-rw-r--r-- | src/testing/test_merchant_api_twisted.c | 14 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_get_tips.c | 83 |
3 files changed, 114 insertions, 13 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 90d88bf5..2b2eedd4 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 baf025d3..282d18ef 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 ae7ffb02..0ce9218a 100644 --- a/src/testing/testing_api_cmd_get_tips.c +++ b/src/testing/testing_api_cmd_get_tips.c @@ -50,6 +50,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. */ unsigned int http_status; @@ -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; |