merchant

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

commit 3015d13f6e6d11faa8348772756b1a56931de4fd
parent 8178e10981eaba0a5f08f6f2681861d105f8b0c7
Author: Sebastian <sebasjm@gmail.com>
Date:   Mon,  6 Dec 2021 12:51:01 -0300

fixing: unable to use default instance if it was not the first created

if the first instance created is not the default instance then the next access to the default instance is not possible since:

 * default_auth is set to null in taler-merchant-httpd_private-post-instances:463
 * TMH_lookup_instance will not find default instance in taler-merchant-httpd:1153
 * auth_ok will be always false in line 1385
    - multihashmap_size > 0
    - default_auth == NULL
    - hc->instance == NULL

disabling any instance creation, even default instance until restart
restarting the service will load the default_auth again allowing the
access to the default instance again

Diffstat:
Msrc/backend/taler-merchant-httpd_private-post-instances.c | 9+++++++--
Asrc/testing/test_merchant_instance_creation.sh | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/testing/test_merchant_order_creation.sh | 2--
3 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -453,8 +453,13 @@ retry: TMH_reload_instances (mi->settings.id); } GNUNET_JSON_parse_free (spec); - GNUNET_free (TMH_default_auth); /* clear it: user just either created default - instance or it should already be NULL */ + if (0 == strcmp (is.id, + "default")) + { + GNUNET_free (TMH_default_auth); /* clear it if the default instance was + created */ + } + return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, NULL, diff --git a/src/testing/test_merchant_instance_creation.sh b/src/testing/test_merchant_instance_creation.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# This file is part of TALER +# Copyright (C) 2014-2021 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/> +# + +. initialize_taler_system.sh + + +echo -n "Configuring a merchant instance before configuring the default instance ..." + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + http://localhost:9966/management/instances \ + -d '{"auth":{"method":"token","token":"secret-token:other_secret"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"first","name":"test","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' \ + -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 default 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"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' \ + -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 a second merchant instance ..." + +STATUS=$(curl -H "Content-Type: application/json" -X POST \ + http://localhost:9966/management/instances \ + -d '{"auth":{"method":"token","token":"secret-token:other_secret"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"second","name":"test","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' \ + -w "%{http_code}" -s -o /dev/null) + +if [ "$STATUS" != "204" ] +then + echo 'should respond ok, instance created. got:' $STATUS + exit 1 +fi + +echo " OK" + + +exit 0 diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh @@ -3,8 +3,6 @@ set -eu -set -x - . initialize_taler_system.sh echo -n "First prepare wallet with coins..."