From 35c77313481a6566bdc10d8633a501c6f3925830 Mon Sep 17 00:00:00 2001 From: MS Date: Thu, 16 Jul 2020 18:23:09 +0200 Subject: Triggering bug in test cases. This bug appears when a order gets created, and after requested via the GET /private/orders/$ID API. Instead of informing the client about the unpaid status of such order, the merchant backend responds with a 404. --- src/testing/test_merchant_api.c | 28 +++++++++++++++ src/testing/testing_api_cmd_post_orders.c | 60 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) (limited to 'src/testing') diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 2b2eedd4..2d9e9266 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -166,6 +166,32 @@ run (void *cls, "post-transfer-1", NULL }; + + struct TALER_TESTING_Command get_private_order_id[] = { + + TALER_TESTING_cmd_merchant_post_instances ("instance-create-default", + merchant_url, + "default", + PAYTO_I1, + "EUR", + MHD_HTTP_NO_CONTENT), + + TALER_TESTING_cmd_merchant_post_orders_no_claim ("create-proposal-4", + merchant_url, + MHD_HTTP_OK, + "1", + GNUNET_TIME_UNIT_ZERO_ABS, + GNUNET_TIME_UNIT_FOREVER_ABS, + "EUR:5.0"), + TALER_TESTING_cmd_merchant_get_order ("get-order-4", + merchant_url, + "create-proposal-4", + false, + false, + MHD_HTTP_OK), + TALER_TESTING_cmd_end () + }; + struct TALER_TESTING_Command pay[] = { /** * Move money to the exchange's bank account. @@ -945,6 +971,8 @@ run (void *cls, inactivation. */ }; struct TALER_TESTING_Command commands[] = { + TALER_TESTING_cmd_batch ("orders-id", + get_private_order_id), TALER_TESTING_cmd_config ("config", merchant_url, MHD_HTTP_OK), diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c index 3a489026..8ae0babc 100644 --- a/src/testing/testing_api_cmd_post_orders.c +++ b/src/testing/testing_api_cmd_post_orders.c @@ -111,9 +111,15 @@ struct OrdersState * The locks that the order should release. */ const char *locks; + + /** + * Should the command also CLAIM the order? + */ + bool with_claim; }; + /** * Offer internal data to other commands. * @@ -264,6 +270,11 @@ order_cb (void *cls, return; } + if (false == ps->with_claim) + { + TALER_TESTING_interpreter_next (ps->is); + return; + } if (NULL == (ps->och = TALER_MERCHANT_order_claim (ps->is->ctx, ps->merchant_url, @@ -567,6 +578,54 @@ make_order_json (const char *order_id, amount); } +/** + * Make the "proposal" command AVOIDING claiming the order. + * + * @param label command label + * @param merchant_url base URL of the merchant serving + * the proposal request. + * @param http_status expected HTTP status. + * @param order_id the name of the order to add. + * @param refund_deadline the deadline for refunds on this order. + * @param pay_deadline the deadline for payment on this order. + * @param amount the amount this order is for. + * @return the command + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_post_orders_no_claim (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *order_id, + struct GNUNET_TIME_Absolute + refund_deadline, + struct GNUNET_TIME_Absolute + pay_deadline, + const char *amount) +{ + struct OrdersState *ps; + + ps = GNUNET_new (struct OrdersState); + make_order_json (order_id, + refund_deadline, + pay_deadline, + amount, + &ps->order); + ps->http_status = http_status; + ps->merchant_url = merchant_url; + ps->with_claim = false; + { + struct TALER_TESTING_Command cmd = { + .cls = ps, + .label = label, + .run = &orders_run, + .cleanup = &orders_cleanup, + .traits = &orders_traits + }; + + return cmd; + } +} + /** * Make the "proposal" command. @@ -602,6 +661,7 @@ TALER_TESTING_cmd_merchant_post_orders (const char *label, &ps->order); ps->http_status = http_status; ps->merchant_url = merchant_url; + ps->with_claim = true; { struct TALER_TESTING_Command cmd = { .cls = ps, -- cgit v1.2.3