gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: payto fixes WIP


From: gnunet
Subject: [taler-exchange] branch master updated: payto fixes WIP
Date: Fri, 17 Jan 2020 01:23:38 +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 6faf6fc7 payto fixes WIP
6faf6fc7 is described below

commit 6faf6fc732afe58a5da71dd442ede78cdbd7c495
Author: Florian Dold <address@hidden>
AuthorDate: Fri Jan 17 01:23:32 2020 +0100

    payto fixes WIP
---
 doc/prebuilt                             |  2 +-
 src/auditor/taler-wire-auditor.c         |  3 +--
 src/bank-lib/bank_api_parse.c            | 45 ++++++++++++++++++++++++++++++--
 src/exchange/taler-exchange-aggregator.c |  3 +--
 src/exchange/taler-exchange-wirewatch.c  |  3 +--
 src/include/taler_bank_service.h         | 21 ++++++++++++++-
 src/lib/test_auditor_api.conf            |  1 +
 src/lib/test_bank_api.c                  |  2 +-
 src/lib/test_bank_api.conf               |  5 ++--
 src/lib/testing_api_helpers_bank.c       | 29 ++++++++++++++++++--
 10 files changed, 99 insertions(+), 15 deletions(-)

diff --git a/doc/prebuilt b/doc/prebuilt
index 934a6a18..ca53235c 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit 934a6a18301e81c4fd1b3a8cda2dc13dca4741cc
+Subproject commit ca53235ccfa0458ebf11c204888ca370e20ec3f5
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c
index d8da36d0..8ea2b2fd 100644
--- a/src/auditor/taler-wire-auditor.c
+++ b/src/auditor/taler-wire-auditor.c
@@ -1842,8 +1842,7 @@ process_credits (void *cls)
               "Starting bank CREDIT history of account `%s'\n",
               wa->section_name);
   wa->chh = TALER_BANK_credit_history (ctx,
-                                       wa->account.details.x_taler_bank.
-                                       account_base_url,
+                                       wa->auth.wire_gateway_url,
                                        &wa->auth,
                                        wa->in_wire_off,
                                        INT64_MAX,
diff --git a/src/bank-lib/bank_api_parse.c b/src/bank-lib/bank_api_parse.c
index 6e5c9f12..5423d01b 100644
--- a/src/bank-lib/bank_api_parse.c
+++ b/src/bank-lib/bank_api_parse.c
@@ -98,16 +98,50 @@ TALER_BANK_auth_parse_cfg (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
     { NULL, TALER_BANK_AUTH_NONE     }
   };
   char *method;
+  unsigned long long fakebank_port;
+
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number (cfg,
+                                             section,
+                                             "FAKEBANK_PORT",
+                                             &fakebank_port))
+  {
+    auth->method = TALER_BANK_AUTH_FAKEBANK;
+    auth->details.fakebank.fb_port = (uint16_t) fakebank_port;
+    // FIXME: we should not hardcode exchange account number "2"
+    GNUNET_asprintf (&auth->wire_gateway_url,
+                     "http://localhost:%u/2/";,
+                     (unsigned int) fakebank_port);
+
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Using fakebank %s on port %u\n",
+                auth->wire_gateway_url,
+                (unsigned int) fakebank_port);
+    return GNUNET_OK;
+  }
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              section,
-                                             "TALER_BANK_AUTH_METHOD",
+                                             "WIRE_GATEWAY_URL",
+                                             &auth->wire_gateway_url))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               section,
+                               "WIRE_GATEWAY_URL");
+    return GNUNET_SYSERR;
+  }
+
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             section,
+                                             "WIRE_GATEWAY_AUTH_METHOD",
                                              &method))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                section,
-                               "TALER_BANK_AUTH_METHOD");
+                               "WIRE_GATEWAY_AUTH_METHOD");
+    GNUNET_free (auth->wire_gateway_url);
     return GNUNET_SYSERR;
   }
   for (unsigned int i = 0; NULL != methods[i].m; i++)
@@ -132,6 +166,7 @@ TALER_BANK_auth_parse_cfg (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
                                      section,
                                      "USERNAME");
           GNUNET_free (method);
+          GNUNET_free (auth->wire_gateway_url);
           return GNUNET_SYSERR;
         }
         if (GNUNET_OK !=
@@ -146,11 +181,14 @@ TALER_BANK_auth_parse_cfg (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
                                      section,
                                      "PASSWORD");
           GNUNET_free (method);
+          GNUNET_free (auth->wire_gateway_url);
           return GNUNET_SYSERR;
         }
         auth->method = TALER_BANK_AUTH_BASIC;
         GNUNET_free (method);
         return GNUNET_OK;
+      case TALER_BANK_AUTH_FAKEBANK:
+        GNUNET_assert (0);
       }
     }
   }
@@ -184,7 +222,10 @@ TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData 
*auth)
       auth->details.basic.password = NULL;
     }
     break;
+  case TALER_BANK_AUTH_FAKEBANK:
+    break;
   }
+  GNUNET_free (auth->wire_gateway_url);
 }
 
 
diff --git a/src/exchange/taler-exchange-aggregator.c 
b/src/exchange/taler-exchange-aggregator.c
index 264cbf62..df201d69 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1783,8 +1783,7 @@ wire_prepare_cb (void *cls,
   }
   wa = wpd->wa;
   wpd->eh = TALER_BANK_execute_wire_transfer (ctx,
-                                              wa->account.details.x_taler_bank.
-                                              account_base_url,
+                                              wa->auth.wire_gateway_url,
                                               &wa->auth,
                                               buf,
                                               buf_size,
diff --git a/src/exchange/taler-exchange-wirewatch.c 
b/src/exchange/taler-exchange-wirewatch.c
index c328e73e..600ae536 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -537,8 +537,7 @@ find_transfers (void *cls)
   current_batch_size = 0;
 
   hh = TALER_BANK_credit_history (ctx,
-                                  wa_pos->account.details.x_taler_bank.
-                                  account_base_url,
+                                  wa_pos->auth.wire_gateway_url,
                                   &wa_pos->auth,
                                   last_row_off,
                                   batch_size,
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index aace9402..c9843f2f 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -42,7 +42,12 @@ enum TALER_BANK_AuthenticationMethod
   /**
    * Basic authentication with cleartext username and password.
    */
-  TALER_BANK_AUTH_BASIC
+  TALER_BANK_AUTH_BASIC,
+
+  /**
+   * The authentication data refers to a fakebank.
+   */
+  TALER_BANK_AUTH_FAKEBANK,
 };
 
 
@@ -52,6 +57,12 @@ enum TALER_BANK_AuthenticationMethod
 struct TALER_BANK_AuthenticationData
 {
 
+  /**
+   * Base URL we use to talk to the wire gateway,
+   * which talks to the bank for us.
+   */
+  char *wire_gateway_url;
+
   /**
    * Which authentication method should we use?
    */
@@ -79,6 +90,14 @@ struct TALER_BANK_AuthenticationData
       char *password;
     } basic;
 
+    struct
+    {
+      /**
+       * Port that the fakebank runs on.
+       */
+      uint16_t fb_port;
+    } fakebank;
+
   } details;
 
 };
diff --git a/src/lib/test_auditor_api.conf b/src/lib/test_auditor_api.conf
index 5c6ee031..8133ce48 100644
--- a/src/lib/test_auditor_api.conf
+++ b/src/lib/test_auditor_api.conf
@@ -71,6 +71,7 @@ METHOD = x-taler-bank
 [account-2]
 # What is the bank account (with the "Taler Bank" demo system)?
 URL = "payto://x-taler-bank/localhost:8082/2"
+FAKEBANK_PORT = 8082
 
 # This is the response we give out for the /wire request.  It provides
 # wallets with the bank information for transfers to the exchange.
diff --git a/src/lib/test_bank_api.c b/src/lib/test_bank_api.c
index 5ebf7637..f4712397 100644
--- a/src/lib/test_bank_api.c
+++ b/src/lib/test_bank_api.c
@@ -140,7 +140,7 @@ main (int argc,
     TALER_LOG_DEBUG ("Running against the Fakebank.\n");
     if (GNUNET_OK !=
         TALER_TESTING_prepare_fakebank (CONFIG_FILE,
-                                        "account-1",
+                                        "account-2",
                                         &bc))
     {
       GNUNET_break (0);
diff --git a/src/lib/test_bank_api.conf b/src/lib/test_bank_api.conf
index 906b95fc..97fe09c9 100644
--- a/src/lib/test_bank_api.conf
+++ b/src/lib/test_bank_api.conf
@@ -1,8 +1,9 @@
 [taler]
 currency = KUDOS
 
-[account-1]
-URL = payto://x-taler-bank/localhost:8081/1
+[account-2]
+URL = payto://x-taler-bank/localhost:8081/2
+FAKEBANK_PORT = 8081
 
 [bank]
 SERVE = http
diff --git a/src/lib/testing_api_helpers_bank.c 
b/src/lib/testing_api_helpers_bank.c
index f0ba9f99..342137c9 100644
--- a/src/lib/testing_api_helpers_bank.c
+++ b/src/lib/testing_api_helpers_bank.c
@@ -380,11 +380,30 @@ TALER_TESTING_prepare_fakebank (const char 
*config_filename,
 {
   struct GNUNET_CONFIGURATION_Handle *cfg;
   char *payto_url;
+  uint16_t fakebank_port;
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
                                               config_filename))
     return GNUNET_SYSERR;
+
+  if (GNUNET_OK !=
+      TALER_BANK_auth_parse_cfg (cfg,
+                                 "account-" EXCHANGE_ACCOUNT_NAME,
+                                 &bc->exchange_auth))
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return GNUNET_SYSERR;
+  }
+
+  GNUNET_assert (TALER_BANK_AUTH_FAKEBANK == bc->exchange_auth.method);
+
+  fakebank_port = bc->exchange_auth.details.fakebank.fb_port;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Fakebank port from config: %u\n",
+              (unsigned int) fakebank_port);
+
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              config_section,
@@ -418,10 +437,16 @@ TALER_TESTING_prepare_fakebank (const char 
*config_filename,
     GNUNET_free (payto_url);
     return GNUNET_SYSERR;
   }
-  bc->exchange_account_url
-    = TALER_xtalerbank_account_url_from_payto (payto_url);
+  GNUNET_asprintf (&bc->exchange_account_url,
+                   "http://localhost:%u/%s/";,
+                   fakebank_port,
+                   EXCHANGE_ACCOUNT_NAME);
   GNUNET_assert (NULL != bc->exchange_account_url);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
+              bc->exchange_account_url);
   GNUNET_free (payto_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 = TALER_payto_xtalerbank_make (bc->bank_url, "2");
   bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");

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



reply via email to

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