diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/test_bank_api.c | 20 | ||||
-rw-r--r-- | src/testing/test_bank_api_nexus.conf | 10 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_bank_admin_add_incoming.c | 20 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_bank_history_credit.c | 34 | ||||
-rw-r--r-- | src/testing/testing_api_helpers_bank.c | 30 |
5 files changed, 87 insertions, 27 deletions
diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c index d81fbe36e..cb4609ddf 100644 --- a/src/testing/test_bank_api.c +++ b/src/testing/test_bank_api.c @@ -37,6 +37,13 @@ #define CONFIG_FILE_PYBANK "test_bank_api_pybank.conf" #define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf" + +/** + * Configuration file. It changes based on + * whether Nexus or Fakebank are used. + */ +const char *cfgfile; + /** * Bank configuration data. */ @@ -88,14 +95,24 @@ run (void *cls, "KUDOS:5.01", &bc.exchange_auth, bc.user42_payto), + /** + * This CMD doesn't care about the HTTP response code; that's + * because Fakebank and euFin behaves differently when a reserve + * pub is duplicate. Fakebank responds with 409, whereas euFin + * with 200 but it bounces the payment back to the customer. + */ TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail", "KUDOS:2.01", &bc.exchange_auth, bc.user42_payto, "credit-1", - MHD_HTTP_CONFLICT), + -1), TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle", 4), + /** + * Check that the incoming payment with a duplicate + * reserve public key didn't make it to the exchange. + */ TALER_TESTING_cmd_bank_credits ("history-1c", &bc.exchange_auth, NULL, @@ -164,7 +181,6 @@ main (int argc, char *const *argv) { int rv; - const char *cfgfile; (void) argc; (void) argv; diff --git a/src/testing/test_bank_api_nexus.conf b/src/testing/test_bank_api_nexus.conf index c514170e1..016399d5e 100644 --- a/src/testing/test_bank_api_nexus.conf +++ b/src/testing/test_bank_api_nexus.conf @@ -1,22 +1,20 @@ # This file is in the public domain. [taler] -currency = KUDOS +currency = TESTKUDOS [exchange-account-2] PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange [exchange-accountcredentials-2] -WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler/ +WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = basic -# the exchange authenticates as the 'admin' user, -# since that makes the test preparation just easier. -USERNAME = Exchange +USERNAME = exchange PASSWORD = x [bank] # not (!) used by the nexus, only by the helper -# check to make sure the port is free for the nexus. +# check to make sure the port is free for Nexus. HTTP_PORT = 5001 [auditor] diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c index 28d251a4f..9db874faf 100644 --- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c @@ -217,6 +217,26 @@ confirmation_cb (void *cls, fts->reserve_history.details.in_details.timestamp = timestamp; fts->reserve_history.details.in_details.wire_reference = serial_id; fts->aih = NULL; + /** + * Test case not caring about the HTTP status code. + * That helps when Fakebank and Libeufin diverge in + * the response status code. An example is the + * /admin/add-incoming: libeufin return ALWAYS '200 OK' + * (see note below) whereas the Fakebank responds with + * '409 Conflict' upon a duplicate reserve public key. + * + * Note: this decision aims at avoiding to put Taler + * logic into the Sandbox; that's because banks DO allow + * their customers to wire the same subject multiple + * times. Hence, instead of triggering any error, libeufin + * bounces the payment back in the same way it does for + * malformed reserve public keys. + */ + if (-1 == fts->expected_http_status) + { + TALER_TESTING_interpreter_next (is); + return; + } if (http_status != fts->expected_http_status) { GNUNET_break (0); diff --git a/src/testing/testing_api_cmd_bank_history_credit.c b/src/testing/testing_api_cmd_bank_history_credit.c index 62bc47e11..c65c84c13 100644 --- a/src/testing/testing_api_cmd_bank_history_credit.c +++ b/src/testing/testing_api_cmd_bank_history_credit.c @@ -168,9 +168,6 @@ build_history (struct TALER_TESTING_Interpreter *is, unsigned int start; unsigned int end; - /* @var turns GNUNET_YES whenever either no 'start' value was - * given for the history query, or the given value is found - * in the list of all the CMDs. */// int ok; const uint64_t *row_id_start = NULL; @@ -208,7 +205,11 @@ build_history (struct TALER_TESTING_Interpreter *is, start = is->ip - 1; end = 0; } - + /** + * ok equals GNUNET_YES whenever a starting row_id + * was provided AND was found among the CMDs, OR no + * starting row was given in the first place. + */ ok = GNUNET_NO; if (NULL == row_id_start) ok = GNUNET_YES; @@ -228,9 +229,11 @@ build_history (struct TALER_TESTING_Interpreter *is, const struct TALER_ReservePublicKeyP *reserve_pub; const char **exchange_credit_url; - /* The following command allows us to skip over those CMDs + /** + * The following command allows us to skip over those CMDs * that do not offer a "row_id" trait. Such skipped CMDs are - * not interesting for building a history. */// + * not interesting for building a history. + */ if ( (GNUNET_OK != TALER_TESTING_get_trait_bank_row (cmd, &row_id)) || @@ -250,22 +253,29 @@ build_history (struct TALER_TESTING_Interpreter *is, TALER_TESTING_get_trait_exchange_bank_account_url ( cmd, &exchange_credit_url)) ) - continue; /* not an interesting event */ - /* Seek "/history/incoming" starting row. */ + continue; // Not an interesting event + /** + * Is the interesting event a match with regard to + * the row_id value? If yes, store this condition + * to the state and analyze the next CMDs. + */ if ( (NULL != row_id_start) && (*row_id_start == *row_id) && (GNUNET_NO == ok) ) { - /* Until here, nothing counted. */ ok = GNUNET_YES; continue; } - /* when 'start' was _not_ given, then ok == GNUNET_YES */ + /** + * The interesting event didn't match the wanted + * row_id value, analyze the next CMDs. Note: this + * branch is relevant only when row_id WAS given. + */ if (GNUNET_NO == ok) - continue; /* skip until we find the marker */ + continue; if (0 != strcasecmp (hs->account_url, *exchange_credit_url)) - continue; /* account mismatch */ + continue; // Account mismatch if (total >= GNUNET_MAX (hs->num_results, -hs->num_results) ) { diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c index 1ec2050a2..eccd45723 100644 --- a/src/testing/testing_api_helpers_bank.c +++ b/src/testing/testing_api_helpers_bank.c @@ -92,6 +92,12 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) struct TALER_TESTING_LibeufinServices ret = { 0 }; unsigned int iter; char *curl_check_cmd; + const char *db_conn = "jdbc:sqlite:/tmp/libeufin-exchange-test.sqlite3"; + + setenv ( + "LIBEUFIN_NEXUS_DB_CONNECTION", + db_conn, + 1); // not overwriting any potentially existing DB. nexus_proc = GNUNET_OS_start_process ( GNUNET_OS_INHERIT_STD_ERR, @@ -99,7 +105,6 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) "libeufin-nexus", "libeufin-nexus", "serve", - "--db-name", "/tmp/nexus-exchange-test.sqlite3", NULL); if (NULL == nexus_proc) { @@ -139,14 +144,26 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) // start sandbox. GNUNET_free (curl_check_cmd); fprintf (stderr, "\n"); - + setenv ( + "LIBEUFIN_SANDBOX_DB_CONNECTION", + db_conn, + 1); // not overwriting existing any potentially existing DB. + setenv ( + "LIBEUFIN_SANDBOX_ADMIN_PASSWORD", + "secret", + 1); + if (0 != system ("libeufin-sandbox config --currency=KUDOS default")) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not create the default demobank.\n"); + return ret; + } sandbox_proc = GNUNET_OS_start_process ( GNUNET_OS_INHERIT_STD_ERR, NULL, NULL, NULL, "libeufin-sandbox", "libeufin-sandbox", "serve", - "--db-name", "/tmp/sandbox-exchange-test.sqlite3", NULL); if (NULL == sandbox_proc) { @@ -350,8 +367,7 @@ TALER_TESTING_prepare_nexus (const char *config_filename, /* DB preparation */ if (GNUNET_YES == reset_db) { - if (0 != system ( - "rm -f /tmp/nexus-exchange-test.sqlite3 && rm -f /tmp/sandbox-exchange-test.sqlite3")) + if (0 != system ("rm -f /tmp/libeufin-exchange-test.sqlite3")) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to invoke db-removal command.\n"); @@ -384,9 +400,9 @@ TALER_TESTING_prepare_nexus (const char *config_filename, GNUNET_CONFIGURATION_destroy (cfg); bc->exchange_payto = exchange_payto_uri; bc->user42_payto = - "payto://iban/BIC/FR7630006000011234567890189?receiver-name=User42"; + "payto://iban/SANDBOXX/FR7630006000011234567890189?receiver-name=User42"; bc->user43_payto = - "payto://iban/BIC/GB33BUKB20201555555555?receiver-name=User43"; + "payto://iban/SANDBOXX/GB33BUKB20201555555555?receiver-name=User43"; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Relying on nexus %s on port %u\n", bc->exchange_auth.wire_gateway_url, |