summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_orders.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-23 23:32:53 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-23 23:32:53 -0400
commit4ce3a78d0071035a66cfb889c23fe9a9d731086f (patch)
treeadb9f8507ab6fcbbafb52ba8c3d1837d94a10e47 /src/testing/testing_api_cmd_get_orders.c
parentd34f954dcaf6d064931d47f0c90576f3b1dbf648 (diff)
downloadmerchant-4ce3a78d0071035a66cfb889c23fe9a9d731086f.tar.gz
merchant-4ce3a78d0071035a66cfb889c23fe9a9d731086f.tar.bz2
merchant-4ce3a78d0071035a66cfb889c23fe9a9d731086f.zip
deeper checks on GET /private/orders
Diffstat (limited to 'src/testing/testing_api_cmd_get_orders.c')
-rw-r--r--src/testing/testing_api_cmd_get_orders.c71
1 files changed, 66 insertions, 5 deletions
diff --git a/src/testing/testing_api_cmd_get_orders.c b/src/testing/testing_api_cmd_get_orders.c
index 93469fd0..d4073b04 100644
--- a/src/testing/testing_api_cmd_get_orders.c
+++ b/src/testing/testing_api_cmd_get_orders.c
@@ -54,6 +54,16 @@ struct GetOrdersState
*/
unsigned int http_status;
+ /**
+ * A NULL-terminated array of CMD labels that created orders.
+ */
+ const char **orders;
+
+ /**
+ * The length of @e orders.
+ */
+ unsigned int orders_length;
+
};
@@ -68,7 +78,6 @@ get_orders_cb (void *cls,
unsigned int orders_length,
const struct TALER_MERCHANT_OrderEntry orders[])
{
- /* FIXME, deeper checks should be implemented here. */
struct GetOrdersState *gos = cls;
gos->ogh = NULL;
@@ -85,8 +94,43 @@ get_orders_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gis->instance_reference here to
- // check if the data returned matches that from the POST / PATCH
+ if (orders_length != gos->orders_length)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Number of orders found does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ for (unsigned int i = 0; i < orders_length; ++i)
+ {
+ const struct TALER_TESTING_Command *order_cmd;
+
+ order_cmd = TALER_TESTING_interpreter_lookup_command (
+ gos->is,
+ gos->orders[i]);
+
+ {
+ const char *order_id;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_order_id (order_cmd,
+ 0,
+ &order_id))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch order id\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if (0 != strcmp (orders[i].order_id,
+ order_id))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Order id does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ }
+ }
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -136,7 +180,7 @@ get_orders_cleanup (void *cls,
if (NULL != gos->ogh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "GET /instances/$ID operation did not complete\n");
+ "GET /orders operation did not complete\n");
TALER_MERCHANT_orders_get_cancel (gos->ogh);
}
GNUNET_free (gos);
@@ -150,12 +194,16 @@ get_orders_cleanup (void *cls,
* @param merchant_url base URL of the merchant serving the
* GET /orders request.
* @param http_status expected HTTP response code.
+ * @param ... NULL-terminated list of labels (const char *) of
+ * reserve (commands) we expect to be returned in the list
+ * (assuming @a http_code is #MHD_HTTP_OK)
* @return the command.
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_merchant_get_orders (const char *label,
const char *merchant_url,
- unsigned int http_status)
+ unsigned int http_status,
+ ...)
{
struct GetOrdersState *gos;
@@ -163,6 +211,19 @@ TALER_TESTING_cmd_merchant_get_orders (const char *label,
gos->merchant_url = merchant_url;
gos->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 (gos->orders,
+ gos->orders_length,
+ clabel);
+ }
+ va_end (ap);
+ }
+ {
struct TALER_TESTING_Command cmd = {
.cls = gos,
.label = label,