aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bank-lib/bank_api_admin.c5
-rw-r--r--src/bank-lib/fakebank.c6
-rw-r--r--src/bank-lib/test_bank_interpreter.c8
-rw-r--r--src/include/taler_bank_service.h4
-rw-r--r--src/wire/plugin_wire_test.c48
-rw-r--r--src/wire/wire-test.conf4
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 0ce4b11ab..0db28e479 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 88d5c36db..c0854ed13 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 f088cfc40..346e32085 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 c9c20637a..9a0926bf4 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 4f78027c9..201bbf08b 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 fcc156426..bd282ff65 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