diff options
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/fakebank.c | 56 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_twisted.c | 4 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank_twisted.c | 20 |
3 files changed, 67 insertions, 13 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index 9915516cd..1220fa057 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -587,6 +587,7 @@ handle_reject (struct TALER_FAKEBANK_Handle *h, return ret; } + /** * Handle incoming HTTP request for /history * @@ -596,9 +597,40 @@ handle_reject (struct TALER_FAKEBANK_Handle *h, * @return MHD result code */ static int -handle_history_new (struct TALER_FAKEBANK_Handle *h, - struct MHD_Connection *connection, - void **con_cls) +handle_home_page (struct TALER_FAKEBANK_Handle *h, + struct MHD_Connection *connection, + void **con_cls) +{ + int ret; + struct MHD_Response *resp; +#define HELLOMSG "Hello, Fakebank!" + + resp = MHD_create_response_from_buffer + (strlen (HELLOMSG), + HELLOMSG, + MHD_RESPMEM_MUST_COPY); + + ret = MHD_queue_response (connection, + MHD_HTTP_OK, + resp); + + MHD_destroy_response (resp); + return ret; +} + + +/** + * Handle incoming HTTP request for /history + * + * @param h the fakebank handle + * @param connection the connection + * @param con_cls place to store state, not used + * @return MHD result code + */ +static int +handle_history (struct TALER_FAKEBANK_Handle *h, + struct MHD_Connection *connection, + void **con_cls) { struct HistoryArgs ha; struct HistoryRangeIds hri; @@ -763,6 +795,18 @@ handle_mhd_request (void *cls, { struct TALER_FAKEBANK_Handle *h = cls; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Fakebank, serving: %s\n", + url); + + + if ( (0 == strcasecmp (url, + "/")) && + (0 == strcasecmp (method, + MHD_HTTP_METHOD_GET)) ) + return handle_home_page (h, + connection, + con_cls); if ( (0 == strcasecmp (url, "/admin/add/incoming")) && (0 == strcasecmp (method, @@ -792,9 +836,9 @@ handle_mhd_request (void *cls, "/history")) && (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) ) - return handle_history_new (h, - connection, - con_cls); + return handle_history (h, + connection, + con_cls); /* Unexpected URL path, just close the connection. */ /* we're rather impolite here, but it's a testcase. */ diff --git a/src/bank-lib/test_bank_api_twisted.c b/src/bank-lib/test_bank_api_twisted.c index 6d551eb61..d01dbad94 100644 --- a/src/bank-lib/test_bank_api_twisted.c +++ b/src/bank-lib/test_bank_api_twisted.c @@ -82,6 +82,10 @@ run (void *cls, struct TALER_TESTING_Interpreter *is) { struct TALER_TESTING_Command commands[] = { + + TALER_TESTING_cmd_wait_service ("wait-service", + "http://localhost:8888/"), + TALER_TESTING_cmd_bank_history ("history-0", TWISTED_BANK_URL, EXCHANGE_ACCOUNT_NUMBER, diff --git a/src/bank-lib/test_bank_api_with_fakebank_twisted.c b/src/bank-lib/test_bank_api_with_fakebank_twisted.c index 83838172f..4cf500fbe 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_twisted.c +++ b/src/bank-lib/test_bank_api_with_fakebank_twisted.c @@ -75,18 +75,23 @@ static void run (void *cls, struct TALER_TESTING_Interpreter *is) { + struct TALER_TESTING_Command commands[] = { + + /** + * Can't use the "wait service" CMD here because the + * fakebank runs inside the same process of the test. + */ + TALER_TESTING_cmd_sleep ("wait interface", + 2), + TALER_TESTING_cmd_bank_history ("history-0", - twister_url, + TWISTED_BANK_URL, EXCHANGE_ACCOUNT_NUMBER, TALER_BANK_DIRECTION_BOTH, GNUNET_NO, NULL, 5), - /** - * End the suite. Fixme: better to have a label for this - * too, as it shows a "(null)" token on logs. - */ TALER_TESTING_cmd_end () }; @@ -120,8 +125,9 @@ main (int argc, unsetenv ("XDG_DATA_HOME"); unsetenv ("XDG_CONFIG_HOME"); - GNUNET_log_setup ("test-bank-api-twisted", - "DEBUG", NULL); + GNUNET_log_setup ("test-bank-api-with-fakebank-twisted", + "DEBUG", + NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE, |