gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: small steps towards removing har


From: gnunet
Subject: [taler-exchange] branch master updated: small steps towards removing hard-coded exchange account
Date: Sat, 18 Jan 2020 03:51:00 +0100

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

dold pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 08a44798 small steps towards removing hard-coded exchange account
08a44798 is described below

commit 08a447985c598561555a00e15b83f84ece79ceb8
Author: Florian Dold <address@hidden>
AuthorDate: Sat Jan 18 03:50:54 2020 +0100

    small steps towards removing hard-coded exchange account
---
 src/include/taler_testing_lib.h             |  1 +
 src/lib/test_bank_api.c                     |  1 +
 src/lib/test_bank_api_fakebank_twisted.conf |  3 ++
 src/lib/test_bank_api_twisted.c             |  1 +
 src/lib/testing_api_helpers_bank.c          | 57 ++++++++++++++++++++++-------
 5 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 5ed625eb..2631d581 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -801,6 +801,7 @@ TALER_TESTING_run_fakebank (const char *bank_url);
  */
 int
 TALER_TESTING_prepare_bank (const char *config_filename,
+                            const char *config_section,
                             struct TALER_TESTING_BankConfiguration *bc);
 
 
diff --git a/src/lib/test_bank_api.c b/src/lib/test_bank_api.c
index b1257617..c6049c01 100644
--- a/src/lib/test_bank_api.c
+++ b/src/lib/test_bank_api.c
@@ -157,6 +157,7 @@ main (int argc,
     cfgfilename = CONFIG_FILE_PYBANK;
     if (GNUNET_OK !=
         TALER_TESTING_prepare_bank (CONFIG_FILE_PYBANK,
+                                    "account-2",
                                     &bc))
     {
       GNUNET_break (0);
diff --git a/src/lib/test_bank_api_fakebank_twisted.conf 
b/src/lib/test_bank_api_fakebank_twisted.conf
index 49ed4d53..4455ac74 100644
--- a/src/lib/test_bank_api_fakebank_twisted.conf
+++ b/src/lib/test_bank_api_fakebank_twisted.conf
@@ -29,3 +29,6 @@ database = postgres:///talercheck
 
 [account-1]
 URL = payto://x-taler-bank/localhost:8081/1
+
+[account-2]
+URL = payto://x-taler-bank/localhost:8081/2
diff --git a/src/lib/test_bank_api_twisted.c b/src/lib/test_bank_api_twisted.c
index daaa5afa..a1452804 100644
--- a/src/lib/test_bank_api_twisted.c
+++ b/src/lib/test_bank_api_twisted.c
@@ -178,6 +178,7 @@ main (int argc,
     TALER_LOG_DEBUG ("Running against the Pybank.\n");
     if (GNUNET_OK !=
         TALER_TESTING_prepare_bank (cfgfilename,
+                                    "account-2",
                                     &bc))
     {
       GNUNET_break (0);
diff --git a/src/lib/testing_api_helpers_bank.c 
b/src/lib/testing_api_helpers_bank.c
index d6fac4bd..5fcc5022 100644
--- a/src/lib/testing_api_helpers_bank.c
+++ b/src/lib/testing_api_helpers_bank.c
@@ -27,8 +27,6 @@
 #include "taler_testing_lib.h"
 #include "taler_fakebank_lib.h"
 
-#define EXCHANGE_ACCOUNT_NAME "2"
-
 #define BANK_FAIL() \
   do {GNUNET_break (0); return NULL; } while (0)
 
@@ -227,6 +225,7 @@ TALER_TESTING_run_bank (const char *config_filename,
  */
 int
 TALER_TESTING_prepare_bank (const char *config_filename,
+                            const char *config_section,
                             struct TALER_TESTING_BankConfiguration *bc)
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -235,6 +234,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
   enum GNUNET_OS_ProcessStatusType type;
   unsigned long code;
   char *database;
+  char *exchange_payto_uri;
 
   cfg = GNUNET_CONFIGURATION_create ();
 
@@ -259,6 +259,19 @@ TALER_TESTING_prepare_bank (const char *config_filename,
     return GNUNET_SYSERR;
   }
 
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             config_section,
+                                             "URL", /* FIXME: config should be 
renamed to payto_uri, it's not an url even! */
+                                             &exchange_payto_uri))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                               config_section,
+                               "URL");
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return GNUNET_SYSERR;
+  }
+
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg,
                                              "bank",
@@ -340,7 +353,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
   GNUNET_OS_process_destroy (dbreset_proc);
   if (GNUNET_OK !=
       TALER_BANK_auth_parse_cfg (cfg,
-                                 "account-" EXCHANGE_ACCOUNT_NAME,
+                                 config_section,
                                  &bc->exchange_auth))
   {
     GNUNET_break (0);
@@ -350,7 +363,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
   GNUNET_CONFIGURATION_destroy (cfg);
   bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
   bc->exchange_account_url = GNUNET_strdup 
(bc->exchange_auth.wire_gateway_url);
-  bc->exchange_payto = "payto://x-taler-bank/localhost/2";
+  bc->exchange_payto = exchange_payto_uri;
   bc->user42_payto = "payto://x-taler-bank/localhost/42";
   bc->user43_payto = "payto://x-taler-bank/localhost/43";
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -384,6 +397,8 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   unsigned long long fakebank_port;
+  char *exchange_payto_uri;
+  char *exchange_xtalerbank_account;
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
@@ -402,22 +417,39 @@ TALER_TESTING_prepare_fakebank (const char 
*config_filename,
     GNUNET_CONFIGURATION_destroy (cfg);
     return GNUNET_SYSERR;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             config_section,
+                                             "URL", /* FIXME: config should be 
renamed to payto_uri, it's not an url even! */
+                                             &exchange_payto_uri))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                               config_section,
+                               "URL");
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return GNUNET_SYSERR;
+  }
   bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
 
+  exchange_xtalerbank_account = TALER_xtalerbank_account_from_payto (
+    exchange_payto_uri);
+
+  if (NULL == exchange_xtalerbank_account)
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+
   GNUNET_asprintf (&bc->exchange_auth.wire_gateway_url,
                    "http://localhost:%u/%s/";,
                    (unsigned int) fakebank_port,
-                   EXCHANGE_ACCOUNT_NAME);
+                   exchange_xtalerbank_account);
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Using fakebank %s on port %u\n",
               bc->exchange_auth.wire_gateway_url,
               (unsigned int) fakebank_port);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Fakebank port from config: %u\n",
-              (unsigned int) fakebank_port);
-
   GNUNET_CONFIGURATION_destroy (cfg);
   bc->bank_url = GNUNET_strdup (bc->exchange_auth.wire_gateway_url);
   if (GNUNET_OK !=
@@ -428,17 +460,14 @@ TALER_TESTING_prepare_fakebank (const char 
*config_filename,
     return GNUNET_SYSERR;
   }
   /* FIXME: this duplicates bc->exchange_auth.wire_gateway_url */
-  GNUNET_asprintf (&bc->exchange_account_url,
-                   "http://localhost:%u/%s/";,
-                   fakebank_port,
-                   EXCHANGE_ACCOUNT_NAME);
+  bc->exchange_account_url = GNUNET_strdup 
(bc->exchange_auth.wire_gateway_url);
   GNUNET_assert (NULL != bc->exchange_account_url);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
               bc->exchange_account_url);
   /* Now we know it's the fake bank, for purpose of authentication, we
    * don't have any auth. */
   bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
-  bc->exchange_payto = "payto://x-taler-bank/localhost/2";
+  bc->exchange_payto = exchange_payto_uri;
   bc->user42_payto = "payto://x-taler-bank/localhost/42";
   bc->user43_payto = "payto://x-taler-bank/localhost/43";
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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