diff options
Diffstat (limited to 'src/testing/test_merchant_wirewatch.sh')
-rwxr-xr-x | src/testing/test_merchant_wirewatch.sh | 263 |
1 files changed, 149 insertions, 114 deletions
diff --git a/src/testing/test_merchant_wirewatch.sh b/src/testing/test_merchant_wirewatch.sh index 7834c1d0..b8a37f2f 100755 --- a/src/testing/test_merchant_wirewatch.sh +++ b/src/testing/test_merchant_wirewatch.sh @@ -19,109 +19,128 @@ # Testcase for #6363 (WiP) set -eu -echo "Re-initializing database (needed for current libeufin)" # FIXME-MS: enable idempotency AND db-reset! -dropdb talercheck || true -createdb talercheck +# Replace with 0 for nexus... +USE_FAKEBANK=1 +if [ 1 = "$USE_FAKEBANK" ] +then + ACCOUNT="exchange-account-2" + WIRE_METHOD="x-taler-bank" + BANK_FLAGS="-f -d $WIRE_METHOD -u $ACCOUNT" + BANK_URL="http://localhost:8082/taler-bank-access/" +else + ACCOUNT="exchange-account-1" + WIRE_METHOD="iban" + BANK_FLAGS="-ns -d $WIRE_METHOD -u $ACCOUNT" + BANK_URL="http://localhost:18082/demobanks/default/access-api/" +fi . setup.sh # Launch exchange, merchant and bank. -setup -c "test_template.conf" -enms -u "exchange-account-1" -d "iban" -LAST_RESPONSE=$(mktemp test_response.conf-XXXXXX) +setup -c "test_template.conf" \ + -em \ + $BANK_FLAGS +LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) CONF="test_template.conf.edited" -WALLET_DB=$(mktemp test_wallet.json-XXXXXX) -BANK_URL="http://localhost:18082/demobanks/default/" +WALLET_DB=$(mktemp -p "${TMPDIR:-/tmp}" test_wallet.json-XXXXXX) EXCHANGE_URL="http://localhost:8081/" -export LIBEUFIN_SANDBOX_DB_CONNECTION='postgresql:///talercheck' -export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret" -export LIBEUFIN_SANDBOX_URL="http://localhost:18082/" - -export EBICS_HOST="talerebics" -export LIBEUFIN_SANDBOX_USERNAME="admin" -export LIBEUFIN_SANDBOX_PASSWORD="secret" -export EBICS_USER_ID="gnunet_ebics" -export EBICS_PARTNER="GnunetPartner" -export BANK_CONNECTION_NAME="gnunet-connection" -export NEXUS_ACCOUNT_NAME="GnunetCredit" -# The 'gnunet' account is created by -# taler-bank-manage-testing and used for -# the 'default' instance, so this must be used here. -export SANDBOX_ACCOUNT_NAME="gnunet" - -export LIBEUFIN_NEXUS_URL="http://localhost:8082" -# These two are from taler-bank-manage-testing... - -# Define credentials for wirewatch user, will be Merchant client. -CREDIT_USERNAME="merchant-wirewatch" -CREDIT_PASSWORD="merchant-wirewatch-password" - -echo -n "Create credit user (for gnunet-merchant) at Nexus ..." - -export LIBEUFIN_NEXUS_DB_CONNECTION='postgresql:///talercheck' -libeufin-nexus \ - superuser "$CREDIT_USERNAME" \ - --password="$CREDIT_PASSWORD" \ - &> nexus-credit-create.log -echo " OK" -export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME" -export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD" -export GNUNET_CREDIT_FACADE=facade-gnunet-credit - -libeufin-cli sandbox \ - demobank \ - new-ebicssubscriber \ - --host-id ${EBICS_HOST} \ - --user-id ${NEXUS_ACCOUNT_NAME} \ - --partner-id ${EBICS_PARTNER} \ - --bank-account ${SANDBOX_ACCOUNT_NAME} \ - &> sandbox-subscriber-create.log - -libeufin-cli \ - connections \ - new-ebics-connection \ - --ebics-url="${LIBEUFIN_SANDBOX_URL}ebicsweb" \ - --host-id=${EBICS_HOST} \ - --partner-id=${EBICS_PARTNER} \ - --ebics-user-id=${NEXUS_ACCOUNT_NAME} \ - ${BANK_CONNECTION_NAME} \ - &> nexus-connection-create.log - -libeufin-cli \ - connections \ - connect \ - ${BANK_CONNECTION_NAME} \ - &> nexus-connection-connect.log - -libeufin-cli \ - connections \ - download-bank-accounts \ - ${BANK_CONNECTION_NAME} \ - &> nexus-account-download.log - -libeufin-cli \ - connections \ - import-bank-account \ - --offered-account-id=${SANDBOX_ACCOUNT_NAME} \ - --nexus-bank-account-id=${NEXUS_ACCOUNT_NAME} \ - ${BANK_CONNECTION_NAME} \ - &> nexus-account-import.log - -libeufin-cli \ - facades \ - new-anastasis-facade \ - --currency=TESTKUDOS \ - --facade-name=${GNUNET_CREDIT_FACADE} \ - ${BANK_CONNECTION_NAME} \ - ${NEXUS_ACCOUNT_NAME} \ - &> nexus-new-facade.log - -FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \") - -# FIXME: is this correct? Strange to use the super-user -# credentials here! -FACADE_USERNAME="${CREDIT_USERNAME}" -FACADE_PASSWORD="${CREDIT_PASSWORD}" +if [ 1 = "$USE_FAKEBANK" ] +then + FACADE_URL="http://localhost:8082/anastasis-api/gnunet/" + FACADE_USERNAME="gnunet" + FACADE_PASSWORD="x" +else + export LIBEUFIN_SANDBOX_DB_CONNECTION='postgresql:///talercheck' + export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret" + export LIBEUFIN_SANDBOX_URL="http://localhost:18082/" + + export EBICS_HOST="talerebics" + export LIBEUFIN_SANDBOX_USERNAME="admin" + export LIBEUFIN_SANDBOX_PASSWORD="secret" + export EBICS_USER_ID="gnunet_ebics" + export EBICS_PARTNER="GnunetPartner" + export BANK_CONNECTION_NAME="gnunet-connection" + export NEXUS_ACCOUNT_NAME="GnunetCredit" + # The 'gnunet' account is created by + # taler-bank-manage-testing and used for + # the 'default' instance, so this must be used here. + export SANDBOX_ACCOUNT_NAME="gnunet" + + export LIBEUFIN_NEXUS_URL="http://localhost:8082" + # These two are from taler-bank-manage-testing... + + # Define credentials for wirewatch user, will be Merchant client. + CREDIT_USERNAME="merchant-wirewatch" + CREDIT_PASSWORD="merchant-wirewatch-password" + + echo -n "Create credit user (for gnunet-merchant) at Nexus ..." + + export LIBEUFIN_NEXUS_DB_CONNECTION='postgresql:///talercheck' + libeufin-nexus \ + superuser "$CREDIT_USERNAME" \ + --password="$CREDIT_PASSWORD" \ + &> nexus-credit-create.log + echo " OK" + export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME" + export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD" + export GNUNET_CREDIT_FACADE=facade-gnunet-credit + + libeufin-cli sandbox \ + demobank \ + new-ebicssubscriber \ + --host-id ${EBICS_HOST} \ + --user-id ${NEXUS_ACCOUNT_NAME} \ + --partner-id ${EBICS_PARTNER} \ + --bank-account ${SANDBOX_ACCOUNT_NAME} \ + &> sandbox-subscriber-create.log + + libeufin-cli \ + connections \ + new-ebics-connection \ + --ebics-url="${LIBEUFIN_SANDBOX_URL}ebicsweb" \ + --host-id=${EBICS_HOST} \ + --partner-id=${EBICS_PARTNER} \ + --ebics-user-id=${NEXUS_ACCOUNT_NAME} \ + ${BANK_CONNECTION_NAME} \ + &> nexus-connection-create.log + + libeufin-cli \ + connections \ + connect \ + ${BANK_CONNECTION_NAME} \ + &> nexus-connection-connect.log + + libeufin-cli \ + connections \ + download-bank-accounts \ + ${BANK_CONNECTION_NAME} \ + &> nexus-account-download.log + + libeufin-cli \ + connections \ + import-bank-account \ + --offered-account-id=${SANDBOX_ACCOUNT_NAME} \ + --nexus-bank-account-id=${NEXUS_ACCOUNT_NAME} \ + ${BANK_CONNECTION_NAME} \ + &> nexus-account-import.log + + libeufin-cli \ + facades \ + new-anastasis-facade \ + --currency=TESTKUDOS \ + --facade-name=${GNUNET_CREDIT_FACADE} \ + ${BANK_CONNECTION_NAME} \ + ${NEXUS_ACCOUNT_NAME} \ + &> nexus-new-facade.log + + FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \") + + # FIXME: is this correct? Strange to use the super-user + # credentials here! + FACADE_USERNAME="${CREDIT_USERNAME}" + FACADE_PASSWORD="${CREDIT_PASSWORD}" +fi echo -n "First prepare wallet with coins..." rm -f "${WALLET_DB}" @@ -133,21 +152,29 @@ taler-wallet-cli \ "$(jq -n ' { amount: "TESTKUDOS:99", - bankAccessApiBaseUrl: $BANK_ACCESS_API_URL, + bankAccessApiBaseUrl: $BANK_URL, exchangeBaseUrl: $EXCHANGE_URL }' \ - --arg BANK_URL "$BANK_URL/access-api/" \ - --arg BANK_ACCESS_API_URL "$BANK_URL/access-api/" \ + --arg BANK_URL "$BANK_URL" \ --arg EXCHANGE_URL "$EXCHANGE_URL" )" 2>wallet-withdraw-1.err >wallet-withdraw-1.out -# FIXME-MS: add logic to have nexus check immediately here. echo -n "." -sleep 10 -# NOTE: once libeufin can do long-polling, we should -# be able to reduce the delay here and run wirewatch -# always in the background via setup +if [ 1 = "$USE_FAKEBANK" ] +then + # Fakebank is instant... + sleep 0 +else + sleep 10 + # NOTE: once libeufin can do long-polling, we should + # be able to reduce the delay here and run wirewatch + # always in the background via setup +fi echo -n "." -taler-exchange-wirewatch -L "INFO" -c "$CONF" -t &> taler-exchange-wirewatch.out +taler-exchange-wirewatch \ + -L "INFO" \ + -c "$CONF" \ + -t \ + &> taler-exchange-wirewatch.out echo -n "." taler-wallet-cli \ --wallet-db="$WALLET_DB" \ @@ -161,7 +188,12 @@ echo " OK" # echo -n "Configuring merchant default instance ..." -GNUNET_PAYTO=$(get_payto_uri gnunet x) +if [ 1 = "$USE_FAKEBANK" ] +then + GNUNET_PAYTO="payto://x-taler-bank/localhost/gnunet?receiver-name=gnunet" +else + GNUNET_PAYTO=$(get_payto_uri gnunet x) +fi STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ @@ -248,14 +280,17 @@ taler-exchange-transfer\ -L INFO &> transfer.log echo " DONE" -echo -n "Waiting for Nexus and Sandbox to settle the payment ..." -sleep 3 # FIXME-MS: replace with call to Nexus to right now poll the sandbox ... -libeufin-cli \ - accounts \ - fetch-transactions \ - ${NEXUS_ACCOUNT_NAME} \ - &> libeufin-transfer-fetch.out -echo " DONE" +if [ 1 != "$USE_FAKEBANK" ] +then + echo -n "Waiting for Nexus and Sandbox to settle the payment ..." + sleep 3 # FIXME-MS: replace with call to Nexus to right now poll the sandbox ... + libeufin-cli \ + accounts \ + fetch-transactions \ + ${NEXUS_ACCOUNT_NAME} \ + &> libeufin-transfer-fetch.out + echo " DONE" +fi echo -n "Obtaining wire transfer details from bank..." taler-merchant-wirewatch \ |