diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-07-10 10:22:29 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-07-10 10:22:29 +0200 |
commit | 9d706a01a23e36e1c349d06e7a1be8bb44b7f0d5 (patch) | |
tree | 1ac7596f8921d476c5e0e9d7dfc64e28a6b64161 | |
parent | 7e9f5324b719338d790a5eb18c209469d33c708a (diff) |
added expected HTTP-code to logger
37 files changed, 111 insertions, 42 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 332c3a34..8767ee89 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -57,18 +57,44 @@ * * @param is interpreter to fail * @param status unexpected HTTP status code received + * @param expected expected HTTP status code */ -#define TALER_TESTING_unexpected_status(is,status) \ +#define TALER_TESTING_unexpected_status(is,status, expected) \ do { \ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Unexpected response code %u to command %s in %s:%u\n", \ + "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \ status, \ + expected, \ TALER_TESTING_interpreter_get_current_label (is), \ __FILE__, \ __LINE__); \ TALER_TESTING_interpreter_fail (is); \ } while (0) +/** + * Log an error message about us receiving an unexpected HTTP + * status code at the current command and fail the test and print the response + * body (expected as json). + * + * @param is interpreter to fail + * @param status unexpected HTTP status code received + * @param expected expected HTTP status code + * @param body received JSON-reply + */ +#define TALER_TESTING_unexpected_status_with_body(is,status, expected, body) \ + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to " \ + "command %s in %s:%u\nwith body:\n>>%s<<\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__, \ + json_dumps (body, JSON_INDENT (2))); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) + /** * Log an error message about a command not having diff --git a/src/testing/testing_api_cmd_auditor_add.c b/src/testing/testing_api_cmd_auditor_add.c index aaa95552..ac9c2c8f 100644 --- a/src/testing/testing_api_cmd_auditor_add.c +++ b/src/testing/testing_api_cmd_auditor_add.c @@ -76,7 +76,8 @@ auditor_add_cb ( if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_auditor_add_denom_sig.c b/src/testing/testing_api_cmd_auditor_add_denom_sig.c index 2df15fde..6b777689 100644 --- a/src/testing/testing_api_cmd_auditor_add_denom_sig.c +++ b/src/testing/testing_api_cmd_auditor_add_denom_sig.c @@ -81,7 +81,8 @@ denom_sig_add_cb ( if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_auditor_del.c b/src/testing/testing_api_cmd_auditor_del.c index df878f8e..8256bc1c 100644 --- a/src/testing/testing_api_cmd_auditor_del.c +++ b/src/testing/testing_api_cmd_auditor_del.c @@ -77,7 +77,8 @@ auditor_del_cb ( if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c index 252e8f52..1e5a6344 100644 --- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c +++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c @@ -170,7 +170,8 @@ deposit_confirmation_cb ( } } TALER_TESTING_unexpected_status (dcs->is, - hr->http_status); + hr->http_status, + dcs->expected_response_code); return; } TALER_TESTING_interpreter_next (dcs->is); diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c b/src/testing/testing_api_cmd_auditor_exchanges.c index aa9a1bfb..29d3726a 100644 --- a/src/testing/testing_api_cmd_auditor_exchanges.c +++ b/src/testing/testing_api_cmd_auditor_exchanges.c @@ -160,7 +160,8 @@ exchanges_cb (void *cls, } } TALER_TESTING_unexpected_status (es->is, - hr->http_status); + hr->http_status, + es->expected_response_code); return; } if (MHD_HTTP_OK != hr->http_status) diff --git a/src/testing/testing_api_cmd_bank_transfer.c b/src/testing/testing_api_cmd_bank_transfer.c index 7b9d588c..bfb29e12 100644 --- a/src/testing/testing_api_cmd_bank_transfer.c +++ b/src/testing/testing_api_cmd_bank_transfer.c @@ -199,7 +199,8 @@ confirmation_cb (void *cls, } } TALER_TESTING_unexpected_status (is, - tr->http_status); + tr->http_status, + MHD_HTTP_OK); return; } diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index 0a4fbd25..77bfd4d5 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -199,7 +199,8 @@ batch_deposit_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } if (MHD_HTTP_OK == dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c index 7f680949..184e02bf 100644 --- a/src/testing/testing_api_cmd_batch_withdraw.c +++ b/src/testing/testing_api_cmd_batch_withdraw.c @@ -190,7 +190,8 @@ reserve_batch_withdraw_cb (void *cls, if (ws->expected_response_code != wr->hr.http_status) { TALER_TESTING_unexpected_status (is, - wr->hr.http_status); + wr->hr.http_status, + ws->expected_response_code); return; } switch (wr->hr.http_status) diff --git a/src/testing/testing_api_cmd_check_aml_decision.c b/src/testing/testing_api_cmd_check_aml_decision.c index 1f0ada7b..fa0981e0 100644 --- a/src/testing/testing_api_cmd_check_aml_decision.c +++ b/src/testing/testing_api_cmd_check_aml_decision.c @@ -80,7 +80,8 @@ check_aml_decision_cb (void *cls, if (ds->expected_http_status != adr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - adr->hr.http_status); + adr->hr.http_status, + ds->expected_http_status); return; } if (MHD_HTTP_OK == adr->hr.http_status) diff --git a/src/testing/testing_api_cmd_check_aml_decisions.c b/src/testing/testing_api_cmd_check_aml_decisions.c index 4d206485..c8c2ec3f 100644 --- a/src/testing/testing_api_cmd_check_aml_decisions.c +++ b/src/testing/testing_api_cmd_check_aml_decisions.c @@ -80,7 +80,8 @@ check_aml_decisions_cb (void *cls, if (ds->expected_http_status != adr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - adr->hr.http_status); + adr->hr.http_status, + ds->expected_http_status); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_check_keys.c b/src/testing/testing_api_cmd_check_keys.c index 0097725c..e483424c 100644 --- a/src/testing/testing_api_cmd_check_keys.c +++ b/src/testing/testing_api_cmd_check_keys.c @@ -77,7 +77,8 @@ keys_cb (void *cls, if (MHD_HTTP_OK != kr->hr.http_status) { TALER_TESTING_unexpected_status (cks->is, - kr->hr.http_status); + kr->hr.http_status, + MHD_HTTP_OK); return; } cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date; diff --git a/src/testing/testing_api_cmd_contract_get.c b/src/testing/testing_api_cmd_contract_get.c index 902ec4a4..fa83d83f 100644 --- a/src/testing/testing_api_cmd_contract_get.c +++ b/src/testing/testing_api_cmd_contract_get.c @@ -102,7 +102,8 @@ get_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } ref = TALER_TESTING_interpreter_lookup_command (ds->is, diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index f2a3a269..2fa0141f 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -248,8 +248,12 @@ deposit_cb (void *cls, return; } } - TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + TALER_TESTING_unexpected_status_with_body ( + ds->is, + dr->hr.http_status, + ds->expected_response_code, + dr->hr.reply); + return; } if (MHD_HTTP_OK == dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 165af9b1..5d4436e2 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -117,7 +117,8 @@ deposit_wtid_cb (void *cls, if (tts->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (is, - dr->hr.http_status); + dr->hr.http_status, + tts->expected_response_code); return; } switch (dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_get_auditor.c b/src/testing/testing_api_cmd_get_auditor.c index e1ae8ba5..ab4e3266 100644 --- a/src/testing/testing_api_cmd_get_auditor.c +++ b/src/testing/testing_api_cmd_get_auditor.c @@ -83,7 +83,8 @@ version_cb ( if (MHD_HTTP_OK != vr->hr.http_status) { TALER_TESTING_unexpected_status (gas->is, - vr->hr.http_status); + vr->hr.http_status, + MHD_HTTP_OK); return; } if ( (NULL != gas->priv_file) && diff --git a/src/testing/testing_api_cmd_kyc_check_get.c b/src/testing/testing_api_cmd_kyc_check_get.c index bbbd9214..25c7e98b 100644 --- a/src/testing/testing_api_cmd_kyc_check_get.c +++ b/src/testing/testing_api_cmd_kyc_check_get.c @@ -78,7 +78,8 @@ check_kyc_cb (void *cls, if (kcg->expected_response_code != ks->http_status) { TALER_TESTING_unexpected_status (is, - ks->http_status); + ks->http_status, + kcg->expected_response_code); return; } switch (ks->http_status) diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index c0fe7495..b079fffc 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -88,7 +88,8 @@ proof_kyc_cb (void *cls, if (kcg->expected_response_code != kpr->http_status) { TALER_TESTING_unexpected_status (is, - kpr->http_status); + kpr->http_status, + kcg->expected_response_code); return; } switch (kpr->http_status) diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c index fa6edab2..ffb143ff 100644 --- a/src/testing/testing_api_cmd_kyc_wallet_get.c +++ b/src/testing/testing_api_cmd_kyc_wallet_get.c @@ -109,7 +109,8 @@ wallet_kyc_cb (void *cls, if (kwg->expected_response_code != wkr->http_status) { TALER_TESTING_unexpected_status (is, - wkr->http_status); + wkr->http_status, + kwg->expected_response_code); return; } switch (wkr->http_status) diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c index 36dbfbff..cf992946 100644 --- a/src/testing/testing_api_cmd_purse_create_deposit.c +++ b/src/testing/testing_api_cmd_purse_create_deposit.c @@ -163,7 +163,8 @@ deposit_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } if (MHD_HTTP_OK == dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_purse_delete.c b/src/testing/testing_api_cmd_purse_delete.c index f6b7d573..26037359 100644 --- a/src/testing/testing_api_cmd_purse_delete.c +++ b/src/testing/testing_api_cmd_purse_delete.c @@ -75,7 +75,8 @@ purse_delete_cb (void *cls, if (pds->expected_response_code != pdr->hr.http_status) { TALER_TESTING_unexpected_status (pds->is, - pdr->hr.http_status); + pdr->hr.http_status, + pds->expected_response_code); return; } TALER_TESTING_interpreter_next (pds->is); diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c index eafe3342..8533e25c 100644 --- a/src/testing/testing_api_cmd_purse_deposit.c +++ b/src/testing/testing_api_cmd_purse_deposit.c @@ -138,7 +138,8 @@ deposit_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } if (MHD_HTTP_OK == dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index 503ef162..cf9d4f99 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -178,7 +178,8 @@ merge_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_recoup.c b/src/testing/testing_api_cmd_recoup.c index 263a3303..c4e72333 100644 --- a/src/testing/testing_api_cmd_recoup.c +++ b/src/testing/testing_api_cmd_recoup.c @@ -90,7 +90,8 @@ recoup_cb (void *cls, if (ps->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (is, - hr->http_status); + hr->http_status, + ps->expected_response_code); return; } diff --git a/src/testing/testing_api_cmd_recoup_refresh.c b/src/testing/testing_api_cmd_recoup_refresh.c index 7de5b96d..f2fc3b6c 100644 --- a/src/testing/testing_api_cmd_recoup_refresh.c +++ b/src/testing/testing_api_cmd_recoup_refresh.c @@ -89,7 +89,8 @@ recoup_refresh_cb (void *cls, if (rrs->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (is, - hr->http_status); + hr->http_status, + rrs->expected_response_code); return; } diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c index 6449c538..8782b0b5 100644 --- a/src/testing/testing_api_cmd_refresh.c +++ b/src/testing/testing_api_cmd_refresh.c @@ -402,7 +402,8 @@ reveal_cb (void *cls, } } TALER_TESTING_unexpected_status (rrs->is, - hr->http_status); + hr->http_status, + rrs->expected_response_code); return; } melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is, @@ -646,7 +647,8 @@ link_cb (void *cls, } } TALER_TESTING_unexpected_status (rls->is, - hr->http_status); + hr->http_status, + rls->expected_response_code); return; } reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, @@ -937,8 +939,10 @@ melt_cb (void *cls, return; } } - TALER_TESTING_unexpected_status (rms->is, - hr->http_status); + TALER_TESTING_unexpected_status_with_body (rms->is, + hr->http_status, + rms->expected_response_code, + hr->reply); return; } if (MHD_HTTP_OK == hr->http_status) diff --git a/src/testing/testing_api_cmd_refund.c b/src/testing/testing_api_cmd_refund.c index b8ce85f9..5a218bcf 100644 --- a/src/testing/testing_api_cmd_refund.c +++ b/src/testing/testing_api_cmd_refund.c @@ -83,7 +83,8 @@ refund_cb (void *cls, if (rs->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (rs->is, - hr->http_status); + hr->http_status, + rs->expected_response_code); return; } TALER_TESTING_interpreter_next (rs->is); diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index 511e2d49..ef6964f2 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -154,7 +154,8 @@ purse_cb (void *cls, if (ds->expected_response_code != dr->hr.http_status) { TALER_TESTING_unexpected_status (ds->is, - dr->hr.http_status); + dr->hr.http_status, + ds->expected_response_code); return; } switch (dr->hr.http_status) diff --git a/src/testing/testing_api_cmd_revoke_denom_key.c b/src/testing/testing_api_cmd_revoke_denom_key.c index 8bbfda63..2663c538 100644 --- a/src/testing/testing_api_cmd_revoke_denom_key.c +++ b/src/testing/testing_api_cmd_revoke_denom_key.c @@ -79,7 +79,8 @@ success_cb ( if (rs->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (rs->is, - hr->http_status); + hr->http_status, + rs->expected_response_code); return; } TALER_TESTING_interpreter_next (rs->is); diff --git a/src/testing/testing_api_cmd_revoke_sign_key.c b/src/testing/testing_api_cmd_revoke_sign_key.c index 477ffbe8..65b80b4c 100644 --- a/src/testing/testing_api_cmd_revoke_sign_key.c +++ b/src/testing/testing_api_cmd_revoke_sign_key.c @@ -79,7 +79,8 @@ success_cb ( if (rs->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (rs->is, - hr->http_status); + hr->http_status, + rs->expected_response_code); return; } TALER_TESTING_interpreter_next (rs->is); diff --git a/src/testing/testing_api_cmd_set_officer.c b/src/testing/testing_api_cmd_set_officer.c index f2464c8a..4fbe5e36 100644 --- a/src/testing/testing_api_cmd_set_officer.c +++ b/src/testing/testing_api_cmd_set_officer.c @@ -98,7 +98,8 @@ set_officer_cb (void *cls, if (MHD_HTTP_NO_CONTENT != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + MHD_HTTP_NO_CONTENT); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_set_wire_fee.c b/src/testing/testing_api_cmd_set_wire_fee.c index b2002e0f..460a71e4 100644 --- a/src/testing/testing_api_cmd_set_wire_fee.c +++ b/src/testing/testing_api_cmd_set_wire_fee.c @@ -90,7 +90,8 @@ wire_add_cb (void *cls, if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_take_aml_decision.c b/src/testing/testing_api_cmd_take_aml_decision.c index eb758397..c0e23de2 100644 --- a/src/testing/testing_api_cmd_take_aml_decision.c +++ b/src/testing/testing_api_cmd_take_aml_decision.c @@ -108,7 +108,8 @@ take_aml_decision_cb ( if (ds->expected_response != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c index da3585d6..405c8b7f 100644 --- a/src/testing/testing_api_cmd_transfer_get.c +++ b/src/testing/testing_api_cmd_transfer_get.c @@ -133,7 +133,8 @@ track_transfer_cb (void *cls, if (tts->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (is, - hr->http_status); + hr->http_status, + tts->expected_response_code); return; } diff --git a/src/testing/testing_api_cmd_wire_add.c b/src/testing/testing_api_cmd_wire_add.c index b19cca1e..09d4579c 100644 --- a/src/testing/testing_api_cmd_wire_add.c +++ b/src/testing/testing_api_cmd_wire_add.c @@ -80,7 +80,8 @@ wire_add_cb (void *cls, if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_wire_del.c b/src/testing/testing_api_cmd_wire_del.c index 61405e6e..50ebfc7c 100644 --- a/src/testing/testing_api_cmd_wire_del.c +++ b/src/testing/testing_api_cmd_wire_del.c @@ -80,7 +80,9 @@ wire_del_cb (void *cls, if (ds->expected_response_code != hr->http_status) { TALER_TESTING_unexpected_status (ds->is, - hr->http_status); + hr->http_status, + ds->expected_response_code); + return; } TALER_TESTING_interpreter_next (ds->is); diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 3e735ad0..69a47cb5 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -284,7 +284,8 @@ reserve_withdraw_cb (void *cls, } } TALER_TESTING_unexpected_status (is, - wr->hr.http_status); + wr->hr.http_status, + ws->expected_response_code); return; } switch (wr->hr.http_status) |