gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: implement #4993


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: implement #4993
Date: Thu, 04 May 2017 11:19:03 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 405859d  implement #4993
405859d is described below

commit 405859d06864a62982236771d81ca94f799b6c12
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu May 4 11:18:49 2017 +0200

    implement #4993
---
 src/bank-lib/bank_api_admin.c        |  5 +++-
 src/bank-lib/fakebank.c              |  6 +++++
 src/bank-lib/test_bank_interpreter.c |  8 ++++++
 src/include/taler_bank_service.h     |  4 ++-
 src/wire/plugin_wire_test.c          | 48 ++++++++++++++++++++++++++++++++++++
 src/wire/wire-test.conf              |  4 +++
 6 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c
index 0ce4b11..0db28e4 100644
--- a/src/bank-lib/bank_api_admin.c
+++ b/src/bank-lib/bank_api_admin.c
@@ -162,6 +162,7 @@ handle_admin_add_incoming_finished (void *cls,
  * to the operators of the bank.
  *
  * @param ctx curl context for the event loop
+ * @param auth authentication data to send to the bank
  * @param bank_base_url URL of the bank (used to execute this request)
  * @param exchange_base_url base URL of the exchange (for tracking)
  * @param wtid wire transfer identifier for the transfer
@@ -176,6 +177,7 @@ handle_admin_add_incoming_finished (void *cls,
  */
 struct TALER_BANK_AdminAddIncomingHandle *
 TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
+                               const json_t *auth,
                                const char *bank_base_url,
                                const char *exchange_base_url,
                                const struct TALER_WireTransferIdentifierRawP 
*wtid,
@@ -189,8 +191,9 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context 
*ctx,
   json_t *admin_obj;
   CURL *eh;
 
-  admin_obj = json_pack ("{s:s, s:o, s:o, s:I, s:I}",
+  admin_obj = json_pack ("{s:s, s:O, s:o, s:o, s:I, s:I}",
                          "exchange_url", exchange_base_url,
+                         "auth", auth,
                          "wtid", GNUNET_JSON_from_data_auto (wtid),
                          "amount", TALER_JSON_from_amount (amount),
                          "debit_account", (json_int_t) debit_account_no,
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 88d5c36..c0854ed 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -318,11 +318,13 @@ handle_mhd_request (void *cls,
   t = GNUNET_new (struct Transaction);
   {
     const char *base_url;
+    json_t *auth;
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("wtid", &t->wtid),
       GNUNET_JSON_spec_uint64 ("debit_account", &t->debit_account),
       GNUNET_JSON_spec_uint64 ("credit_account", &t->credit_account),
       TALER_JSON_spec_amount ("amount", &t->amount),
+      TALER_JSON_spec_json ("auth", &auth),
       GNUNET_JSON_spec_string ("exchange_url", &base_url),
       GNUNET_JSON_spec_end ()
     };
@@ -335,6 +337,10 @@ handle_mhd_request (void *cls,
       json_decref (json);
       return MHD_NO;
     }
+    /* For now, we ignore authentication, this is the fakebank.
+       We may choose to support "proper" authentication once
+       it is non-trivial and actually needs to be tested. */
+    json_decref (auth);
     t->exchange_base_url = GNUNET_strdup (base_url);
     GNUNET_CONTAINER_DLL_insert (h->transactions_head,
                                  h->transactions_tail,
diff --git a/src/bank-lib/test_bank_interpreter.c 
b/src/bank-lib/test_bank_interpreter.c
index f088cfc..346e320 100644
--- a/src/bank-lib/test_bank_interpreter.c
+++ b/src/bank-lib/test_bank_interpreter.c
@@ -188,6 +188,7 @@ interpreter_run (void *cls)
   struct TALER_WireTransferIdentifierRawP wtid;
   struct TALER_Amount amount;
   const struct GNUNET_SCHEDULER_TaskContext *tc;
+  json_t *auth;
 
   is->task = NULL;
   tc = GNUNET_SCHEDULER_get_task_context ();
@@ -219,8 +220,14 @@ interpreter_run (void *cls)
     GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                                 &cmd->details.admin_add_incoming.wtid,
                                 sizeof (cmd->details.admin_add_incoming.wtid));
+    auth = json_pack ("{s:s, s:{s:s, s:s}}",
+                      "type", "basic",
+                      "data",
+                      "username", "user",
+                      "password", "pass");
     cmd->details.admin_add_incoming.aih
       = TALER_BANK_admin_add_incoming (is->ctx,
+                                       auth,
                                        "http://localhost:8081";,
                                        
cmd->details.admin_add_incoming.exchange_base_url,
                                        &cmd->details.admin_add_incoming.wtid,
@@ -229,6 +236,7 @@ interpreter_run (void *cls)
                                        
cmd->details.admin_add_incoming.credit_account_no,
                                        &add_incoming_cb,
                                        is);
+    json_decref (auth);
     if (NULL == cmd->details.admin_add_incoming.aih)
     {
       GNUNET_break (0);
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index c9c2063..9a0926b 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2015, 2016 GNUnet e.V.
+  Copyright (C) 2015, 2016, 2017 GNUnet e.V. & Inria
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -57,6 +57,7 @@ typedef void
  * to the operators of the bank.
  *
  * @param ctx curl context for the event loop
+ * @param auth authentication data to send to the bank
  * @param bank_base_url URL of the bank (used to execute this request)
  * @param exchange_base_url base URL of the exchange (for tracking)
  * @param wtid wire transfer identifier for the transfer
@@ -71,6 +72,7 @@ typedef void
  */
 struct TALER_BANK_AdminAddIncomingHandle *
 TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
+                               const json_t *auth,
                                const char *bank_base_url,
                                const char *exchange_base_url,
                                const struct TALER_WireTransferIdentifierRawP 
*wtid,
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 4f78027..201bbf0 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -46,6 +46,11 @@ struct TestClosure
   char *bank_uri;
 
   /**
+   * Authentication information.
+   */
+  json_t *auth;
+
+  /**
    * Handle to the context for sending funds to the bank.
    */
   struct GNUNET_CURL_Context *ctx;
@@ -721,6 +726,7 @@ test_execute_wire_transfer (void *cls,
   eh->cc = cc;
   eh->cc_cls = cc_cls;
   eh->aaih = TALER_BANK_admin_add_incoming (tc->ctx,
+                                            tc->auth,
                                             tc->bank_uri,
                                             exchange_base_url,
                                             &bf.wtid,
@@ -773,6 +779,8 @@ libtaler_plugin_wire_test_init (void *cls)
   struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct TestClosure *tc;
   struct TALER_WIRE_Plugin *plugin;
+  char *user;
+  char *pass;
 
   tc = GNUNET_new (struct TestClosure);
   if (NULL != cfg)
@@ -815,6 +823,40 @@ libtaler_plugin_wire_test_init (void *cls)
       GNUNET_free (tc);
       return NULL;
     }
+    if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_string (cfg,
+                                               "exchange-wire-outgoing-test",
+                                               "USERNAME",
+                                               &user))
+    {
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "exchange-wire-outgoing-test",
+                                 "USERNAME");
+      GNUNET_free (tc->bank_uri);
+      GNUNET_free (tc);
+      return NULL;
+    }
+    if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_string (cfg,
+                                               "exchange-wire-outgoing-test",
+                                               "PASSWORD",
+                                               &pass))
+    {
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "exchange-wire-outgoing-test",
+                                 "PASSWORD");
+      GNUNET_free (tc->bank_uri);
+      GNUNET_free (tc);
+      GNUNET_free (user);
+      return NULL;
+    }
+    tc->auth = json_pack ("{s:s, s:{s:s, s:s}}",
+                          "type", "basic",
+                          "data",
+                          "username", user,
+                          "password", pass);
+    GNUNET_free (user);
+    GNUNET_free (pass);
     tc->ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
                                 &tc->rc);
     tc->rc = GNUNET_CURL_gnunet_rc_create (tc->ctx);
@@ -823,6 +865,7 @@ libtaler_plugin_wire_test_init (void *cls)
       GNUNET_break (0);
       GNUNET_free (tc->currency);
       GNUNET_free (tc->bank_uri);
+      json_decref (tc->auth);
       GNUNET_free (tc);
       return NULL;
     }
@@ -863,6 +906,11 @@ libtaler_plugin_wire_test_done (void *cls)
     GNUNET_CURL_gnunet_rc_destroy (tc->rc);
     tc->rc = NULL;
   }
+  if (NULL != tc->auth)
+  {
+    json_decref (tc->auth);
+    tc->auth = NULL;
+  }
   GNUNET_free_non_null (tc->currency);
   GNUNET_free_non_null (tc->bank_uri);
   GNUNET_free (tc);
diff --git a/src/wire/wire-test.conf b/src/wire/wire-test.conf
index fcc1564..bd282ff 100644
--- a/src/wire/wire-test.conf
+++ b/src/wire/wire-test.conf
@@ -20,3 +20,7 @@ EXCHANGE_ACCOUNT_NUMBER = 2
 # the URI of the bank (where the /admin/add/incoming API
 # is avaialble).
 # BANK_URI = https://bank.demo.taler.net/
+
+# Authentication information for basic authentication
+USERNAME = user
+PASSWORD = pass

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



reply via email to

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