diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-01-28 16:51:13 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-01-28 16:51:13 +0100 |
commit | 3dd987035bcdbe4656ee77c62795f79dd591fc96 (patch) | |
tree | 85f3b1ee1bf6ad39c1e7ef22cb01f22ca163d396 | |
parent | 0b0b22c8dba00e587d9a54e3dc51b27d3102a9f3 (diff) | |
download | exchange-3dd987035bcdbe4656ee77c62795f79dd591fc96.tar.xz |
Extend auditor testing-lib.
Add method to check whether a exchange (URL)
belongs to the list of audited exchanges.
-rw-r--r-- | src/include/taler_testing_auditor_lib.h | 17 | ||||
-rw-r--r-- | src/lib/test_auditor_api.c | 7 | ||||
-rw-r--r-- | src/lib/testing_auditor_api_cmd_exchanges.c | 75 |
3 files changed, 90 insertions, 9 deletions
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 @@ -123,6 +123,23 @@ 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); + +/** * 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 @@ -67,6 +67,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? */ int do_retry; @@ -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; + i<num_exchanges; + i++) + if (0 == strcmp (es->exchange_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); @@ -275,6 +303,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. * |