remove ebics (#6038)

This commit is contained in:
Christian Grothoff 2020-01-08 10:04:39 +01:00
parent c0702a6f0a
commit 92d21ca315
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
10 changed files with 17 additions and 592 deletions

View File

@ -31,7 +31,7 @@ URL = payto://METHOD/DETAILS
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
# For access to the account, we need to know the plugin.
PLUGIN = "ebics"
PLUGIN = "taler_bank"
# TBD: authentication data.

View File

@ -59,12 +59,12 @@ CONFIG = "postgres:///talercheck"
# advertised in /wire.
[account-1]
# What is the URL of our account?
URL = "payto://iban/CH9300762011623852957"
URL = "payto://x-taler-bank/localhost:8082/42"
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
# Which wire plugin should we used to access the account?
PLUGIN = ebics
PLUGIN = taler_bank
# ENABLE_CREDIT = YES

View File

@ -45,14 +45,6 @@
#define CONFIG_FILE_EXPIRE_RESERVE_NOW \
"test_exchange_api_expire_reserve_now.conf"
/**
* Is the configuration file is set to include wire format 'ebics'?
* Requires that EBICS /history function is implemented, which it
* is currently not. Once it is, set ENABLE_CREDIT to YES in the
* configuration and then set this option to 1.
*/
#define WIRE_EBICS 0
/**
* URL of the fakebank. Obtained from CONFIG_FILE's
* "exchange-wire-test:BANK_URI" option.
@ -148,7 +140,6 @@ static void
run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
/**
* Checks made against /wire response.
*/
@ -161,16 +152,6 @@ run (void *cls,
"x-taler-bank",
NULL,
MHD_HTTP_OK),
#if WIRE_EBICS
/**
* Check if 'ebics' wire method is offered by the exchange.
*/
TALER_TESTING_cmd_wire ("wire-sepa-1",
"ebics",
NULL,
MHD_HTTP_OK),
#endif
TALER_TESTING_cmd_end ()
};

View File

@ -66,12 +66,12 @@ CONFIG = "postgres:///talercheck"
# advertised in /wire.
[account-1]
# What is the URL of our account?
URL = "payto://iban/CH9300762011623852957"
URL = "payto://x-taler-bank/localhost:8082/42"
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
# Which wire plugin should we used to access the account?
PLUGIN = ebics
PLUGIN = taler_bank
# ENABLE_CREDIT = YES

View File

@ -71,10 +71,10 @@ CONFIG = "postgres:///talercheck"
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/iban.json
# What is the URL of our bank account? Must match WIRE_RESPONSE above!
URL = payto://iban/FIXME
URL = payto://x-taler-bank/localhost:8080/42
# Which plugin implements access for this account?
PLUGIN = "ebics"
PLUGIN = "taler_bank"
[account-2]
@ -83,7 +83,7 @@ PLUGIN = "ebics"
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/x-taler-bank.json
# What is the URL of our bank account? Must match WIRE_RESPONSE above!
URL = payto://x-taler-bank/http://localhost:8082/2
URL = payto://x-taler-bank/localhost:8082/2
# Which plugin implements access for this account?
PLUGIN = "taler_bank"

View File

@ -10,19 +10,16 @@ pkgcfgdir = $(prefix)/share/taler/config.d/
EXTRA_DIST = \
test_wire_plugin.conf \
test_wire_plugin_transactions_taler-bank.conf
test_wire_plugin_transactions_taler-bank.conf
plugindir = $(libdir)/taler
plugin_LTLIBRARIES = \
libtaler_plugin_wire_ebics.la
if HAVE_LIBCURL
plugin_LTLIBRARIES += \
plugin_LTLIBRARIES = \
libtaler_plugin_wire_taler_bank.la
else
if HAVE_LIBGNURL
plugin_LTLIBRARIES += \
plugin_LTLIBRARIES = \
libtaler_plugin_wire_taler_bank.la
endif
endif
@ -45,17 +42,6 @@ libtaler_plugin_wire_taler_bank_la_LDFLAGS = \
-lgnunetutil $(XLIB)
libtaler_plugin_wire_ebics_la_SOURCES = \
plugin_wire_ebics.c
libtaler_plugin_wire_ebics_la_LIBADD = \
$(LTLIBINTL)
libtaler_plugin_wire_ebics_la_LDFLAGS = \
$(TALER_PLUGIN_LDFLAGS) \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil $(XLIB)
libtaler_plugin_wire_template_la_SOURCES = \
plugin_wire_template.c
libtaler_plugin_wire_template_la_LIBADD = \
@ -69,19 +55,11 @@ libtaler_plugin_wire_template_la_LDFLAGS = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
test_ebics_wireformat \
test_wire_plugin \
test_wire_plugin_transactions_taler_bank
check_PROGRAMS= $(TESTS)
test_ebics_wireformat_SOURCES = \
test_ebics_wireformat.c
test_ebics_wireformat_LDADD = \
-lgnunetutil \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/util/libtalerutil.la
test_wire_plugin_SOURCES = \
test_wire_plugin.c

View File

@ -1,447 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2016, 2017, 2018 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file plugin_wire_ebics.c
* @brief wire plugin for transfers using SEPA/EBICS
* @author Florian Dold
* @author Christian Grothoff
* @author Sree Harsha Totakura
*/
#include "platform.h"
#include "taler_wire_lib.h"
#include "taler_wire_plugin.h"
#include "taler_signatures.h"
#include <gnunet/gnunet_json_lib.h>
/**
* Type of the "cls" argument given to each of the functions in
* our API.
*/
struct EbicsClosure
{
/**
* Which currency do we support?
*/
char *currency;
/**
* Configuration we use to lookup account information.
*/
struct GNUNET_CONFIGURATION_Handle *cfg;
};
/**
* Round amount DOWN to the amount that can be transferred via the wire
* method. For example, Taler may support 0.000001 EUR as a unit of
* payment, but SEPA only supports 0.01 EUR. This function would
* round 0.125 EUR to 0.12 EUR in this case.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param[in,out] amount amount to round down
* @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
* #GNUNET_SYSERR if the amount or currency was invalid
*/
static int
ebics_amount_round (void *cls,
struct TALER_Amount *amount)
{
struct EbicsClosure *sc = cls;
uint32_t delta;
if (NULL == sc->currency)
return GNUNET_SYSERR;
if (0 != strcasecmp (amount->currency,
sc->currency))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
delta = amount->fraction % (TALER_AMOUNT_FRAC_BASE / 100);
if (0 == delta)
return GNUNET_NO;
amount->fraction -= delta;
return GNUNET_OK;
}
/**
* Check if the given payto:// URL is correctly formatted for this plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param account_url the payto:// URL
* @return #TALER_EC_NONE if correctly formatted
*/
static enum TALER_ErrorCode
ebics_wire_validate (void *cls,
const char *account_url)
{
(void) cls;
struct TALER_Account acc;
enum TALER_ErrorCode ec;
ec = TALER_WIRE_payto_to_account (account_url,
&acc);
if (TALER_EC_NONE == ec)
{
if (TALER_PAC_IBAN != acc.type)
ec = TALER_EC_PAYTO_WRONG_METHOD;
TALER_WIRE_account_free (&acc);
}
return ec;
}
/**
* Prepare for exeuction of a wire transfer.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param wire valid wire account information
* @param amount amount to transfer, already rounded
* @param exchange_base_url base URL of the exchange (for tracking)
* @param wtid wire transfer identifier to use
* @param psc function to call with the prepared data to persist
* @param psc_cls closure for @a psc
* @return NULL on failure
*/
static struct TALER_WIRE_PrepareHandle *
ebics_prepare_wire_transfer (void *cls,
const char *origin_account_section,
const char *destination_account_url,
const struct TALER_Amount *amount,
const char *exchange_base_url,
const struct
TALER_WireTransferIdentifierRawP *wtid,
TALER_WIRE_PrepareTransactionCallback psc,
void *psc_cls)
{
(void) cls;
(void) origin_account_section;
(void) destination_account_url;
(void) amount;
(void) exchange_base_url;
(void) wtid;
(void) psc;
(void) psc_cls;
GNUNET_break (0); // FIXME: not implemented
return NULL;
}
/**
* Abort preparation of a wire transfer. For example,
* because we are shutting down.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param pth preparation to cancel
*/
static void
ebics_prepare_wire_transfer_cancel (void *cls,
struct TALER_WIRE_PrepareHandle *pth)
{
(void) cls;
(void) pth;
GNUNET_break (0); // FIXME: not implemented
}
/**
* Execute a wire transfer.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param buf buffer with the prepared execution details
* @param buf_size number of bytes in @a buf
* @param cc function to call upon success
* @param cc_cls closure for @a cc
* @return NULL on error
*/
static struct TALER_WIRE_ExecuteHandle *
ebics_execute_wire_transfer (void *cls,
const char *buf,
size_t buf_size,
TALER_WIRE_ConfirmationCallback cc,
void *cc_cls)
{
(void) cls;
(void) buf;
(void) buf_size;
(void) cc;
(void) cc_cls;
GNUNET_break (0); // FIXME: not implemented
return NULL;
}
/**
* Abort execution of a wire transfer. For example, because we are
* shutting down. Note that if an execution is aborted, it may or
* may not still succeed. The caller MUST run @e
* execute_wire_transfer again for the same request as soon as
* possilbe, to ensure that the request either ultimately succeeds
* or ultimately fails. Until this has been done, the transaction is
* in limbo (i.e. may or may not have been committed).
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param eh execution to cancel
*/
static void
ebics_execute_wire_transfer_cancel (void *cls,
struct TALER_WIRE_ExecuteHandle *eh)
{
(void) cls;
(void) eh;
GNUNET_break (0); // FIXME: not implemented
}
/**
* Query transfer history of an account. We use the variable-size
* @a start_off to indicate which transfers we are interested in as
* different banking systems may have different ways to identify
* transfers. The @a start_off value must thus match the value of
* a `row_off` argument previously given to the @a hres_cb. Use
* NULL to query transfers from the beginning of time (with
* positive @a num_results) or from the latest committed transfers
* (with negative @a num_results).
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param account_section specifies the configuration section which
* identifies the account for which we should get the history
* @param direction what kinds of wire transfers should be returned
* @param start_off from which row on do we want to get results, use NULL for the latest; exclusive
* @param start_off_len number of bytes in @a start_off; must be `sizeof(uint64_t)`.
* @param num_results how many results do we want; negative numbers to go into the past,
* positive numbers to go into the future starting at @a start_row;
* must not be zero.
* @param hres_cb the callback to call with the transaction history
* @param hres_cb_cls closure for the above callback
*/
static struct TALER_WIRE_HistoryHandle *
ebics_get_history (void *cls,
const char *account_section,
enum TALER_BANK_Direction direction,
const void *start_off,
size_t start_off_len,
int64_t num_results,
TALER_WIRE_HistoryResultCallback hres_cb,
void *hres_cb_cls)
{
(void) cls;
(void) account_section;
(void) direction;
(void) start_off;
(void) start_off_len;
(void) num_results;
(void) hres_cb;
(void) hres_cb_cls;
GNUNET_break (0);
return NULL;
}
/**
* Cancel going over the account's history.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param whh operation to cancel
*/
static void
ebics_get_history_cancel (void *cls,
struct TALER_WIRE_HistoryHandle *whh)
{
(void) cls;
(void) whh;
GNUNET_break (0);
}
/**
* Context for a rejection operation.
*/
struct TALER_WIRE_RejectHandle
{
/**
* Function to call with the result.
*/
TALER_WIRE_RejectTransferCallback rej_cb;
/**
* Closure for @e rej_cb.
*/
void *rej_cb_cls;
/**
* Handle to task for timeout of operation.
*/
struct GNUNET_SCHEDULER_Task *timeout_task;
};
/**
* Rejection operation failed with timeout, notify callback
* and clean up.
*
* @param cls closure with `struct TALER_WIRE_RejectHandle`
*/
static void
timeout_reject (void *cls)
{
struct TALER_WIRE_RejectHandle *rh = cls;
rh->timeout_task = NULL;
rh->rej_cb (rh->rej_cb_cls,
TALER_EC_NOT_IMPLEMENTED /* in the future: TALER_EC_TIMEOUT */);
GNUNET_free (rh);
}
/**
* Reject an incoming wire transfer that was obtained from the
* history. This function can be used to transfer funds back to
* the sender if the WTID was malformed (i.e. due to a typo).
*
* Calling `reject_transfer` twice on the same wire transfer should
* be idempotent, i.e. not cause the funds to be wired back twice.
* Furthermore, the transfer should henceforth be removed from the
* results returned by @e get_history.
*
* @param cls plugin's closure
* @param account_section specifies the configuration section which
* identifies the account to use to reject the transfer
* @param start_off offset of the wire transfer in plugin-specific format
* @param start_off_len number of bytes in @a start_off
* @param rej_cb function to call with the result of the operation
* @param rej_cb_cls closure for @a rej_cb
* @return handle to cancel the operation
*/
static struct TALER_WIRE_RejectHandle *
ebics_reject_transfer (void *cls,
const char *account_section,
const void *start_off,
size_t start_off_len,
TALER_WIRE_RejectTransferCallback rej_cb,
void *rej_cb_cls)
{
struct TALER_WIRE_RejectHandle *rh;
(void) account_section;
(void) start_off;
(void) start_off_len;
(void) rej_cb;
(void) rej_cb_cls;
GNUNET_break (0); /* not implemented, just a stub! */
rh = GNUNET_new (struct TALER_WIRE_RejectHandle);
rh->rej_cb = rej_cb;
rh->rej_cb_cls = rej_cb_cls;
rh->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_reject,
rh);
return rh;
}
/**
* Cancel ongoing reject operation. Note that the rejection may still
* proceed. Basically, if this function is called, the rejection may
* have happened or not. This function is usually used during shutdown
* or system upgrades. At a later point, the application must call
* @e reject_transfer again for this wire transfer, unless the
* @e get_history shows that the wire transfer no longer exists.
*
* @param cls plugins' closure
* @param rh operation to cancel
* @return closure of the callback of the operation
*/
static void *
ebics_reject_transfer_cancel (void *cls,
struct TALER_WIRE_RejectHandle *rh)
{
void *ret = rh->rej_cb_cls;
(void) cls;
GNUNET_SCHEDULER_cancel (rh->timeout_task);
GNUNET_free (rh);
return ret;
}
/**
* Initialize ebics-wire subsystem.
*
* @param cls a configuration instance
* @return NULL on error, otherwise a `struct TALER_WIRE_Plugin`
*/
void *
libtaler_plugin_wire_ebics_init (void *cls)
{
struct GNUNET_CONFIGURATION_Handle *cfg = cls;
struct EbicsClosure *sc;
struct TALER_WIRE_Plugin *plugin;
sc = GNUNET_new (struct EbicsClosure);
sc->cfg = cfg;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"taler",
"CURRENCY",
&sc->currency))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler",
"CURRENCY");
GNUNET_free (sc);
return NULL;
}
plugin = GNUNET_new (struct TALER_WIRE_Plugin);
plugin->cls = sc;
plugin->method = "iban";
plugin->amount_round = &ebics_amount_round;
plugin->wire_validate = &ebics_wire_validate;
plugin->prepare_wire_transfer = &ebics_prepare_wire_transfer;
plugin->prepare_wire_transfer_cancel = &ebics_prepare_wire_transfer_cancel;
plugin->execute_wire_transfer = &ebics_execute_wire_transfer;
plugin->execute_wire_transfer_cancel = &ebics_execute_wire_transfer_cancel;
plugin->get_history = &ebics_get_history;
plugin->get_history_cancel = &ebics_get_history_cancel;
plugin->reject_transfer = &ebics_reject_transfer;
plugin->reject_transfer_cancel = &ebics_reject_transfer_cancel;
return plugin;
}
/**
* Shutdown Ebics wire subsystem.
*
* @param cls a `struct TALER_WIRE_Plugin`
* @return NULL (always)
*/
void *
libtaler_plugin_wire_ebics_done (void *cls)
{
struct TALER_WIRE_Plugin *plugin = cls;
struct EbicsClosure *sc = plugin->cls;
GNUNET_free_non_null (sc->currency);
GNUNET_free (sc);
GNUNET_free (plugin);
return NULL;
}
/* end of plugin_wire_ebics.c */

View File

@ -1,85 +0,0 @@
/*
This file is part of TALER
(C) 2015, 2016, 2018 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file wire/test_ebics_wireformat.c
* @brief Tests for SEPA format validation by the EBICS plugin
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
#include "platform.h"
#include "taler_util.h"
#include "taler_wire_lib.h"
/**
* Valid SEPA data
*/
static const char *valid_wire_str = "payto://iban/DE67830654080004822650";
/**
* IBAN has wrong country code
*/
static const char *invalid_wire_str = "payto://iban/XX67830654080004822650";
/**
* IBAN has wrong checksum
*/
static const char *invalid_wire_str2 = "payto://iban/DE67830654080004822651";
/**
* Unsupported wireformat type
*/
static const char *unsupported_wire_str = "payto://sega/DE67830654080004822650";
int
main (int argc,
const char *const argv[])
{
struct GNUNET_CONFIGURATION_Handle *cfg;
struct TALER_WIRE_Plugin *plugin;
GNUNET_log_setup ("test-ebics-wireformats",
"WARNING",
NULL);
cfg = GNUNET_CONFIGURATION_create ();
GNUNET_CONFIGURATION_set_value_string (cfg,
"taler",
"currency",
"EUR");
plugin = TALER_WIRE_plugin_load (cfg,
"ebics");
if (NULL == plugin)
{
TALER_LOG_ERROR ("Could not load the ebics plugin\n");
return 77;
}
GNUNET_assert (TALER_EC_NONE !=
plugin->wire_validate (plugin->cls,
unsupported_wire_str));
GNUNET_assert (TALER_EC_NONE !=
plugin->wire_validate (plugin->cls,
invalid_wire_str));
GNUNET_assert (TALER_EC_NONE !=
plugin->wire_validate (plugin->cls,
invalid_wire_str2));
GNUNET_assert (TALER_EC_NONE ==
plugin->wire_validate (plugin->cls,
valid_wire_str));
TALER_WIRE_plugin_unload (plugin);
GNUNET_CONFIGURATION_destroy (cfg);
return 0;
}

View File

@ -59,12 +59,6 @@ struct TestBlock
* to use for the tests.
*/
static struct TestBlock tests[] = {
{
.plugin_name = "ebics",
.round_in = "EUR:0.123456",
.round_out = "EUR:0.12",
.currency = "EUR"
},
#if HAVE_LIBCURL
{
.plugin_name = "taler_bank",

View File

@ -44,7 +44,7 @@ struct ConversionTable
const char *method;
/**
* Plugin name, e.g. 'ebics', 'taler_bank', ..
* Plugin name, e.g. 'taler_bank', ..
*/
const char *plugin_name;
};
@ -78,6 +78,10 @@ TALER_WIRE_payto_get_method (const char *payto_url)
/**
* Get the plugin name from the payment method.
*
* FIXME: this is ugly, would be better to have
* a way to iterate over all plugins and interrogate
* them as to what wire method(s) they support!
*
* @param method the method implemented by the plugin (for
* simplicity, we assume 1 method is implemented by 1 plugin).
* @return the plugin name, NULL if not found.
@ -87,7 +91,7 @@ TALER_WIRE_get_plugin_from_method (const char *method)
{
static const struct ConversionTable ct[] = {
{"x-taler-bank", "taler_bank"},
{"iban", "ebics"},
{"iban", "taler_bank"},
{NULL, NULL}
};