summaryrefslogtreecommitdiff
path: root/src/bank-lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-05-04 11:18:49 +0200
committerChristian Grothoff <christian@grothoff.org>2017-05-04 11:19:00 +0200
commit405859d06864a62982236771d81ca94f799b6c12 (patch)
tree34a73cfa186da8e82953be2ccefa604a1ae05ad0 /src/bank-lib
parent27c921c7c45f8ea8fed5c945a9e0ae0cfcc1c8e9 (diff)
downloadexchange-405859d06864a62982236771d81ca94f799b6c12.tar.gz
exchange-405859d06864a62982236771d81ca94f799b6c12.tar.bz2
exchange-405859d06864a62982236771d81ca94f799b6c12.zip
implement #4993
Diffstat (limited to 'src/bank-lib')
-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
3 files changed, 18 insertions, 1 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);