merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 808cdfd7971a5e00a3fbd685fcd860e709b3fa5c
parent 6bce2eb4247f1fe2922c58cf08bd08a936a244af
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Tue, 18 Dec 2018 12:00:54 +0100

/history testing API.

Provide mean to request /history omitting the 'start' argument.

Diffstat:
Msrc/include/taler_merchant_testing_lib.h | 23+++++++++++++++++++++++
Msrc/lib/test_merchant_api_new.c | 9+++++++++
Msrc/lib/testing_api_cmd_history.c | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 117 insertions(+), 9 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -321,6 +321,29 @@ TALER_TESTING_cmd_refund_increase * @param time limit towards the past for the history * records we want returned. * @param nresult how many results are expected + * @param nrows how many row we want to receive, at most. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_history_default_start + (const char *label, + const char *merchant_url, + struct GNUNET_CURL_Context *ctx, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + long long nrows); + +/** + * Make a "history" command. + * + * @param label command label. + * @param merchant_url base URL of the merchant serving the + * request. + * @param ctx CURL context. + * @param http_status expected HTTP response code + * @param time limit towards the past for the history + * records we want returned. + * @param nresult how many results are expected * @param start first row id we want in the result. * @param nrows how many row we want to receive, at most. */ diff --git a/src/lib/test_merchant_api_new.c b/src/lib/test_merchant_api_new.c @@ -1071,6 +1071,15 @@ run (void *cls, TALER_TESTING_cmd_batch ("pay-abort", pay_abort), + + TALER_TESTING_cmd_history_default_start + ("history-default-start", + merchant_url, + is->ctx, + MHD_HTTP_OK, + GNUNET_TIME_UNIT_FOREVER_ABS, + 0, + -100), /** * End the suite. Fixme: better to have a label for this * too, as it shows a "(null)" token on logs. diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c @@ -285,17 +285,22 @@ history_run (void *cls, * records we want returned. * @param nresult how many results are expected * @param start first row id we want in the result. + * @param use_default_start if GNUNET_YES, then it will + * use the API call that requests /history omitting + * the 'start' argument. This makes easier to test + * the server default behaviour. * @param nrows how many row we want to receive, at most. */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_history (const char *label, - const char *merchant_url, - struct GNUNET_CURL_Context *ctx, - unsigned int http_status, - struct GNUNET_TIME_Absolute time, - unsigned int nresult, - unsigned long long start, - long long nrows) +static struct TALER_TESTING_Command +TALER_TESTING_cmd_history2 (const char *label, + const char *merchant_url, + struct GNUNET_CURL_Context *ctx, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + unsigned long long start, + int use_default_start, + long long nrows) { struct HistoryState *hs; struct TALER_TESTING_Command cmd; @@ -317,4 +322,75 @@ TALER_TESTING_cmd_history (const char *label, return cmd; } +/** + * Make a "history" command. + * + * @param label command label. + * @param merchant_url base URL of the merchant serving the + * request. + * @param ctx CURL context. + * @param http_status expected HTTP response code + * @param time limit towards the past for the history + * records we want returned. + * @param nresult how many results are expected + * @param nrows how many row we want to receive, at most. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_history_default_start + (const char *label, + const char *merchant_url, + struct GNUNET_CURL_Context *ctx, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + long long nrows) +{ + return TALER_TESTING_cmd_history2 (label, + merchant_url, + ctx, + http_status, + time, + nresult, + -1, /* ignored */ + GNUNET_YES, + nrows); +} + + +/** + * Make a "history" command. + * + * @param label command label. + * @param merchant_url base URL of the merchant serving the + * request. + * @param ctx CURL context. + * @param http_status expected HTTP response code + * @param time limit towards the past for the history + * records we want returned. + * @param nresult how many results are expected + * @param start first row id we want in the result. + * @param nrows how many row we want to receive, at most. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_history (const char *label, + const char *merchant_url, + struct GNUNET_CURL_Context *ctx, + unsigned int http_status, + struct GNUNET_TIME_Absolute time, + unsigned int nresult, + unsigned long long start, + long long nrows) +{ + return TALER_TESTING_cmd_history2 (label, + merchant_url, + ctx, + http_status, + time, + nresult, + start, + GNUNET_NO, + nrows); +} + + /* end of testing_api_cmd_history.c */