diff --git a/src/include/taler_testing_auditor_lib.h b/src/include/taler_testing_auditor_lib.h index 65f50b776..090a1210c 100644 --- a/src/include/taler_testing_auditor_lib.h +++ b/src/include/taler_testing_auditor_lib.h @@ -122,6 +122,23 @@ TALER_TESTING_cmd_exchanges unsigned int expected_response_code); +/** + * Create a "list exchanges" command and check whether + * a particular exchange belongs to the returned bundle. + * + * @param label command label. + * @param auditor auditor connection. + * @param expected_response_code expected HTTP response code. + * @param exchange_url URL of the exchange supposed to + * be included in the response. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exchanges_with_url + (const char *label, + unsigned int expected_response_code, + const char *exchange_url); + /** * Modify an exchanges command to enable retries when we get * transient errors from the auditor. diff --git a/src/lib/test_auditor_api.c b/src/lib/test_auditor_api.c index cde3e1aa9..78db2a09a 100644 --- a/src/lib/test_auditor_api.c +++ b/src/lib/test_auditor_api.c @@ -472,8 +472,11 @@ run (void *cls, struct TALER_TESTING_Command commands[] = { - CMD_RUN_AUDITOR("virgin-auditor"), - CMD_RUN_WIRE_AUDITOR("virgin-wire-auditor"), + CMD_RUN_AUDITOR ("virgin-auditor"), + CMD_RUN_WIRE_AUDITOR ("virgin-wire-auditor"), + TALER_TESTING_cmd_exchanges_with_url ("check-exchange", + MHD_HTTP_OK, + "http://localhost:8081/"), TALER_TESTING_cmd_batch ("withdraw", withdraw), TALER_TESTING_cmd_batch ("spend", diff --git a/src/lib/testing_auditor_api_cmd_exchanges.c b/src/lib/testing_auditor_api_cmd_exchanges.c index ed4ca5e0e..2f002627e 100644 --- a/src/lib/testing_auditor_api_cmd_exchanges.c +++ b/src/lib/testing_auditor_api_cmd_exchanges.c @@ -66,6 +66,11 @@ struct ExchangesState */ unsigned int expected_response_code; + /** + * URL of the exchange expected to be included in the response. + */ + const char *exchange_url; + /** * Should we retry on (transient) failures? */ @@ -146,16 +151,39 @@ exchanges_cb (void *cls, return; } } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - http_status, - es->is->commands[es->is->ip].label, - __FILE__, - __LINE__); + GNUNET_log + (GNUNET_ERROR_TYPE_ERROR, + "Unexpected response code %u to command %s in %s:%u\n", + http_status, + es->is->commands[es->is->ip].label, + __FILE__, + __LINE__); json_dumpf (raw_response, stderr, 0); TALER_TESTING_interpreter_fail (es->is); return; } + if (NULL != es->exchange_url) + { + unsigned int found = GNUNET_NO; + + for (unsigned int i=0; + iexchange_url, + ei[i].exchange_url)) + found = GNUNET_YES; + if (GNUNET_NO == found) + { + TALER_LOG_ERROR + ("Exchange '%s' doesn't exist at this auditor\n", + es->exchange_url); + TALER_TESTING_interpreter_fail (es->is); + return; + } + + TALER_LOG_DEBUG ("Exchange '%s' exists at this auditor!\n", + es->exchange_url); + } TALER_TESTING_interpreter_next (es->is); } @@ -176,7 +204,7 @@ exchanges_run (void *cls, es->is = is; es->leh = TALER_AUDITOR_list_exchanges - (es->auditor, + (is->auditor, &exchanges_cb, es); @@ -274,6 +302,39 @@ TALER_TESTING_cmd_exchanges } +/** + * Create a "list exchanges" command and check whether + * a particular exchange belongs to the returned bundle. + * + * @param label command label. + * @param auditor auditor connection. + * @param expected_response_code expected HTTP response code. + * @param exchange_url URL of the exchange supposed to + * be included in the response. + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_exchanges_with_url + (const char *label, + unsigned int expected_response_code, + const char *exchange_url) +{ + struct TALER_TESTING_Command cmd = {0}; /* need explicit zeroing..*/ + struct ExchangesState *es; + + es = GNUNET_new (struct ExchangesState); + es->expected_response_code = expected_response_code; + es->exchange_url = exchange_url; + + cmd.cls = es; + cmd.label = label; + cmd.run = &exchanges_run; + cmd.cleanup = &exchanges_cleanup; + cmd.traits = &exchanges_traits; + + return cmd; +} + /** * Modify an exchanges command to enable retries when we get * transient errors from the auditor.