aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/wire/Makefile.am4
-rw-r--r--src/wire/plugin_wire_sepa.c3
-rw-r--r--src/wire/test_wire_plugin.c108
-rw-r--r--src/wire/test_wire_plugin.conf21
-rw-r--r--src/wire/test_wire_plugin_key.priv1
-rw-r--r--src/wire/test_wire_plugin_sepa.json8
-rw-r--r--src/wire/test_wire_plugin_test.json7
8 files changed, 143 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index fc31e919e..20d4b52c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@ src/exchange-tools/taler-exchange-wire
src/exchangedb/perf-exchangedb
src/json/test_json
src/wire/test_sepa_wireformat
+src/wire/test_wire_plugin
src/pq/test_pq
src/util/test_amount
src/util/test_crypto
diff --git a/src/wire/Makefile.am b/src/wire/Makefile.am
index 107ceb379..debb27828 100644
--- a/src/wire/Makefile.am
+++ b/src/wire/Makefile.am
@@ -15,7 +15,8 @@ pkgcfg_DATA = \
EXTRA_DIST = \
wire-sepa.conf \
- wire-test.conf
+ wire-test.conf \
+ test_wire_plugin.conf
plugindir = $(libdir)/taler
@@ -97,6 +98,7 @@ test_sepa_wireformat_LDADD = \
test_wire_plugin_SOURCES = \
test_wire_plugin.c
test_wire_plugin_LDADD = \
+ -lgnunetjson \
-lgnunetutil \
-ljansson \
libtalerwire.la \
diff --git a/src/wire/plugin_wire_sepa.c b/src/wire/plugin_wire_sepa.c
index e0a3426c2..6f01167d9 100644
--- a/src/wire/plugin_wire_sepa.c
+++ b/src/wire/plugin_wire_sepa.c
@@ -539,6 +539,9 @@ sepa_get_wire_details (void *cls,
"SEPA_RESPONSE_FILE",
&sepa_wire_file))
{
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ account_name,
+ "SEPA_RESPONSE_FILE");
return NULL;
}
ret = json_load_file (sepa_wire_file,
diff --git a/src/wire/test_wire_plugin.c b/src/wire/test_wire_plugin.c
index 9f61b21fe..27b4366c1 100644
--- a/src/wire/test_wire_plugin.c
+++ b/src/wire/test_wire_plugin.c
@@ -23,6 +23,8 @@
#include "taler_util.h"
#include "taler_wire_lib.h"
#include "taler_wire_plugin.h"
+#include <gnunet/gnunet_json_lib.h>
+#include <jansson.h>
/**
@@ -48,32 +50,120 @@ struct TestBlock {
* to use for the tests.
*/
static struct TestBlock tests[] = {
- { "sepa", "{ \"iban\":3 }" },
- { "test", "{ \"bank_uri\":3 }" },
+ { "sepa", "{ \"type\":\"sepa\", \"iban\":\"DE67830654080004822650\", \"name\":\"GNUnet e.V.\", \"bic\":\"GENODEF1SLR\" }" },
+ { "test", "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account_number\":42 }" },
{ NULL, NULL }
};
+/**
+ * Private key used to sign wire details.
+ */
+static struct TALER_MasterPrivateKeyP priv_key;
+
+/**
+ * Public key matching #priv_key.
+ */
+static struct TALER_MasterPublicKeyP pub_key;
+
+/**
+ * Our configuration.
+ */
+static struct GNUNET_CONFIGURATION_Handle *cfg;
+
+
+/**
+ * Run the test.
+ *
+ * @param name of the test
+ * @param plugin plugin to test
+ * @param wire wire details for testing
+ * @return #GNUNET_OK on success
+ */
+static int
+run_test (const char *name,
+ struct TALER_WIRE_Plugin *plugin,
+ json_t *wire)
+{
+ struct GNUNET_HashCode salt;
+ struct TALER_MasterSignatureP sig;
+ json_t *lwire;
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &salt,
+ sizeof (salt));
+ if (GNUNET_OK !=
+ plugin->sign_wire_details (plugin->cls,
+ wire,
+ &priv_key,
+ &salt,
+ &sig))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ json_object_set_new (wire,
+ "salt",
+ GNUNET_JSON_from_data (&salt,
+ sizeof (salt)));
+ json_object_set_new (wire,
+ "sig",
+ GNUNET_JSON_from_data (&sig,
+ sizeof (sig)));
+ if (GNUNET_OK !=
+ plugin->wire_validate (plugin->cls,
+ wire,
+ &pub_key))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ /* load wire details from file */
+ lwire = plugin->get_wire_details (plugin->cls,
+ cfg,
+ name);
+ if (NULL == lwire)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ plugin->wire_validate (plugin->cls,
+ lwire,
+ &pub_key))
+ {
+ GNUNET_break (0);
+ json_decref (lwire);
+ return GNUNET_SYSERR;
+ }
+ json_decref (lwire);
+ return GNUNET_OK;
+}
+
+
int
main (int argc,
const char *const argv[])
{
json_t *wire;
- json_error_t error;
int ret;
- struct GNUNET_CONFIGURATION_Handle *cfg;
struct TALER_WIRE_Plugin *plugin;
const struct TestBlock *test;
unsigned int i;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
GNUNET_log_setup ("test-wire-plugin",
"WARNING",
NULL);
cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "exchange",
- "currency",
- "EUR");
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_load (cfg,
+ "test_wire_plugin.conf"));
+ pk = GNUNET_CRYPTO_eddsa_key_create_from_file ("test_wire_plugin_key.priv");
+ priv_key.eddsa_priv = *pk;
+ GNUNET_free (pk);
+ GNUNET_CRYPTO_eddsa_key_get_public (&priv_key.eddsa_priv,
+ &pub_key.eddsa_pub);
ret = GNUNET_OK;
for (i=0;NULL != (test = &tests[i])->plugin_name;i++)
{
@@ -82,7 +172,7 @@ main (int argc,
GNUNET_assert (NULL != plugin);
wire = json_loads (test->json_proto, 0, NULL);
GNUNET_assert (NULL != wire);
- // FIXME: do test...
+ ret = run_test (test->plugin_name, plugin, wire);
json_decref (wire);
TALER_WIRE_plugin_unload (plugin);
if (GNUNET_OK != ret)
diff --git a/src/wire/test_wire_plugin.conf b/src/wire/test_wire_plugin.conf
new file mode 100644
index 000000000..ece816954
--- /dev/null
+++ b/src/wire/test_wire_plugin.conf
@@ -0,0 +1,21 @@
+# This file is in the public domain.
+#
+[test]
+# This is the response we give out for the /wire request. It provides
+# wallets with the bank information for transfers to the exchange.
+TEST_RESPONSE_FILE = test_wire_plugin_test.json
+
+[sepa]
+# This is the response we give out for the /wire request. It provides
+# wallets with the bank information for transfers to the exchange.
+SEPA_RESPONSE_FILE = test_wire_plugin_sepa.json
+
+
+[wire-outgoing-test]
+# For transfers made by the exchange, we need to know
+# the URI of the bank (where the /admin/add/incoming API
+# is avaialble).
+BANK_URI = http://localhost/
+
+[exchange]
+CURRENCY = "EUR"
diff --git a/src/wire/test_wire_plugin_key.priv b/src/wire/test_wire_plugin_key.priv
new file mode 100644
index 000000000..26b4f26f6
--- /dev/null
+++ b/src/wire/test_wire_plugin_key.priv
@@ -0,0 +1 @@
+?Sgb@Js; %aKȉs_Hў \ No newline at end of file
diff --git a/src/wire/test_wire_plugin_sepa.json b/src/wire/test_wire_plugin_sepa.json
new file mode 100644
index 000000000..175345f0c
--- /dev/null
+++ b/src/wire/test_wire_plugin_sepa.json
@@ -0,0 +1,8 @@
+{
+ "salt": "32V01R7K4T02S74PZZMVXRQ1K7FR948RBNB9BJ5Z101HEQFH7CW7J82006GY3BPTGQ4FM775PSSRD3K9MY97HSNVVCGEVBPVSAQ2710",
+ "type": "sepa",
+ "iban": "DE67830654080004822650",
+ "sig": "K48GPPM715ZXX0DC597WESD5ECT3R0B3TAFQMB68SBF4K5CZ5KCE9NESN1JX412SPZ82PSV7JAPVJFXDDTZ63YV4295S5RC28E4221G",
+ "name": "GNUnet e.V.",
+ "bic": "GENODEF1SLR"
+} \ No newline at end of file
diff --git a/src/wire/test_wire_plugin_test.json b/src/wire/test_wire_plugin_test.json
new file mode 100644
index 000000000..6fe6b2359
--- /dev/null
+++ b/src/wire/test_wire_plugin_test.json
@@ -0,0 +1,7 @@
+{
+ "type": "test",
+ "bank_uri": "http://localhost/",
+ "sig": "KX1CMHNFH1WE10244AEF07AXHJCF9PZDZVNZBC9P4EJEQ1MH1Y3C2TWF08VTQMK4N5TCV0V1VTGWSV0WB8TB9YQRZW87F5A6KCEZ81R",
+ "account_number": 42,
+ "salt": "EZV905MQPVAZEMGC6SEZQF2Z75P6ZKTN8TX00JHN11S7J81DQ78G8Z551K6TGR9WHPP0JW1X9J9X9CVRY48JTHBCP6Q4XKJ6R2G18G0"
+} \ No newline at end of file