anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 37fcba7e895f0e6e5d5f9d1a7fa990d2aedaecce
parent fcfd43286a8157c15386e734353a5337616f89ea
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 30 Jul 2026 17:55:31 +0200

migrate to libeufin-bank instead of fakebank

Diffstat:
Msrc/authorization/libanastasiseufin/lae_credit.c | 29+++++++++++++++++++----------
Msrc/cli/meson.build | 4+---
Msrc/cli/setup.sh | 23++++++++++++-----------
Msrc/cli/test_iban.sh | 238+++++++++++++++++++++++++++++--------------------------------------------------
Msrc/include/anastasis_eufin_lib.h | 12++++++++----
Msrc/testing/meson.build | 2++
Msrc/testing/test_anastasis.c | 73++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/testing/test_anastasis_api.c | 73++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/testing/test_anastasis_api.conf | 31++++++++++++++++++++++++++-----
9 files changed, 218 insertions(+), 267 deletions(-)

diff --git a/src/authorization/libanastasiseufin/lae_credit.c b/src/authorization/libanastasiseufin/lae_credit.c @@ -18,8 +18,8 @@ */ /** * @file libanastasiseufin/lae_credit.c - * @brief Implementation of the /history/incoming - * requests of the libeufin's Anastasis facade + * @brief Implementation of the /history requests of the + * Taler revenue API (as served by libeufin-bank) * @author Christian Grothoff * @author Marcello Stanisci */ @@ -29,7 +29,7 @@ /** - * @brief A /history/incoming Handle + * @brief A /history Handle */ struct ANASTASIS_EUFIN_CreditHistoryHandle { @@ -70,6 +70,7 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh, const json_t *history) { json_t *history_array; + const char *credit_account_uri; if (NULL == (history_array = json_object_get (history, "incoming_transactions"))) @@ -82,6 +83,15 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh, GNUNET_break_op (0); return GNUNET_SYSERR; } + /* The credited account is the account we asked about, so the revenue API + states it once for the whole response instead of per transaction. */ + credit_account_uri = json_string_value (json_object_get (history, + "credit_account")); + if (NULL == credit_account_uri) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } for (size_t i = 0; i<json_array_size (history_array); i++) { struct ANASTASIS_EUFIN_CreditDetails td; @@ -97,13 +107,12 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh, &td.wire_subject), GNUNET_JSON_spec_string ("debit_account", &td.debit_account_uri), - GNUNET_JSON_spec_string ("credit_account", - &td.credit_account_uri), GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, i); + td.credit_account_uri = credit_account_uri; if (GNUNET_OK != GNUNET_JSON_parse (transaction, hist_spec, @@ -131,7 +140,7 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh, /** * Function called when we're done processing the - * HTTP /history/incoming request. + * HTTP /history request. * * @param cls the `struct ANASTASIS_EUFIN_CreditHistoryHandle` * @param response_code HTTP response code, 0 on error @@ -241,13 +250,13 @@ ANASTASIS_EUFIN_credit_history ( (! GNUNET_TIME_relative_is_zero (timeout)) ) GNUNET_snprintf (url, sizeof (url), - "history/incoming?delta=%lld&long_poll_ms=%llu", + "history?limit=%lld&timeout_ms=%llu", (long long) num_results, tms); else GNUNET_snprintf (url, sizeof (url), - "history/incoming?delta=%lld", + "history?limit=%lld", (long long) num_results); } else @@ -256,14 +265,14 @@ ANASTASIS_EUFIN_credit_history ( (! GNUNET_TIME_relative_is_zero (timeout)) ) GNUNET_snprintf (url, sizeof (url), - "history/incoming?delta=%lld&start=%llu&long_poll_ms=%llu", + "history?limit=%lld&offset=%llu&timeout_ms=%llu", (long long) num_results, (unsigned long long) start_row, tms); else GNUNET_snprintf (url, sizeof (url), - "history/incoming?delta=%lld&start=%llu", + "history?limit=%lld&offset=%llu", (long long) num_results, (unsigned long long) start_row); } diff --git a/src/cli/meson.build b/src/cli/meson.build @@ -11,6 +11,7 @@ check_SCRIPTS = [ 'test_anastasis_reducer_recovery_enter_user_attributes', 'test_anastasis_reducer_recovery_no_pay', 'test_anastasis_reducer_recovery_hanging', + 'test_iban', ] foreach f : check_SCRIPTS @@ -27,9 +28,6 @@ foreach f : check_SCRIPTS is_parallel: false, ) endforeach -# Removed for now, libeufin is not yet working OK for this. -# test_iban.sh - EXTRA_DIST = [ 'setup.sh', diff --git a/src/cli/setup.sh b/src/cli/setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # This file is in the public domain # Script to be inlined into the main test scripts. Defines function 'setup()' @@ -10,6 +10,10 @@ set -eu +unset XDG_DATA_HOME +unset XDG_CONFIG_HOME + + # Cleanup to run whenever we exit function exit_cleanup() { @@ -58,15 +62,12 @@ function exit_skip() { } function get_payto_uri() { - export LIBEUFIN_SANDBOX_USERNAME="$1" - export LIBEUFIN_SANDBOX_PASSWORD="$2" - export LIBEUFIN_SANDBOX_URL="http://localhost:18082" - libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri' + libeufin-bank create-account -u "$1" -p "$2" --name "$1" 2> /dev/null } -function get_bankaccount_transactions() { - export LIBEUFIN_SANDBOX_USERNAME=$1 - export LIBEUFIN_SANDBOX_PASSWORD=$2 - export LIBEUFIN_SANDBOX_URL="http://localhost:18082" - libeufin-cli sandbox demobank list-transactions --bank-account $1 -} +echo -n "Checking for curl ..." +curl --version 2> /dev/null > /dev/null || exit_skip " no curl" +echo " OK" +echo -n "Checking for jq ..." +jq --version 2> /dev/null > /dev/null || exit_skip " no jq" +echo " OK" diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh @@ -23,31 +23,11 @@ function cleanup() do kill "$n" 2> /dev/null || true done - rm -rf "$CONF" "$R1FILE" "$R2FILE" "$B1FILE" "$B2FILE" + rm -rf "$CONF" "$BANK_CONF" "$R1FILE" "$R2FILE" "$B1FILE" "$B2FILE" wait } -# $1=ebics username, $2=ebics partner name, $3=person name, $4=sandbox bank account name, $5=iban -function prepare_sandbox_account() { - echo -n "Registering $4 to the Sandbox..." - export LIBEUFIN_SANDBOX_USERNAME="$4" - export LIBEUFIN_SANDBOX_PASSWORD=unused - libeufin-cli sandbox --sandbox-url="$SANDBOX_URL" \ - demobank register --name "$3" --iban "$5" - echo " OK" - echo -n "Associating a EBICS subscriber to $4..." - export LIBEUFIN_SANDBOX_USERNAME=admin - libeufin-cli sandbox --sandbox-url="$SANDBOX_URL" demobank new-ebicssubscriber \ - --host-id "$EBICS_HOST" \ - --user-id "$1" --partner-id "$2" \ - --bank-account "$4" # that's a username _and_ a bank account name - echo " OK" - - unset LIBEUFIN_SANDBOX_USERNAME - unset LIBEUFIN_SANDBOX_PASSWORD -} - function sync_providers() { infile="$1" outfile="$2" @@ -86,58 +66,30 @@ function sync_providers() { trap cleanup EXIT -# Transfer only from debit to credit/anastasis account. -# This function moves funds directly at the Sandbox. No need -# to pass through the Nexus+Ebics layer to issue the payment +# Transfer funds from the customer's account to the Anastasis account. # $1 = amount ($CURRENCY:X.Y), $2 = subject. function wire_transfer_to_anastasis() { echo -n "Initiating wire transfer ..." - libeufin-sandbox make-transaction \ - --debit-account=sandbox-account-debit \ - --credit-account=sandbox-account-credit "$1" "$2" &> libeufin-transfer-initiate.out - echo " OK" - # FIXME-MS: the following command reports that it did not - # sync any transactions, even though presumably we just - # made one in the one above (which succeeded...) - echo -n "Syncing nexus with sandbox ..." - export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME" - export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD" - libeufin-cli accounts fetch-transactions nexus-bankaccount-credit &> libeufin-transfer-fetch.out + curl -s -X POST \ + --user "${DEBIT_USERNAME}:${DEBIT_PASSWORD}" \ + -H "Content-Type: application/json" \ + -d "{\"payto_uri\":\"${PAYTO_CREDIT}&message=$(echo -n "$2" | jq -sRr @uri)&amount=$1\"}" \ + "${BANK_URL}accounts/${DEBIT_USERNAME}/transactions" \ + > libeufin-transfer.out echo " OK" } -# $1 = facade base URL. Merely a debug utility. -function see_anastasis_transactions_via_facade() { - curl -s --user "$CREDIT_USERNAME:$CREDIT_PASSWORD" "${1}history/incoming?delta=5" | jq +# Merely a debug utility: show what Anastasis sees on the credit account. +function see_anastasis_transactions() { + curl -s --user "${CREDIT_USERNAME}:${CREDIT_PASSWORD}" \ + "${BANK_URL}accounts/${CREDIT_USERNAME}/taler-revenue/history?limit=5" | jq } -# $1 = ebics user id, $2 = ebics partner, $3 = bank connection name -# $4 = bank account name local to Nexus, $5 = bank account name as known -# by Sandbox -function prepare_nexus_account() { - echo -n "Making bank connection $3 ..." - libeufin-cli connections new-ebics-connection \ - --ebics-url="${SANDBOX_URL}ebicsweb" \ - --host-id="$EBICS_HOST" \ - --partner-id="$2" \ - --ebics-user-id="$1" \ - $3 > /dev/null - echo " OK" - echo -n "Connecting $3 ..." - libeufin-cli connections connect "$3" > /dev/null - echo " OK" - echo -n "Importing Sandbox bank account ($5) to Nexus ($4) ..." - libeufin-cli connections download-bank-accounts "$3" > /dev/null - libeufin-cli connections import-bank-account \ - --offered-account-id="$5" --nexus-bank-account-id="$4" "$3" > /dev/null - echo " OK" -} - - # Configuration file will be edited, so we create one # from the template. CONF=$(mktemp test_free_reducerXXXXXX.conf) cp test_free_reducer.conf "$CONF" +BANK_CONF=$(mktemp test_iban_bankXXXXXX.conf) @@ -152,16 +104,12 @@ export B1FILE export R2FILE export R1FILE -echo -n "Testing for libeufin-cli" -libeufin-cli --version > /dev/null || exit_skip "libeufin-cli required" +echo -n "Testing for libeufin-bank" +libeufin-bank --help > /dev/null || exit_skip "libeufin-bank required" echo " FOUND" -echo -n "Testing for libeufin-nexus" -libeufin-nexus --version > /dev/null || exit_skip "libeufin-nexus required" -echo " FOUND" - -echo -n "Testing for libeufin-sandbox" -libeufin-sandbox --version > /dev/null || exit_skip "libeufin-sandbox required" +echo -n "Testing for curl" +curl --version > /dev/null || exit_skip "curl required" echo " FOUND" # Check we can actually run @@ -186,100 +134,86 @@ anastasis-dbinit -c "$CONF" 2> anastasis-dbinit.log echo " OK" -export LIBEUFIN_NEXUS_DB_CONNECTION="postgres:///anastasischeck" -export LIBEUFIN_SANDBOX_DB_CONNECTION="postgres:///anastasischeck" -NEXUS_URL="http://localhost:5001/" -SANDBOX_URL="http://localhost:5000/" - -echo -n "Starting Nexus ..." -libeufin-nexus serve &> nexus.log & -nexus_pid=$! -if ! curl -s --retry 5 --retry-connrefused "$NEXUS_URL" > /dev/null; then - exit_skip "Could not launch Nexus" -fi -echo " OK" - -echo -n "Configuring Sandbox..." -libeufin-sandbox config default &> sandbox-config.log -echo " OK" -echo -n "Starting Sandbox ..." -libeufin-sandbox serve --no-auth &> sandbox-serve.log & -sandbox_pid=$! -if ! curl -s --retry 5 --retry-connrefused "$SANDBOX_URL" > /dev/null; then - exit_skip "Could not launch Sandbox" -fi -echo " OK" - CURRENCY="EUR" -# CURRENCY="TESTKUDOS" - -EBICS_HOST="ebicstesthost" +BANK_DB=anastasisbankcheck +BANK_PORT=8092 +BANK_URL="http://localhost:${BANK_PORT}/" +# Both IBANs have to pass the IBAN checksum, libeufin-bank rejects the rest. export IBAN_CREDIT="DE89370400440532013000" export IBAN_DEBIT="FR1420041010050500013M02606" - -echo -n "Preparing Sandbox (creating the EBICS host) ..." -libeufin-cli \ - sandbox --sandbox-url="$SANDBOX_URL" \ - ebicshost create \ - --host-id="$EBICS_HOST" -echo " OK" - PERSON_CREDIT_NAME="Person Credit" -echo -n "Preparing accounts ..." -# note: Ebisc schema doesn't allow dashed names. -prepare_sandbox_account \ - ebicsuserCredit \ - ebicspartnerCredit \ - "${PERSON_CREDIT_NAME}" \ - sandbox-account-credit \ - "$IBAN_CREDIT" -prepare_sandbox_account \ - ebicsuserDebit \ - ebicspartnerDebit \ - "Person Debit" \ - sandbox-account-debit \ - "$IBAN_DEBIT" -echo "Sandbox preparation done" -echo -n "Preparing Nexus ..." -export LIBEUFIN_NEXUS_URL="$NEXUS_URL" -# Make debit user, will buy Anastasis services. +CREDIT_USERNAME=anastasis-credit-user +CREDIT_PASSWORD=anastasis-credit-password DEBIT_USERNAME=anastasis-debit-user DEBIT_PASSWORD=anastasis-debit-password -libeufin-nexus superuser "$DEBIT_USERNAME" --password="$DEBIT_PASSWORD" +PAYTO_CREDIT="payto://iban/${IBAN_CREDIT}?receiver-name=Person+Credit" +PAYTO_DEBIT="payto://iban/${IBAN_DEBIT}?receiver-name=Person+Debit" + +echo -n "Configuring bank ..." +cat > "$BANK_CONF" <<EOF +# Generated by test_iban.sh +[libeufin-bank] +CURRENCY = ${CURRENCY} +BASE_URL = ${BANK_URL} +SERVE = tcp +PORT = ${BANK_PORT} +WIRE_TYPE = iban +IBAN_PAYTO_BIC = SANDBOXX +DEFAULT_CUSTOMER_DEBT_LIMIT = ${CURRENCY}:200 +DEFAULT_ADMIN_DEBT_LIMIT = ${CURRENCY}:2000 +ALLOW_REGISTRATION = YES +# keep the test fast +PWD_HASH_CONFIG = { "cost": 4 } +# the Anastasis IBAN helper authenticates with HTTP basic auth +PWD_AUTH_COMPAT = yes + +[libeufin-bankdb-postgres] +CONFIG = postgres:///${BANK_DB} +EOF +dropdb "$BANK_DB" >/dev/null 2>/dev/null || true +createdb "$BANK_DB" || exit_skip "Could not create database $BANK_DB" +libeufin-bank dbinit -c "$BANK_CONF" &> libeufin-bank-dbinit.log echo " OK" -export LIBEUFIN_NEXUS_USERNAME="$DEBIT_USERNAME" -export LIBEUFIN_NEXUS_PASSWORD="$DEBIT_PASSWORD" -# Make credit user, will be Anastasis client. -CREDIT_USERNAME=anastasis-credit-user -CREDIT_PASSWORD=anastasis-credit-password -echo -n "Create credit user (for anastasis) at Nexus ..." -libeufin-nexus superuser "$CREDIT_USERNAME" --password="$CREDIT_PASSWORD" -echo " OK" -export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME" -export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD" - -prepare_nexus_account \ - ebicsuserCredit \ - ebicspartnerCredit \ - bankconnection-credit \ - nexus-bankaccount-credit \ - sandbox-account-credit - -echo -n "Create facade ..." -libeufin-cli facades new-anastasis-facade \ - --currency="$CURRENCY" \ - --facade-name=facade-credit \ - bankconnection-credit nexus-bankaccount-credit +echo -n "Starting bank ..." +libeufin-bank serve -c "$BANK_CONF" &> libeufin-bank.log & +OK=0 +for n in $(seq 1 50) +do + sleep 0.2 + wget --tries=1 --timeout=1 "${BANK_URL}config" \ + -o /dev/null -O /dev/null >/dev/null || continue + OK=1 + break +done +if [ 1 != $OK ] +then + exit_skip "Could not launch libeufin-bank" +fi echo " OK" -FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \") - -## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD +echo -n "Preparing accounts ..." +libeufin-bank create-account -c "$BANK_CONF" \ + -u "$CREDIT_USERNAME" -p "$CREDIT_PASSWORD" \ + --name "$PERSON_CREDIT_NAME" \ + --payto_uri "$PAYTO_CREDIT" > /dev/null +libeufin-bank create-account -c "$BANK_CONF" \ + -u "$DEBIT_USERNAME" -p "$DEBIT_PASSWORD" \ + --name "Person Debit" \ + --payto_uri "$PAYTO_DEBIT" > /dev/null +# the customer has to be able to send money it does not have +libeufin-bank edit-account -c "$BANK_CONF" \ + --debit_threshold="${CURRENCY}:1000" \ + "$DEBIT_USERNAME" > /dev/null +echo " OK" echo -n "Configuring Anastasis IBAN account ..." anastasis-config -c "$CONF" \ -s authorization-iban \ + -o CURRENCY \ + -V "${CURRENCY}" +anastasis-config -c "$CONF" \ + -s authorization-iban \ -o CREDIT_IBAN \ -V "${IBAN_CREDIT}" anastasis-config -c "$CONF" \ @@ -289,7 +223,7 @@ anastasis-config -c "$CONF" \ anastasis-config -c "$CONF" \ -s authorization-iban \ -o WIRE_GATEWAY_URL \ - -V "${FACADE_URL}" + -V "${BANK_URL}accounts/${CREDIT_USERNAME}/taler-revenue/" anastasis-config -c "$CONF" \ -s authorization-iban \ -o WIRE_GATEWAY_AUTH_METHOD \ @@ -297,11 +231,11 @@ anastasis-config -c "$CONF" \ anastasis-config -c "$CONF" \ -s authorization-iban \ -o USERNAME \ - -V "${LIBEUFIN_NEXUS_USERNAME}" + -V "${CREDIT_USERNAME}" anastasis-config -c "$CONF" \ -s authorization-iban \ -o PASSWORD \ - -V "${LIBEUFIN_NEXUS_PASSWORD}" + -V "${CREDIT_PASSWORD}" echo " OK" echo -n "Launching Anastasis service ..." diff --git a/src/include/anastasis_eufin_lib.h b/src/include/anastasis_eufin_lib.h @@ -15,7 +15,8 @@ */ /** * @file include/anastasis_eufin_lib.h - * @brief C interface to access the Anastasis facade of LibEuFin + * @brief C interface to access the Taler revenue API of a bank + * (e.g. libeufin-bank) * See https://docs.taler.net/TBD * @author Christian Grothoff */ @@ -91,7 +92,7 @@ struct ANASTASIS_EUFIN_AuthenticationData }; -/* ********************* /history/incoming *********************** */ +/* ************************* /history ***************************** */ /** * Handle for querying the bank for transactions @@ -127,7 +128,9 @@ struct ANASTASIS_EUFIN_CreditDetails /** * payto://-URL of the target account that - * received the funds. + * received the funds. The revenue API states this once per + * response, so it is the same for every transaction of one + * history request. */ const char *credit_account_uri; }; @@ -212,7 +215,8 @@ ANASTASIS_EUFIN_credit_history_cancel ( int ANASTASIS_EUFIN_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, - struct ANASTASIS_EUFIN_AuthenticationData *auth); + struct ANASTASIS_EUFIN_AuthenticationData *auth) +; /** diff --git a/src/testing/meson.build b/src/testing/meson.build @@ -55,6 +55,7 @@ test_anastasisrest_api = executable( talermerchanttesting_dep, talertesting_dep, gnunetutil_dep, + json_dep, ], include_directories: [incdir, configuration_inc], install: false, @@ -78,6 +79,7 @@ test_anastasis = executable( talertesting_dep, talerexchange_dep, gnunetutil_dep, + json_dep, ], include_directories: [incdir, configuration_inc], install: false, diff --git a/src/testing/test_anastasis.c b/src/testing/test_anastasis.c @@ -37,36 +37,20 @@ #define EXCHANGE_URL "http://localhost:8081/" /** - * Account number of the exchange at the bank. + * IBAN of the account the merchant is paid into. Unlike the accounts of + * the payer and of the exchange, this one need not exist at the bank: the + * test never runs the aggregator, so nothing is ever transferred to it. */ -#define EXCHANGE_ACCOUNT_NAME "2" +#define MERCHANT_ACCOUNT_IBAN "DE89370400440532013000" /** - * Account number of some user. - */ -#define USER_ACCOUNT_NAME "62" - -/** - * Account number used by the merchant - */ -#define MERCHANT_ACCOUNT_NAME "3" - -/** - * Credentials for the test. + * Credentials for the test. The bank accounts of the payer + * (@e user42_payto) and of the exchange (@e exchange_payto) are the ones + * `taler-unified-setup.sh' registers at libeufin-bank. */ static struct TALER_TESTING_Credentials cred; /** - * Payto URI of the customer (payer). - */ -static struct TALER_FullPayto payer_payto; - -/** - * Payto URI of the exchange (escrow account). - */ -static struct TALER_FullPayto exchange_payto; - -/** * Payto URI of the merchant (receiver). */ static struct TALER_FullPayto merchant_payto; @@ -125,8 +109,8 @@ cmd_transfer_to_exchange (const char *label, { return TALER_TESTING_cmd_admin_add_incoming (label, amount, - &cred.ba, - payer_payto); + &cred.ba_admin, + cred.user42_payto); } @@ -318,12 +302,10 @@ run (void *cls, struct TALER_TESTING_Command commands[] = { /* general setup */ - TALER_TESTING_cmd_run_fakebank ("run-fakebank", - cred.cfg, - "exchange-account-exchange"), TALER_TESTING_cmd_system_start ("start-taler", CONFIG_FILE, - "-em", + "-bem", + "-d", "iban", "-u", "exchange-account-exchange", NULL), TALER_TESTING_cmd_get_exchange ("get-exchange", @@ -331,10 +313,25 @@ run (void *cls, NULL, true, true), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-admin", - merchant_url, - "admin", - MHD_HTTP_NO_CONTENT), + /* Not TALER_TESTING_cmd_merchant_post_instances(): that one gives the + instance a pay delay of two seconds, and the orders here are created + by anastasis-httpd, not by the test, so a slow order creation would + expire the offer before the test gets to pay it. */ + TALER_TESTING_cmd_merchant_post_instances2 ("instance-create-admin", + merchant_url, + "admin", + "admin", + json_pack ("{s:s}", + "city", + "shopcity"), + json_pack ("{s:s}", + "city", + "lawyercity"), + true, /* use STEFAN */ + GNUNET_TIME_UNIT_ZERO, + GNUNET_TIME_UNIT_MINUTES, + NULL, /* auth token */ + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, @@ -373,14 +370,8 @@ main (int argc, dir); } id_data = ANASTASIS_TESTING_make_id_data_example ("MaxMuster123456789"); - payer_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME - "?receiver-name=62"; - exchange_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME - "?receiver-name=exchange"; merchant_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME + (char *) "payto://iban/SANDBOXX/" MERCHANT_ACCOUNT_IBAN "?receiver-name=merchant"; merchant_url = "http://localhost:8080/"; @@ -398,7 +389,7 @@ main (int argc, "INFO", CONFIG_FILE, "exchange-account-exchange", - TALER_TESTING_BS_FAKEBANK, + TALER_TESTING_BS_IBAN, &cred, &run, NULL); diff --git a/src/testing/test_anastasis_api.c b/src/testing/test_anastasis_api.c @@ -37,36 +37,20 @@ #define EXCHANGE_URL "http://localhost:8081/" /** - * Account number of the exchange at the bank. + * IBAN of the account the merchant is paid into. Unlike the accounts of + * the payer and of the exchange, this one need not exist at the bank: the + * test never runs the aggregator, so nothing is ever transferred to it. */ -#define EXCHANGE_ACCOUNT_NAME "2" +#define MERCHANT_ACCOUNT_IBAN "DE89370400440532013000" /** - * Account number of some user. - */ -#define USER_ACCOUNT_NAME "62" - -/** - * Account number used by the merchant - */ -#define MERCHANT_ACCOUNT_NAME "3" - -/** - * Test credentials. + * Test credentials. The bank accounts of the payer (@e user42_payto) and + * of the exchange (@e exchange_payto) are the ones + * `taler-unified-setup.sh' registers at libeufin-bank. */ static struct TALER_TESTING_Credentials cred; /** - * Payto URI of the customer (payer). - */ -static struct TALER_FullPayto payer_payto; - -/** - * Payto URI of the exchange (escrow account). - */ -static struct TALER_FullPayto exchange_payto; - -/** * Payto URI of the merchant (receiver). */ static struct TALER_FullPayto merchant_payto; @@ -119,8 +103,8 @@ cmd_transfer_to_exchange (const char *label, { return TALER_TESTING_cmd_admin_add_incoming (label, amount, - &cred.ba, - payer_payto); + &cred.ba_admin, + cred.user42_payto); } @@ -266,12 +250,10 @@ run (void *cls, struct TALER_TESTING_Command commands[] = { /* general setup */ - TALER_TESTING_cmd_run_fakebank ("run-fakebank", - cred.cfg, - "exchange-account-exchange"), TALER_TESTING_cmd_system_start ("start-taler", CONFIG_FILE, - "-em", + "-bem", + "-d", "iban", "-u", "exchange-account-exchange", NULL), TALER_TESTING_cmd_get_exchange ("get-exchange", @@ -279,10 +261,25 @@ run (void *cls, NULL, true, true), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-admin", - merchant_url, - "admin", - MHD_HTTP_NO_CONTENT), + /* Not TALER_TESTING_cmd_merchant_post_instances(): that one gives the + instance a pay delay of two seconds, and the orders here are created + by anastasis-httpd, not by the test, so a slow order creation would + expire the offer before the test gets to pay it. */ + TALER_TESTING_cmd_merchant_post_instances2 ("instance-create-admin", + merchant_url, + "admin", + "admin", + json_pack ("{s:s}", + "city", + "shopcity"), + json_pack ("{s:s}", + "city", + "lawyercity"), + true, /* use STEFAN */ + GNUNET_TIME_UNIT_ZERO, + GNUNET_TIME_UNIT_MINUTES, + NULL, /* auth token */ + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, @@ -326,14 +323,8 @@ main (int argc, "%s/.secret", dir); } - payer_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME - "?receiver-name=62"; - exchange_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME - "?receiver-name=exchange"; merchant_payto.full_payto = - (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME + (char *) "payto://iban/SANDBOXX/" MERCHANT_ACCOUNT_IBAN "?receiver-name=merchant"; merchant_url = "http://localhost:8080/"; @@ -351,7 +342,7 @@ main (int argc, "INFO", CONFIG_FILE, "exchange-account-exchange", - TALER_TESTING_BS_FAKEBANK, + TALER_TESTING_BS_IBAN, &cred, &run, NULL); diff --git a/src/testing/test_anastasis_api.conf b/src/testing/test_anastasis_api.conf @@ -19,14 +19,20 @@ LOOKAHEAD_SIGN = 12 days LOOKAHEAD_SIGN = 12 days DURATION = 7 days +# The bank is libeufin-bank (see below); this section only survives because +# TALER_TESTING_get_credentials() insists on reading [bank]/HTTP_PORT. [bank] HTTP_PORT = 8082 BASE_URL = http://localhost:8082/ +# libeufin-bank is started by taler-unified-setup.sh (option '-b'); WIRE_TYPE +# must agree with the wire method the tests pass to it ('-d iban'), as that is +# what decides the shape of the payto://-URIs of the accounts it registers. [libeufin-bank] CURRENCY = EUR WIRE_TYPE = iban IBAN_PAYTO_BIC = SANDBOXX +BASE_URL = http://localhost:8082/ DEFAULT_CUSTOMER_DEBT_LIMIT = EUR:200 DEFAULT_ADMIN_DEBT_LIMIT = EUR:2000 REGISTRATION_BONUS_ENABLED = yes @@ -34,6 +40,14 @@ REGISTRATION_BONUS = EUR:100 SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/ SERVE = tcp PORT = 8082 +# a cheap password hash keeps the test fast +PWD_HASH_CONFIG = { "cost": 4 } +# allow HTTP basic authentication, which is what the exchange's wire gateway +# client uses to talk to the bank +PWD_AUTH_COMPAT = yes + +[libeufin-bankdb-postgres] +CONFIG = postgres:///talercheck [anastasis] PORT = 8086 @@ -119,18 +133,25 @@ KEY_DIR = ${TALER_DATA_HOME}/exchange-secmod-cs/keys [exchangedb-postgres] CONFIG = "postgres:///talercheck" +# 'exchange' is one of the accounts taler-unified-setup.sh registers at +# libeufin-bank; the IBAN is the one it hard-codes for that account. [exchange-account-exchange] -PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=exchange" +PAYTO_URI = "payto://iban/SANDBOXX/DE989651?receiver-name=Exchange+Company" ENABLE_DEBIT = YES ENABLE_CREDIT = YES [exchange-accountcredentials-exchange] -WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" -WIRE_GATEWAY_AUTH_METHOD = NONE +WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" +WIRE_GATEWAY_AUTH_METHOD = basic +USERNAME = exchange +PASSWORD = password [admin-accountcredentials-exchange] -WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/" -WIRE_GATEWAY_AUTH_METHOD = NONE +WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" +WIRE_GATEWAY_AUTH_METHOD = basic +USERNAME = admin +# the password taler-unified-setup.sh gives the bank's admin account +PASSWORD = secret-password [coin_eur_ct_1] value = EUR:0.01