modify /wire/test to provide bank URI and bank account numbers

This commit is contained in:
Christian Grothoff 2016-03-04 11:57:57 +01:00
commit aba92c5bfa
10 changed files with 82 additions and 18 deletions

0
bootstrap Normal file → Executable file
View File

View File

@ -25,5 +25,11 @@ DB_CONN_STR = "postgres:///talercheck"
SEPA_RESPONSE_FILE = "sepa.json" SEPA_RESPONSE_FILE = "sepa.json"
[wire-test] [wire-test]
BANK_URI = "http://bank/" # What is the main website of the bank?
BANK_ACCOUNT_NUMBER = 1 BANK_URI = "https://bank/"
# Into which account at the 'bank' should incoming
# wire transfers be made?
BANK_ACCOUNT_NO_INCOMING = 2
# From which account at the 'bank' should outgoing
# wire transfers be made?
BANK_ACCOUNT_NO_OUTGOING = 2

View File

@ -150,7 +150,8 @@ handle_admin_add_incoming_finished (void *cls,
* @param reserve_pub public key of the reserve * @param reserve_pub public key of the reserve
* @param amount amount that was deposited * @param amount amount that was deposited
* @param execution_date when did we receive the amount * @param execution_date when did we receive the amount
* @param account_no account number (53 bits at most) * @param debit_account_no account number to withdraw from (53 bits at most)
* @param credit_account_no account number to deposit into (53 bits at most)
* @param res_cb the callback to call when the final result for this request is available * @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback * @param res_cb_cls closure for the above callback
* @return NULL * @return NULL
@ -161,7 +162,8 @@ struct TALER_BANK_AdminAddIncomingHandle *
TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank, TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
uint64_t account_no, uint64_t debit_account_no,
uint64_t credit_account_no,
TALER_BANK_AdminAddIncomingResultCallback res_cb, TALER_BANK_AdminAddIncomingResultCallback res_cb,
void *res_cb_cls) void *res_cb_cls)
{ {
@ -169,12 +171,13 @@ TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank,
json_t *admin_obj; json_t *admin_obj;
CURL *eh; CURL *eh;
admin_obj = json_pack ("{s:o, s:o," /* reserve_pub/amount */ admin_obj = json_pack ("{s:o, s:o,"
" s:I}", /* execution_Date/wire */ " s:I, s:I}",
"wtid", TALER_json_from_data (wtid, "wtid", TALER_json_from_data (wtid,
sizeof (*wtid)), sizeof (*wtid)),
"amount", TALER_json_from_amount (amount), "amount", TALER_json_from_amount (amount),
"account", (json_int_t) account_no); "debit_account", (json_int_t) debit_account_no,
"credit_account", (json_int_t) credit_account_no);
aai = GNUNET_new (struct TALER_BANK_AdminAddIncomingHandle); aai = GNUNET_new (struct TALER_BANK_AdminAddIncomingHandle);
aai->bank = bank; aai->bank = bank;
aai->cb = res_cb; aai->cb = res_cb;

View File

@ -103,9 +103,14 @@ struct Command
const char *amount; const char *amount;
/** /**
* Account number. * Credited account number.
*/ */
uint64_t account_no; uint64_t credit_account_no;
/**
* Debited account number.
*/
uint64_t debit_account_no;
/** /**
* Wire transfer identifier to use. Initialized to * Wire transfer identifier to use. Initialized to
@ -310,7 +315,8 @@ interpreter_run (void *cls,
= TALER_BANK_admin_add_incoming (ctx, = TALER_BANK_admin_add_incoming (ctx,
&cmd->details.admin_add_incoming.wtid, &cmd->details.admin_add_incoming.wtid,
&amount, &amount,
cmd->details.admin_add_incoming.account_no, cmd->details.admin_add_incoming.debit_account_no,
cmd->details.admin_add_incoming.credit_account_no,
&add_incoming_cb, &add_incoming_cb,
is); is);
if (NULL == cmd->details.admin_add_incoming.aih) if (NULL == cmd->details.admin_add_incoming.aih)
@ -470,7 +476,8 @@ run (void *cls,
{ .oc = OC_ADMIN_ADD_INCOMING, { .oc = OC_ADMIN_ADD_INCOMING,
.label = "deposit-1", .label = "deposit-1",
.expected_response_code = MHD_HTTP_OK, .expected_response_code = MHD_HTTP_OK,
.details.admin_add_incoming.account_no = 42, .details.admin_add_incoming.credit_account_no = 1,
.details.admin_add_incoming.debit_account_no = 2,
.details.admin_add_incoming.amount = "EUR:5.01" }, .details.admin_add_incoming.amount = "EUR:5.01" },
{ .oc = OC_END } { .oc = OC_END }

View File

@ -82,6 +82,25 @@ struct TALER_EXCHANGE_WireHandle
}; };
/**
* Verify that the signature on the "200 OK" response
* for /wire/test from the exchange is valid.
* Accepts everything.
*
* @param wh wire handle
* @param json json reply with the signature
* @return #GNUNET_SYSERR if @a json is invalid,
* #GNUNET_NO if the method is unknown,
* #GNUNET_OK if the json is valid
*/
static int
verify_wire_test_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh,
json_t *json)
{
return GNUNET_OK;
}
/** /**
* Verify that the signature on the "200 OK" response * Verify that the signature on the "200 OK" response
* for /wire/sepa from the exchange is valid. * for /wire/sepa from the exchange is valid.
@ -182,6 +201,7 @@ verify_wire_method_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh,
int (*handler)(const struct TALER_EXCHANGE_WireHandle *wh, int (*handler)(const struct TALER_EXCHANGE_WireHandle *wh,
json_t *json); json_t *json);
} handlers[] = { } handlers[] = {
{ "test", &verify_wire_test_signature_ok },
{ "sepa", &verify_wire_sepa_signature_ok }, { "sepa", &verify_wire_sepa_signature_ok },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -26,5 +26,11 @@ DB_CONN_STR = "postgres:///talercheck"
SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json"
[wire-test] [wire-test]
# What is the main website of the bank?
BANK_URI = "http://localhost/" BANK_URI = "http://localhost/"
BANK_ACCOUNT_NUMBER = 1 # Into which account at the 'bank' should incoming
# wire transfers be made?
BANK_ACCOUNT_NO_INCOMING = 2
# From which account at the 'bank' should outgoing
# wire transfers be made?
BANK_ACCOUNT_NO_OUTGOING = 2

View File

@ -2328,8 +2328,8 @@ run (void *cls,
#if WIRE_TEST #if WIRE_TEST
{ .oc = OC_WIRE, { .oc = OC_WIRE,
.label = "wire-test", .label = "wire-test",
/* /wire/test replies with a 302 redirect */ /* /wire/test replies with a 200 OK */
.expected_response_code = MHD_HTTP_FOUND, .expected_response_code = MHD_HTTP_OK,
.details.wire.format = "test" }, .details.wire.format = "test" },
#endif #endif
#if WIRE_SEPA #if WIRE_SEPA

View File

@ -117,13 +117,14 @@ TMH_WIRE_handler_wire_test (struct TMH_RequestHandler *rh,
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg, GNUNET_CONFIGURATION_get_value_number (cfg,
"wire-test", "wire-test",
"BANK_ACCOUNT_NUMBER", "BANK_ACCOUNT_NO_INCOMING",
&account_number)) &account_number))
{ {
/* oopsie, configuration error */ /* oopsie, configuration error */
MHD_destroy_response (response); MHD_destroy_response (response);
GNUNET_free (bank_uri);
return TMH_RESPONSE_reply_internal_error (connection, return TMH_RESPONSE_reply_internal_error (connection,
"BANK_URI not configured"); "BANK_ACCOUNT_NO_INCOMING not configured");
} }
ret = TMH_RESPONSE_reply_json_pack (connection, ret = TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,

View File

@ -133,7 +133,8 @@ typedef void
* @param reserve_pub public key of the reserve * @param reserve_pub public key of the reserve
* @param amount amount that was deposited * @param amount amount that was deposited
* @param execution_date when did we receive the amount * @param execution_date when did we receive the amount
* @param account_no account number (53 bits at most) * @param debit_account_no account number to withdraw from (53 bits at most)
* @param credit_account_no account number to deposit into (53 bits at most)
* @param res_cb the callback to call when the final result for this request is available * @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback * @param res_cb_cls closure for the above callback
* @return NULL * @return NULL
@ -144,7 +145,8 @@ struct TALER_BANK_AdminAddIncomingHandle *
TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank, TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
uint64_t account_no, uint64_t debit_account_no,
uint64_t credit_account_no,
TALER_BANK_AdminAddIncomingResultCallback res_cb, TALER_BANK_AdminAddIncomingResultCallback res_cb,
void *res_cb_cls); void *res_cb_cls);

View File

@ -43,6 +43,11 @@ struct TestClosure
*/ */
char *currency; char *currency;
/**
* Number of the account that the exchange has at the bank.
*/
unsigned long long exchange_account_no;
/** /**
* Handle to the bank task, or NULL. * Handle to the bank task, or NULL.
*/ */
@ -489,6 +494,7 @@ test_execute_wire_transfer (void *cls,
eh->aaih = TALER_BANK_admin_add_incoming (tc->bank, eh->aaih = TALER_BANK_admin_add_incoming (tc->bank,
&bf.wtid, &bf.wtid,
&amount, &amount,
(uint64_t) tc->exchange_account_no,
(uint64_t) account_no, (uint64_t) account_no,
&execute_cb, &execute_cb,
eh); eh);
@ -551,6 +557,19 @@ libtaler_plugin_wire_test_init (void *cls)
return NULL; return NULL;
} }
tc = GNUNET_new (struct TestClosure); tc = GNUNET_new (struct TestClosure);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
"wire-test",
"BANK_ACCOUNT_NO_OUTGOING",
&tc->exchange_account_no))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"wire-test",
"BANK_ACCOUNT_NO_OUTGOING");
GNUNET_free (uri);
GNUNET_free (tc);
return NULL;
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange", "exchange",