merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 0922dcdf0cf7bb584e78e6ee2c038032a4b27fd2
parent 968865572e61929567730cb22c26e135372c3ae1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  5 Sep 2025 13:01:41 +0200

skeleton for MFA test

Diffstat:
Asrc/testing/test_email_helper.sh | 5+++++
Asrc/testing/test_merchant_mfa.conf | 30++++++++++++++++++++++++++++++
Asrc/testing/test_merchant_mfa.sh | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/testing/test_sms_helper.sh | 5+++++
4 files changed, 132 insertions(+), 0 deletions(-)

diff --git a/src/testing/test_email_helper.sh b/src/testing/test_email_helper.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# This file is in the public domain. +echo "$1" > /tmp/test-merchant-email-address.txt +cat - > /tmp/test-merchant-email-tan.txt +exit 0 diff --git a/src/testing/test_merchant_mfa.conf b/src/testing/test_merchant_mfa.conf @@ -0,0 +1,30 @@ +# This file is in the public domain. +# +[PATHS] +TALER_TEST_HOME = test_merchant_api_home/ + +[merchant-exchange-chf] +DISABLED = YES + +[merchant-exchange-kudos] +DISABLED = YES + +[merchant] +PORT = 9966 +SERVE = tcp +DB = postgres + +HELPER_SMS = test_sms_helper.sh +HELPER_EMAIL = test_email_helper.sh +MANDATORY_TAN_CHANNELS = sms email + + +# This specifies which database the postgres backend uses. +[merchantdb-postgres] +CONFIG = postgres:///talercheck +SQL_DIR = ${DATADIR}sql/ + +[merchant-exchange-test] +MASTER_KEY = KHA6YSPRQV1ZFCF144SY8KJNR588XA8DA0F6510FKJW30DJFJNAG +EXCHANGE_BASE_URL = http://localhost:8081/ +CURRENCY = EUR diff --git a/src/testing/test_merchant_mfa.sh b/src/testing/test_merchant_mfa.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# This file is part of TALER +# Copyright (C) 2025 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/> +# +set -eu + +. setup.sh + + +# Launch system. +setup \ + -c "test_merchant_mfa.conf" \ + -m +LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) + +echo -n "Configuring a merchant admin instance ..." + +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"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -w "%{http_code}" -s \ + -o "$LAST_RESPONSE") + +if [ "$STATUS" != "204" ] +then + jq < "$LAST_RESPONSE" + exit_fail "Expected 204 ok, instance created. got: $STATUS" +fi + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:super_secret' \ + http://localhost:9966/private/accounts \ + -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user43"}' \ + -w "%{http_code}" -s \ + -o "$LAST_RESPONSE") + + +if [ "$STATUS" != "200" ] +then + jq < "$LAST_RESPONSE" + exit_fail "Expected 200 OK. Got: $STATUS" +fi + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + -H 'Authorization: Bearer secret-token:super_secret' \ + http://localhost:9966/private/accounts \ + -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/44?receiver-name=user44"}' \ + -w "%{http_code}" -s \ + -o "$LAST_RESPONSE") + + +if [ "$STATUS" != "200" ] +then + jq < "$LAST_RESPONSE" + exit_fail "Expected 200 OK. Got: $STATUS" +fi + +echo " OK" + +echo -n "Check the instance exists ..." + +STATUS=$(curl -H "Content-Type: application/json" -X GET \ + http://localhost:9966/private/ \ + -w "%{http_code}" -s \ + -o "$LAST_RESPONSE") + +if [ "$STATUS" != "200" ] +then + jq < "$LAST_RESPONSE" + exit_fail "Expected 200 ok, instance exists. got: $STATUS" +fi + +echo " OK" + +echo "TEST PASSED" + +exit 0 diff --git a/src/testing/test_sms_helper.sh b/src/testing/test_sms_helper.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# This file is in the public domain. +echo "$1" > /tmp/test-merchant-sms-address.txt +cat - > /tmp/test-merchant-sms-tan.txt +exit 0