gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: fixing: unable to use default in


From: gnunet
Subject: [taler-merchant] branch master updated: fixing: unable to use default instance if it was not the first created
Date: Mon, 06 Dec 2021 16:54:16 +0100

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

sebasjm pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 3015d13f fixing: unable to use default instance if it was not the 
first created
3015d13f is described below

commit 3015d13f6e6d11faa8348772756b1a56931de4fd
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Dec 6 12:51:01 2021 -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
---
 .../taler-merchant-httpd_private-post-instances.c  |  9 ++-
 src/testing/test_merchant_instance_creation.sh     | 70 ++++++++++++++++++++++
 src/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
index 71be2673..0ab7fce6 100644
--- 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
new file mode 100755
index 00000000..04410a56
--- /dev/null
+++ 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
index 04ee34ea..3ab07406 100755
--- 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..."

-- 
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]