gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: add draft for testcase for #6363


From: gnunet
Subject: [taler-merchant] branch master updated: add draft for testcase for #6363
Date: Thu, 13 Apr 2023 19:27:23 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 1ccb665a add draft for testcase for #6363
1ccb665a is described below

commit 1ccb665a36d01465e6ed810b92f7646ac50e0880
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Apr 13 19:27:21 2023 +0200

    add draft for testcase for #6363
---
 src/testing/initialize_taler_system.sh |   6 +-
 src/testing/test_merchant_wirewatch.sh | 318 +++++++++++++++++++++++++++++++++
 src/testing/test_template.conf         |   9 +
 3 files changed, 332 insertions(+), 1 deletion(-)

diff --git a/src/testing/initialize_taler_system.sh 
b/src/testing/initialize_taler_system.sh
index 2b5cc50a..153121d2 100755
--- a/src/testing/initialize_taler_system.sh
+++ b/src/testing/initialize_taler_system.sh
@@ -133,7 +133,7 @@ gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
 AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
 
 # patch configuration
-TALER_DB=talercheck
+export TALER_DB=talercheck
 taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
 taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
 taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
@@ -160,6 +160,10 @@ echo "Setting up libeufin ..."
 # reset libeufin database
 rm -f $TALER_DB
 taler-bank-manage-testing $NEXUS_PORT $TALER_DB $EXCHANGE_URL $CONF
+
+
+
+
 echo -n "Setting up exchange ..."
 # reset database
 dropdb $TALER_DB >/dev/null 2>/dev/null || true
diff --git a/src/testing/test_merchant_wirewatch.sh 
b/src/testing/test_merchant_wirewatch.sh
new file mode 100755
index 00000000..6ff7ab0c
--- /dev/null
+++ b/src/testing/test_merchant_wirewatch.sh
@@ -0,0 +1,318 @@
+#!/bin/bash
+# This file is part of TALER
+# Copyright (C) 2014-2023 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or
+# (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with TALER; see the file COPYING.  If not, see
+# <http://www.gnu.org/licenses/>
+#
+# Testcase for #6363 (WiP)
+
+. initialize_taler_system.sh
+
+# NEXUS_PORT is from the initialize_taler_systems.sh script
+export NEXUS_PORT
+
+# 'talerebics' is used in taler-bank-manage-testing
+export EBICS_HOST="talerebics"
+
+# These are also from taler-bank-manage-testing
+export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:${TALER_DB}"
+export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret"
+export LIBEUFIN_SANDBOX_URL="http://localhost:1${NEXUS_PORT}/";
+
+export GNUNET_PAYTO=`get_payto_uri gnunet x`
+
+export LIBEUFIN_SANDBOX_USERNAME="admin"
+export EBICS_USER_ID="gnunet_ebics"
+export EBICS_PARTNER="gnunet_partner"
+export BANK_CONNECTION_NAME="gnunet-connection"
+export NEXUS_ACCOUNT_NAME="gnunet_credit"
+# 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:${NEXUS_PORT}";
+# These two are from taler-bank-manage-testing...
+
+# Make credit user, will be Merchant client.
+CREDIT_USERNAME=`taler-config -c $CONF \
+  -s "taler-merchant-wirewatch" \
+  -o "USERNAME"`
+CREDIT_PASSWORD=`taler-config -c $CONF \
+  -s "taler-merchant-wirewatch" \
+  -o "PASSWORD"`
+
+echo -n "Create credit user (for gnunet-merchant) at Nexus ..."
+
+export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:${TALER_DB}"
+libeufin-nexus superuser "$CREDIT_USERNAME" --password="$CREDIT_PASSWORD"
+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}
+
+libeufin-cli \
+    connections \
+    new-ebics-connection \
+    --ebics-url="${SANDBOX_URL}ebicsweb" \
+    --host-id=${EBICS_HOST} \
+    --partner-id={$EBICS_PARTNER} \
+    --ebics-user-id=${NEXUS_ACCOUNT_NAME} \
+    ${BANK_CONNECTION_NAME}
+
+echo "FIXME-MS: next step fails, dropping into shell"
+bash
+
+# FIXME-MS: This step fails with a 500 error (code 9000!)
+libeufin-cli \
+    connections \
+    connect \
+    ${BANK_CONNECTION_NAME}
+
+libeufin-cli \
+    connections \
+    download-bank-accounts \
+    ${BANK_CONNECTION_NAME}
+libeufin-cli \
+    connections \
+    import-bank-account \
+    --offered-account-id=${SANDBOX_ACCOUNT_NAME} \
+    --nexus-bank-account-id=${NEXUS_ACCOUNT_NAME}
+    ${BANK_CONNECTION_NAME}
+
+libeufin-cli \
+    facades \
+    new-anastasis-facade \
+  --currency=TESTKUDOS \
+  --facade-name=${GNUNET_CREDIT_FACADE} \
+    ${BANK_CONNECTION_NAME} \
+    ${NEXUS_ACCOUNT_NAME}
+
+FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \")
+
+echo -n "Setting FACADE URL in configuration"
+taler-config -c $CONF \
+  -s "taler-merchant-wirewatch" \
+  -o "WIRE_GATEWAY_URL" \
+  -V "${FACADE_URL}"
+echo " OK"
+
+echo -n "First prepare wallet with coins..."
+rm $WALLET_DB
+taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api --expect-success 
'withdrawTestBalance' \
+  "$(jq -n '
+    {
+        amount: "TESTKUDOS:99",
+        bankBaseUrl: $BANK_URL,
+        exchangeBaseUrl: $EXCHANGE_URL
+    }' \
+    --arg BANK_URL "$BANK_URL/access-api/" \
+    --arg EXCHANGE_URL "$EXCHANGE_URL"
+  )" 2>wallet-withdraw-1.err >wallet-withdraw-1.out
+taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 
2>wallet-withdraw-finish-1.err >wallet-withdraw-finish-1.out
+echo " OK"
+
+#
+# CREATE INSTANCE FOR TESTING
+#
+
+echo -n "Configuring merchant default instance ..."
+TOR_PAYTO=`get_payto_uri tor x`
+GNUNET_PAYTO=`get_payto_uri gnunet x`
+# create with 2 address
+
+STATUS=$(curl -H "Content-Type: application/json" -X POST \
+    -H 'Authorization: Bearer secret-token:super_secret' \
+    http://localhost:9966/management/instances \
+    -d 
'{"auth":{"method":"external"},"payto_uris":["'$TOR_PAYTO'","'$GNUNET_PAYTO'"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1",
 
"default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us"
 : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+    -w "%{http_code}" -s -o /dev/null)
+
+if [ "$STATUS" != "204" ]
+then
+    echo 'should respond ok, instance created. got:' $STATUS
+    exit 1
+fi
+
+echo OK
+
+
+echo -n "Configuring merchant test instance ..."
+SURVEY_PAYTO=`get_payto_uri survey x`
+TUTORIAL_PAYTO=`get_payto_uri tutorial x`
+# create with 2 address
+
+STATUS=$(curl -H "Content-Type: application/json" -X POST \
+    -H 'Authorization: Bearer secret-token:super_secret' \
+    http://localhost:9966/management/instances \
+    -d 
'{"auth":{"method":"external"},"payto_uris":["'$SURVEY_PAYTO'","'$TUTORIAL_PAYTO'"],"id":"test","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1",
 
"default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us"
 : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
+    -w "%{http_code}" -s -o /dev/null)
+
+if [ "$STATUS" != "204" ]
+then
+    echo 'should respond ok, instance created. got:' $STATUS
+    exit 1
+fi
+echo OK
+
+RANDOM_IMG='data:image/png;base64,abcdefg'
+
+# CREATE ORDER AND SELL IT
+echo -n "Creating order to be paid..."
+STATUS=$(curl 'http://localhost:9966/instances/test/private/orders' \
+    -d '{"order":{"amount":"TESTKUDOS:1","summary":"payme"}}' \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    echo 'should respond ok, order created. got:' $STATUS `cat $LAST_RESPONSE`
+    exit 1
+fi
+
+ORDER_ID=`jq -e -r .order_id < $LAST_RESPONSE`
+TOKEN=`jq -e -r .token < $LAST_RESPONSE`
+
+STATUS=$(curl 
"http://localhost:9966/instances/test/private/orders/${ORDER_ID}"; \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    echo 'should respond ok, getting order info before claming it. got:' 
$STATUS `cat $LAST_RESPONSE`
+    exit 1
+fi
+PAY_URL=`jq -e -r .taler_pay_uri < $LAST_RESPONSE`
+echo OK
+
+NOW=`date +%s`
+echo -n "Pay first order ..."
+taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB handle-uri "${PAY_URL}" 
-y 2> wallet-pay1.err > wallet-pay1.log
+NOW2=`date +%s`
+echo " OK (took $( echo -n $(($NOW2 - $NOW))) secs)"
+
+STATUS=$(curl 
"http://localhost:9966/instances/test/private/orders/${ORDER_ID}"; \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    echo 'should respond ok, after pay. got:' $STATUS `cat $LAST_RESPONSE`
+    exit 1
+fi
+
+ORDER_STATUS=`jq -r .order_status < $LAST_RESPONSE`
+
+if [ "$ORDER_STATUS" != "paid" ]
+then
+    echo 'order should be paid. got:' $ORDER_STATUS `cat $LAST_RESPONSE`
+    exit 1
+fi
+
+#
+# WIRE TRANSFER TO MERCHANT AND NOTIFY BACKEND
+#
+
+PAY_DEADLINE=`jq -r .contract_terms.pay_deadline.t_s < $LAST_RESPONSE`
+WIRE_DEADLINE=`jq -r .contract_terms.wire_transfer_deadline.t_s < 
$LAST_RESPONSE`
+
+NOW=`date +%s`
+
+TO_SLEEP=`echo $(( $WIRE_DEADLINE - $NOW ))`
+echo "waiting $TO_SLEEP secs for wire transfer"
+
+echo -n "Perform wire transfers ..."
+taler-exchange-aggregator -y -c $CONF -T ${TO_SLEEP}000000 -t -L INFO &> 
aggregator.log
+taler-exchange-transfer -c $CONF -t -L INFO &> transfer.log
+echo " DONE"
+
+echo -n "waiting for Nexus and Sandbox to settle the payment .."
+sleep 3
+echo " DONE"
+
+echo -n "Obtaining wire transfer details from bank..."
+taler-merchant-wirewatch -t -L INFO &> merchant-wirewatch.log
+echo " OK"
+
+echo -n "Fetching wire transfers of DEFAULT instance ..."
+
+STATUS=$(curl 'http://localhost:9966/instances/default/private/transfers' \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    jq . < $LAST_RESPONSE
+    exit_fail "Expected response 200 Ok. got: $STATUS"
+fi
+
+TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+
+if [ "$TRANSFERS_LIST_SIZE" != "1" ]
+then
+    jq . < $LAST_RESPONSE
+    exit_fail "Expected one transfer. got: $TRANSFERS_LIST_SIZE"
+fi
+
+echo "OK"
+
+echo -n "Fetching wire transfers of 'test' instance ..."
+
+STATUS=$(curl 'http://localhost:9966/instances/test/private/transfers' \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    jq . < $LAST_RESPONSE
+    exit_fail "Expected response 200 Ok. got: $STATUS"
+fi
+
+TRANSFERS_LIST_SIZE=`jq -r '.transfers | length' < $LAST_RESPONSE`
+
+if [ "$TRANSFERS_LIST_SIZE" != "0" ]
+then
+    jq . < $LAST_RESPONSE
+    exit_fail "Expected response ok. got: $STATUS"
+fi
+
+echo "OK"
+
+
+echo -n "Checking order status ..."
+STATUS=$(curl 
"http://localhost:9966/instances/test/private/orders/${ORDER_ID}?transfer=YES"; \
+    -w "%{http_code}" -s -o $LAST_RESPONSE)
+
+if [ "$STATUS" != "200" ]
+then
+    jq . < $LAST_RESPONSE
+    exit_fail 'should response ok, after order inquiry. got:' $STATUS `cat 
$LAST_RESPONSE`
+    exit 1
+fi
+
+WAS_WIRED=`jq -r .wired < $LAST_RESPONSE`
+
+if [ "$WAS_WIRED" != "true" ]
+then
+    jq . < $LAST_RESPONSE
+    echo '.wired false, expected true'
+    exit 1
+fi
+
+echo " OK"
+
+exit 0
diff --git a/src/testing/test_template.conf b/src/testing/test_template.conf
index 4f406ace..92032259 100644
--- a/src/testing/test_template.conf
+++ b/src/testing/test_template.conf
@@ -46,6 +46,15 @@ DEFAULT_MAX_WIRE_FEE = TESTKUDOS:0.10
 # Ensure that merchant reports EVERY deposit confirmation to auditor
 FORCE_AUDIT = YES
 
+[taler-merchant-wirewatch]
+INSTANCE = "default"
+# This one will be set by test_merchant_wirewatch.sh
+# WIRE_GATEWAY_URL =
+WIRE_GATEWAY_AUTH_METHOD = BASIC
+USERNAME = merchant-wirewatch
+PASSWORD = merchant-wirewatch-password
+
+
 [auditor]
 DB = postgres
 AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]