diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_get_reserve.c | 3 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_merchant_get_order.c | 87 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_merchant_get_tip.c | 3 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_pay_order.c | 3 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_wallet_get_order.c | 95 |
5 files changed, 68 insertions, 123 deletions
diff --git a/src/testing/testing_api_cmd_get_reserve.c b/src/testing/testing_api_cmd_get_reserve.c index 03b6a071..ef7f67e0 100644 --- a/src/testing/testing_api_cmd_get_reserve.c +++ b/src/testing/testing_api_cmd_get_reserve.c @@ -83,7 +83,6 @@ get_reserve_cb (void *cls, unsigned int tips_length, const struct TALER_MERCHANT_TipDetails tips[]) { - /* FIXME, deeper checks should be implemented here. */ struct GetReserveState *grs = cls; const struct TALER_TESTING_Command *reserve_cmd; @@ -105,8 +104,6 @@ get_reserve_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - // FIXME: use grs->reserve_reference here to - // check if the data returned matches that from the POST / PATCH { const struct TALER_Amount *initial_amount; if (GNUNET_OK != diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c index 85ba174f..8001ac43 100644 --- a/src/testing/testing_api_cmd_merchant_get_order.c +++ b/src/testing/testing_api_cmd_merchant_get_order.c @@ -130,45 +130,40 @@ apply_forget (void *cls, * Callback to process a GET /orders/$ID request * * @param cls closure - * @param hr HTTP response details - * @param osr order status response details (on success) + * @param osr order status response details */ static void merchant_get_order_cb ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, const struct TALER_MERCHANT_OrderStatusResponse *osr) { - /* FIXME, deeper checks should be implemented here. */ struct MerchantGetOrderState *gos = cls; gos->ogh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GET /private/orders/$ID completed with status %u\n", - hr->http_status); - if (gos->http_status != hr->http_status) + osr->hr.http_status); + if (gos->http_status != osr->hr.http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u (%d) to command %s\n", - hr->http_status, - (int) hr->ec, + osr->hr.http_status, + (int) osr->hr.ec, TALER_TESTING_interpreter_get_current_label (gos->is)); TALER_TESTING_interpreter_fail (gos->is); return; } - switch (hr->http_status) + switch (osr->hr.http_status) { case MHD_HTTP_OK: - // FIXME: use gts->tip_reference here to - // check if the data returned matches that from the POST / PATCH - if (gos->osc != osr->status) + if (gos->osc != osr->details.success.status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order paid does not match\n"); TALER_TESTING_interpreter_fail (gos->is); return; } - switch (osr->status) + switch (osr->details.success.status) { case TALER_MERCHANT_OSC_PAID: { @@ -241,7 +236,7 @@ merchant_get_order_cb ( } if (1 != json_equal (ct, - osr->details.paid.contract_terms)) + osr->details.success.details.paid.contract_terms)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order contract terms do not match\n"); @@ -251,14 +246,14 @@ merchant_get_order_cb ( json_decref (ct); } - if (gos->wired != osr->details.paid.wired) + if (gos->wired != osr->details.success.details.paid.wired) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order wired does not match\n"); TALER_TESTING_interpreter_fail (gos->is); return; } - if (gos->transfers_length != osr->details.paid.wts_len) + if (gos->transfers_length != osr->details.success.details.paid.wts_len) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Number of transfers found does not match\n"); @@ -285,7 +280,8 @@ merchant_get_order_cb ( return; } if (0 != GNUNET_memcmp (wtid, - &osr->details.paid.wts[i].wtid)) + &osr->details.success.details.paid.wts[i]. + wtid)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer id does not match\n"); @@ -306,7 +302,8 @@ merchant_get_order_cb ( return; } if (0 != strcmp (*exchange_url, - osr->details.paid.wts[i].exchange_url)) + osr->details.success.details.paid.wts[i]. + exchange_url)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer exchange url does not match\n"); @@ -340,12 +337,13 @@ merchant_get_order_cb ( TALER_TESTING_interpreter_fail (gos->is); return; } - if ((GNUNET_OK != TALER_amount_cmp_currency (&transfer_total, - &osr->details.paid.wts[ - i] - .total_amount)) || - (0 != TALER_amount_cmp (&transfer_total, - &osr->details.paid.wts[i].total_amount))) + if ((GNUNET_OK != + TALER_amount_cmp_currency ( + &transfer_total, + &osr->details.success.details.paid.wts[i].total_amount)) || + (0 != TALER_amount_cmp ( + &transfer_total, + &osr->details.success.details.paid.wts[i].total_amount))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer total does not match\n"); @@ -354,14 +352,15 @@ merchant_get_order_cb ( } } } - if (gos->refunded != osr->details.paid.refunded) + if (gos->refunded != osr->details.success.details.paid.refunded) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order refunded does not match\n"); TALER_TESTING_interpreter_fail (gos->is); return; } - if (gos->refunds_length != osr->details.paid.refunds_len) + if (gos->refunds_length != + osr->details.success.details.paid.refunds_len) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Number of refunds found does not match\n"); @@ -369,10 +368,11 @@ merchant_get_order_cb ( return; } if (0 < gos->refunds_length) - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero ( - osr->details.paid.refund_amount.currency, - &refunded_total)); + GNUNET_assert ( + GNUNET_OK == + TALER_amount_set_zero ( + osr->details.success.details.paid.refund_amount.currency, + &refunded_total)); for (unsigned int i = 0; i < gos->refunds_length; ++i) { const struct TALER_TESTING_Command *refund_cmd; @@ -383,7 +383,7 @@ merchant_get_order_cb ( { const struct TALER_Amount *expected_amount; struct TALER_Amount *amount_found = - &osr->details.paid.refunds[i].refund_amount; + &osr->details.success.details.paid.refunds[i].refund_amount; if (GNUNET_OK != TALER_TESTING_get_trait_amount (refund_cmd, @@ -421,8 +421,9 @@ merchant_get_order_cb ( TALER_TESTING_interpreter_fail (gos->is); return; } - if (0 != strcmp (*expected_reason, - osr->details.paid.refunds[i].reason)) + if (0 != strcmp ( + *expected_reason, + osr->details.success.details.paid.refunds[i].reason)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Refund reason does not match\n"); @@ -432,7 +433,7 @@ merchant_get_order_cb ( } } - if (gos->wired != osr->details.paid.wired) + if (gos->wired != osr->details.success.details.paid.wired) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order wired does not match\n"); @@ -446,19 +447,19 @@ merchant_get_order_cb ( break; case TALER_MERCHANT_OSC_UNPAID: { - /* FIXME: Check all of the members of `pud` */ struct TALER_MERCHANT_PayUriData pud; const struct TALER_TESTING_Command *order_cmd; const char **order_id; const struct TALER_ClaimTokenP *claim_token; if (GNUNET_OK != - TALER_MERCHANT_parse_pay_uri (osr->details.unpaid.taler_pay_uri, - &pud)) + TALER_MERCHANT_parse_pay_uri ( + osr->details.success.details.unpaid.taler_pay_uri, + &pud)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Taler pay uri `%s' is malformed\n", - osr->details.unpaid.taler_pay_uri); + osr->details.success.details.unpaid.taler_pay_uri); TALER_TESTING_interpreter_fail (gos->is); return; } @@ -511,7 +512,7 @@ merchant_get_order_cb ( { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order pay uri `%s' does not match, wanted %s/%s\n", - osr->details.unpaid.taler_pay_uri, + osr->details.success.details.unpaid.taler_pay_uri, host, *order_id); TALER_TESTING_interpreter_fail (gos->is); @@ -541,8 +542,8 @@ merchant_get_order_cb ( return; } TALER_MERCHANT_parse_pay_uri_free (&pud); + break; } - break; } break; default: @@ -860,17 +861,15 @@ conclude_task (void *cls) * Callback to process a GET /private/orders/$ID request * * @param cls closure - * @param hr HTTP response details - * @param osr order status response details (on success) + * @param osr order status response details */ static void merchant_poll_order_cb ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, const struct TALER_MERCHANT_OrderStatusResponse *osr) { - /* FIXME, deeper checks should be implemented here. */ struct MerchantPollOrderStartState *pos = cls; + const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr; pos->ogh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, diff --git a/src/testing/testing_api_cmd_merchant_get_tip.c b/src/testing/testing_api_cmd_merchant_get_tip.c index a4841da1..1ea5229d 100644 --- a/src/testing/testing_api_cmd_merchant_get_tip.c +++ b/src/testing/testing_api_cmd_merchant_get_tip.c @@ -99,7 +99,6 @@ merchant_get_tip_cb (void *cls, unsigned int pickups_length, const struct TALER_MERCHANT_PickupDetail pickups[]) { - /* FIXME, deeper checks should be implemented here. */ struct MerchantTipGetState *gts = cls; const struct TALER_TESTING_Command *authorize_cmd; struct TALER_Amount expected_total_picked_up; @@ -124,8 +123,6 @@ merchant_get_tip_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - // FIXME: use gts->tip_reference here to - // check if the data returned matches that from the POST / PATCH { const struct TALER_Amount *initial_amount; diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index 61a43b9e..cd589965 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -306,8 +306,7 @@ pay_run (void *cls, &total_amount), TALER_JSON_spec_amount_any ("max_fee", &max_fee), - /* FIXME oec - * add minimum age */ + /* FIXME oec: parse minimum age, use data later? */ GNUNET_JSON_spec_end () }; diff --git a/src/testing/testing_api_cmd_wallet_get_order.c b/src/testing/testing_api_cmd_wallet_get_order.c index f9e89d63..771dc6f8 100644 --- a/src/testing/testing_api_cmd_wallet_get_order.c +++ b/src/testing/testing_api_cmd_wallet_get_order.c @@ -79,37 +79,15 @@ struct WalletGetOrderState * Callback to process a GET /orders/$ID request * * @param cls closure - * @param hr HTTP response details - * @param paid #GNUNET_YES if the payment is settled, #GNUNET_NO if not - * settled, #GNUNET_SYSERR on error - * (note that refunded payments are returned as paid!) - * @param refunded #GNUNET_YES if there is at least on refund on this payment, - * #GNUNET_NO if refunded, #GNUNET_SYSERR or error - * @param refund_pending #GNUNET_YES if there are refunds waiting to be - * obtained, #GNUNET_NO if all refunds have been obtained, #GNUNET_SYSERR - * on error. - * @param refund_amount amount that was refunded, NULL if there - * was no refund - * @param taler_pay_uri the URI that instructs the wallets to process - * the payment - * @param already_paid_order_id equivalent order that this customer - * paid already, or NULL for none + * @param owgr response details */ static void wallet_get_order_cb ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - enum GNUNET_GenericReturnValue paid, - enum GNUNET_GenericReturnValue refunded, - enum GNUNET_GenericReturnValue refund_pending, - struct TALER_Amount *refund_amount, - const char *taler_pay_uri, - const char *already_paid_order_id) + const struct TALER_MERCHANT_OrderWalletGetResponse *owgr) { struct WalletGetOrderState *gos = cls; - bool paid_b = (paid == GNUNET_YES); - bool refunded_b = (refunded == GNUNET_YES); - bool refund_pending_b = (refund_pending == GNUNET_YES); + const struct TALER_MERCHANT_HttpResponse *hr = &owgr->hr; gos->ogh = NULL; if (gos->http_status != hr->http_status) @@ -125,44 +103,36 @@ wallet_get_order_cb ( switch (hr->http_status) { case MHD_HTTP_OK: - // FIXME: use gos->order_reference here to - // check if the data returned matches that from the POST / PATCH - if (gos->paid != paid_b) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Order paid does not match\n"); - TALER_TESTING_interpreter_fail (gos->is); - return; - } - if (gos->refunded != refunded_b) + if (gos->refunded != owgr->details.success.refunded) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order refunded does not match\n"); TALER_TESTING_interpreter_fail (gos->is); return; } - if (gos->refund_pending != refund_pending_b) + if (gos->refund_pending != owgr->details.success.refund_pending) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order refund pending does not match\n"); TALER_TESTING_interpreter_fail (gos->is); return; } - if (! paid_b) + break; + case MHD_HTTP_PAYMENT_REQUIRED: { - /* FIXME: Check all of the members of `pud` */ struct TALER_MERCHANT_PayUriData pud; const struct TALER_TESTING_Command *order_cmd; const char **order_id; const struct TALER_ClaimTokenP *claim_token; if (GNUNET_OK != - TALER_MERCHANT_parse_pay_uri (taler_pay_uri, - &pud)) + TALER_MERCHANT_parse_pay_uri ( + owgr->details.payment_required.taler_pay_uri, + &pud)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Taler pay uri `%s' is malformed\n", - taler_pay_uri); + owgr->details.payment_required.taler_pay_uri); TALER_TESTING_interpreter_fail (gos->is); return; } @@ -216,7 +186,7 @@ wallet_get_order_cb ( { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Order pay uri `%s' does not match `%s'\n", - taler_pay_uri, + owgr->details.payment_required.taler_pay_uri, pud.order_id); TALER_TESTING_interpreter_fail (gos->is); TALER_MERCHANT_parse_pay_uri_free (&pud); @@ -565,34 +535,15 @@ conclude_task (void *cls) * Process response from a GET /orders/$ID request * * @param cls a `struct WalletPollOrderStartState *` - * @param hr HTTP response details - * @param paid #GNUNET_YES if the payment is settled, #GNUNET_NO if not - * settled, #GNUNET_SYSERR on error - * (note that refunded payments are returned as paid!) - * @param refunded #GNUNET_YES if there is at least on refund on this payment, - * #GNUNET_NO if refunded, #GNUNET_SYSERR or error - * @param refund_pending #GNUNET_YES if there are refunds waiting to be - * obtained, #GNUNET_NO if all refunds have been obtained, #GNUNET_SYSERR - * on error. - * @param refund_amount amount that was refunded, NULL if there - * was no refund - * @param taler_pay_uri the URI that instructs the wallets to process - * the payment - * @param already_paid_order_id equivalent order that this customer - * paid already, or NULL for none + * @param owgr response details */ static void wallet_poll_order_cb ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - enum GNUNET_GenericReturnValue paid, - enum GNUNET_GenericReturnValue refunded, - enum GNUNET_GenericReturnValue refund_pending, - struct TALER_Amount *refund_amount, - const char *taler_pay_uri, - const char *already_paid_order_id) + const struct TALER_MERCHANT_OrderWalletGetResponse *owgr) { struct WalletPollOrderStartState *pos = cls; + const struct TALER_MERCHANT_HttpResponse *hr = &owgr->hr; pos->ogh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -602,13 +553,15 @@ wallet_poll_order_cb ( switch (hr->http_status) { case MHD_HTTP_OK: - pos->paid = (GNUNET_YES == paid); - pos->refunded = (GNUNET_YES == refunded); - pos->refund_pending = (GNUNET_YES == refund_pending); - if (NULL != refund_amount) - pos->refund_available = *refund_amount; - if (NULL != already_paid_order_id) - pos->already_paid_order_id = GNUNET_strdup (already_paid_order_id); + pos->paid = true; + pos->refunded = owgr->details.success.refunded; + pos->refund_pending = owgr->details.success.refund_pending; + if (owgr->details.success.refunded) + pos->refund_available = owgr->details.success.refund_amount; + break; + case MHD_HTTP_PAYMENT_REQUIRED: + pos->already_paid_order_id = GNUNET_strdup ( + owgr->details.payment_required.already_paid_order_id); break; default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |