added expected HTTP-code to logger

This commit is contained in:
Özgür Kesim 2023-07-10 10:22:29 +02:00
parent 7e9f5324b7
commit 9d706a01a2
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
37 changed files with 111 additions and 42 deletions

View File

@ -57,18 +57,44 @@
* *
* @param is interpreter to fail * @param is interpreter to fail
* @param status unexpected HTTP status code received * @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 { \ do { \
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 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, \ status, \
expected, \
TALER_TESTING_interpreter_get_current_label (is), \ TALER_TESTING_interpreter_get_current_label (is), \
__FILE__, \ __FILE__, \
__LINE__); \ __LINE__); \
TALER_TESTING_interpreter_fail (is); \ TALER_TESTING_interpreter_fail (is); \
} while (0) } 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 * Log an error message about a command not having

View File

@ -76,7 +76,8 @@ auditor_add_cb (
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -81,7 +81,8 @@ denom_sig_add_cb (
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -77,7 +77,8 @@ auditor_del_cb (
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -170,7 +170,8 @@ deposit_confirmation_cb (
} }
} }
TALER_TESTING_unexpected_status (dcs->is, TALER_TESTING_unexpected_status (dcs->is,
hr->http_status); hr->http_status,
dcs->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (dcs->is); TALER_TESTING_interpreter_next (dcs->is);

View File

@ -160,7 +160,8 @@ exchanges_cb (void *cls,
} }
} }
TALER_TESTING_unexpected_status (es->is, TALER_TESTING_unexpected_status (es->is,
hr->http_status); hr->http_status,
es->expected_response_code);
return; return;
} }
if (MHD_HTTP_OK != hr->http_status) if (MHD_HTTP_OK != hr->http_status)

View File

@ -199,7 +199,8 @@ confirmation_cb (void *cls,
} }
} }
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
tr->http_status); tr->http_status,
MHD_HTTP_OK);
return; return;
} }

View File

@ -199,7 +199,8 @@ batch_deposit_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)

View File

@ -190,7 +190,8 @@ reserve_batch_withdraw_cb (void *cls,
if (ws->expected_response_code != wr->hr.http_status) if (ws->expected_response_code != wr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
wr->hr.http_status); wr->hr.http_status,
ws->expected_response_code);
return; return;
} }
switch (wr->hr.http_status) switch (wr->hr.http_status)

View File

@ -80,7 +80,8 @@ check_aml_decision_cb (void *cls,
if (ds->expected_http_status != adr->hr.http_status) if (ds->expected_http_status != adr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
adr->hr.http_status); adr->hr.http_status,
ds->expected_http_status);
return; return;
} }
if (MHD_HTTP_OK == adr->hr.http_status) if (MHD_HTTP_OK == adr->hr.http_status)

View File

@ -80,7 +80,8 @@ check_aml_decisions_cb (void *cls,
if (ds->expected_http_status != adr->hr.http_status) if (ds->expected_http_status != adr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
adr->hr.http_status); adr->hr.http_status,
ds->expected_http_status);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -77,7 +77,8 @@ keys_cb (void *cls,
if (MHD_HTTP_OK != kr->hr.http_status) if (MHD_HTTP_OK != kr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (cks->is, TALER_TESTING_unexpected_status (cks->is,
kr->hr.http_status); kr->hr.http_status,
MHD_HTTP_OK);
return; return;
} }
cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date; cks->my_denom_date = kr->details.ok.keys->last_denom_issue_date;

View File

@ -102,7 +102,8 @@ get_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
ref = TALER_TESTING_interpreter_lookup_command (ds->is, ref = TALER_TESTING_interpreter_lookup_command (ds->is,

View File

@ -248,8 +248,12 @@ deposit_cb (void *cls,
return; return;
} }
} }
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status_with_body (
dr->hr.http_status); ds->is,
dr->hr.http_status,
ds->expected_response_code,
dr->hr.reply);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)

View File

@ -117,7 +117,8 @@ deposit_wtid_cb (void *cls,
if (tts->expected_response_code != dr->hr.http_status) if (tts->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
dr->hr.http_status); dr->hr.http_status,
tts->expected_response_code);
return; return;
} }
switch (dr->hr.http_status) switch (dr->hr.http_status)

View File

@ -83,7 +83,8 @@ version_cb (
if (MHD_HTTP_OK != vr->hr.http_status) if (MHD_HTTP_OK != vr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (gas->is, TALER_TESTING_unexpected_status (gas->is,
vr->hr.http_status); vr->hr.http_status,
MHD_HTTP_OK);
return; return;
} }
if ( (NULL != gas->priv_file) && if ( (NULL != gas->priv_file) &&

View File

@ -78,7 +78,8 @@ check_kyc_cb (void *cls,
if (kcg->expected_response_code != ks->http_status) if (kcg->expected_response_code != ks->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
ks->http_status); ks->http_status,
kcg->expected_response_code);
return; return;
} }
switch (ks->http_status) switch (ks->http_status)

View File

@ -88,7 +88,8 @@ proof_kyc_cb (void *cls,
if (kcg->expected_response_code != kpr->http_status) if (kcg->expected_response_code != kpr->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
kpr->http_status); kpr->http_status,
kcg->expected_response_code);
return; return;
} }
switch (kpr->http_status) switch (kpr->http_status)

View File

@ -109,7 +109,8 @@ wallet_kyc_cb (void *cls,
if (kwg->expected_response_code != wkr->http_status) if (kwg->expected_response_code != wkr->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
wkr->http_status); wkr->http_status,
kwg->expected_response_code);
return; return;
} }
switch (wkr->http_status) switch (wkr->http_status)

View File

@ -163,7 +163,8 @@ deposit_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)

View File

@ -75,7 +75,8 @@ purse_delete_cb (void *cls,
if (pds->expected_response_code != pdr->hr.http_status) if (pds->expected_response_code != pdr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (pds->is, TALER_TESTING_unexpected_status (pds->is,
pdr->hr.http_status); pdr->hr.http_status,
pds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (pds->is); TALER_TESTING_interpreter_next (pds->is);

View File

@ -138,7 +138,8 @@ deposit_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
if (MHD_HTTP_OK == dr->hr.http_status) if (MHD_HTTP_OK == dr->hr.http_status)

View File

@ -178,7 +178,8 @@ merge_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -90,7 +90,8 @@ recoup_cb (void *cls,
if (ps->expected_response_code != hr->http_status) if (ps->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
hr->http_status); hr->http_status,
ps->expected_response_code);
return; return;
} }

View File

@ -89,7 +89,8 @@ recoup_refresh_cb (void *cls,
if (rrs->expected_response_code != hr->http_status) if (rrs->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
hr->http_status); hr->http_status,
rrs->expected_response_code);
return; return;
} }

View File

@ -402,7 +402,8 @@ reveal_cb (void *cls,
} }
} }
TALER_TESTING_unexpected_status (rrs->is, TALER_TESTING_unexpected_status (rrs->is,
hr->http_status); hr->http_status,
rrs->expected_response_code);
return; return;
} }
melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is, melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is,
@ -646,7 +647,8 @@ link_cb (void *cls,
} }
} }
TALER_TESTING_unexpected_status (rls->is, TALER_TESTING_unexpected_status (rls->is,
hr->http_status); hr->http_status,
rls->expected_response_code);
return; return;
} }
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is, reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
@ -937,8 +939,10 @@ melt_cb (void *cls,
return; return;
} }
} }
TALER_TESTING_unexpected_status (rms->is, TALER_TESTING_unexpected_status_with_body (rms->is,
hr->http_status); hr->http_status,
rms->expected_response_code,
hr->reply);
return; return;
} }
if (MHD_HTTP_OK == hr->http_status) if (MHD_HTTP_OK == hr->http_status)

View File

@ -83,7 +83,8 @@ refund_cb (void *cls,
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (rs->is, TALER_TESTING_unexpected_status (rs->is,
hr->http_status); hr->http_status,
rs->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);

View File

@ -154,7 +154,8 @@ purse_cb (void *cls,
if (ds->expected_response_code != dr->hr.http_status) if (ds->expected_response_code != dr->hr.http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status); dr->hr.http_status,
ds->expected_response_code);
return; return;
} }
switch (dr->hr.http_status) switch (dr->hr.http_status)

View File

@ -79,7 +79,8 @@ success_cb (
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (rs->is, TALER_TESTING_unexpected_status (rs->is,
hr->http_status); hr->http_status,
rs->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);

View File

@ -79,7 +79,8 @@ success_cb (
if (rs->expected_response_code != hr->http_status) if (rs->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (rs->is, TALER_TESTING_unexpected_status (rs->is,
hr->http_status); hr->http_status,
rs->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (rs->is); TALER_TESTING_interpreter_next (rs->is);

View File

@ -98,7 +98,8 @@ set_officer_cb (void *cls,
if (MHD_HTTP_NO_CONTENT != hr->http_status) if (MHD_HTTP_NO_CONTENT != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
MHD_HTTP_NO_CONTENT);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -90,7 +90,8 @@ wire_add_cb (void *cls,
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -108,7 +108,8 @@ take_aml_decision_cb (
if (ds->expected_response != hr->http_status) if (ds->expected_response != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -133,7 +133,8 @@ track_transfer_cb (void *cls,
if (tts->expected_response_code != hr->http_status) if (tts->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
hr->http_status); hr->http_status,
tts->expected_response_code);
return; return;
} }

View File

@ -80,7 +80,8 @@ wire_add_cb (void *cls,
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -80,7 +80,9 @@ wire_del_cb (void *cls,
if (ds->expected_response_code != hr->http_status) if (ds->expected_response_code != hr->http_status)
{ {
TALER_TESTING_unexpected_status (ds->is, TALER_TESTING_unexpected_status (ds->is,
hr->http_status); hr->http_status,
ds->expected_response_code);
return; return;
} }
TALER_TESTING_interpreter_next (ds->is); TALER_TESTING_interpreter_next (ds->is);

View File

@ -284,7 +284,8 @@ reserve_withdraw_cb (void *cls,
} }
} }
TALER_TESTING_unexpected_status (is, TALER_TESTING_unexpected_status (is,
wr->hr.http_status); wr->hr.http_status,
ws->expected_response_code);
return; return;
} }
switch (wr->hr.http_status) switch (wr->hr.http_status)