aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-08 08:52:25 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-08 08:52:25 +0100
commitd9690fb08711847957a4ad101e24d453d843253a (patch)
tree6def3a0c708966f6948ed02cfb2639042120f6ff
parent398ef9d971019cb2cce28b5936f491bc0738b046 (diff)
add KYC test skeleton
-rw-r--r--src/testing/Makefile.am21
-rw-r--r--src/testing/test_kyc_api.c217
-rw-r--r--src/testing/test_kyc_api.conf140
3 files changed, 377 insertions, 1 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 6d2ddf461..d02e6377f 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -122,6 +122,7 @@ check_PROGRAMS = \
test_exchange_api_revocation \
test_exchange_api_overlapping_keys_bug \
test_exchange_management_api \
+ test_kyc_api \
test_taler_exchange_aggregator-postgres \
test_taler_exchange_wirewatch-postgres
if HAVE_TWISTER
@@ -152,6 +153,7 @@ test_auditor_api_LDADD = \
-ljansson \
$(XLIB)
+
test_auditor_api_version_SOURCES = \
test_auditor_api_version.c
test_auditor_api_version_LDADD = \
@@ -339,6 +341,22 @@ test_bank_api_with_pybank_twisted_LDADD = \
$(XLIB)
+test_kyc_api_SOURCES = \
+ test_kyc_api.c
+test_kyc_api_LDADD = \
+ libtalertesting.la \
+ $(top_builddir)/src/lib/libtalerauditor.la \
+ $(top_builddir)/src/lib/libtalerexchange.la \
+ $(LIBGCRYPT_LIBS) \
+ $(top_builddir)/src/bank-lib/libtalerfakebank.la \
+ $(top_builddir)/src/bank-lib/libtalerbank.la \
+ $(top_builddir)/src/json/libtalerjson.la \
+ $(top_builddir)/src/util/libtalerutil.la \
+ -lgnunetcurl \
+ -lgnunetutil \
+ -ljansson \
+ $(XLIB)
+
# Distribution
EXTRA_DIST = \
@@ -365,4 +383,5 @@ EXTRA_DIST = \
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
test_taler_exchange_httpd_home/.local/share/taler/exchange/wirefees/x-taler-bank.fee \
test-taler-exchange-aggregator-postgres.conf \
- test-taler-exchange-wirewatch-postgres.conf
+ test-taler-exchange-wirewatch-postgres.conf \
+ test_kyc_api.conf
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
new file mode 100644
index 000000000..4df552c40
--- /dev/null
+++ b/src/testing/test_kyc_api.c
@@ -0,0 +1,217 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2014-2021 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 testing/test_kyc_api.c
+ * @brief testcase to test the KYC processes
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "taler_util.h"
+#include "taler_signatures.h"
+#include "taler_exchange_service.h"
+#include "taler_json_lib.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include "taler_bank_service.h"
+#include "taler_fakebank_lib.h"
+#include "taler_testing_lib.h"
+
+
+/**
+ * Configuration file we use. One (big) configuration is used
+ * for the various components for this test.
+ */
+#define CONFIG_FILE "test_kyc_api.conf"
+
+/**
+ * Exchange configuration data.
+ */
+static struct TALER_TESTING_ExchangeConfiguration ec;
+
+/**
+ * Bank configuration data.
+ */
+static struct TALER_TESTING_BankConfiguration bc;
+
+/**
+ * Execute the taler-exchange-wirewatch command with
+ * our configuration file.
+ *
+ * @param label label to use for the command.
+ */
+#define CMD_EXEC_WIREWATCH(label) \
+ TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE)
+
+/**
+ * Execute the taler-exchange-aggregator, closer and transfer commands with
+ * our configuration file.
+ *
+ * @param label label to use for the command.
+ */
+#define CMD_EXEC_AGGREGATOR(label) \
+ TALER_TESTING_cmd_exec_aggregator /*_with_kyc*/ (label, CONFIG_FILE), \
+ TALER_TESTING_cmd_exec_transfer (label, CONFIG_FILE)
+
+/**
+ * Run wire transfer of funds from some user's account to the
+ * exchange.
+ *
+ * @param label label to use for the command.
+ * @param amount amount to transfer, i.e. "EUR:1"
+ */
+#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
+ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
+ &bc.exchange_auth, \
+ bc.user42_payto)
+
+/**
+ * Main function that will tell the interpreter what commands to
+ * run.
+ *
+ * @param cls closure
+ */
+static void
+run (void *cls,
+ struct TALER_TESTING_Interpreter *is)
+{
+ /**
+ * Test withdraw.
+ */
+ struct TALER_TESTING_Command withdraw[] = {
+ CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
+ "EUR:5.01"),
+ TALER_TESTING_cmd_check_bank_admin_transfer (
+ "check-create-reserve-1",
+ "EUR:5.01", bc.user42_payto, bc.exchange_payto,
+ "create-reserve-1"),
+ CMD_EXEC_WIREWATCH ("wirewatch-1"),
+ TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
+ "create-reserve-1",
+ "EUR:5",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_end ()
+ };
+ struct TALER_TESTING_Command spend[] = {
+ TALER_TESTING_cmd_deposit (
+ "deposit-simple",
+ "withdraw-coin-1",
+ 0,
+ bc.user42_payto,
+ "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
+ GNUNET_TIME_UNIT_ZERO,
+ "EUR:5",
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_end ()
+ };
+
+ struct TALER_TESTING_Command track[] = {
+ CMD_EXEC_AGGREGATOR ("run-aggregator"),
+ TALER_TESTING_cmd_check_bank_transfer (
+ "check_bank_transfer-499c",
+ ec.exchange_url,
+ "EUR:4.98",
+ bc.exchange_payto,
+ bc.user42_payto),
+ TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
+ TALER_TESTING_cmd_end ()
+ };
+
+ struct TALER_TESTING_Command commands[] = {
+ TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
+ CONFIG_FILE,
+ "EUR:0.01",
+ "EUR:0.01"),
+ TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
+ MHD_HTTP_NO_CONTENT,
+ false),
+ TALER_TESTING_cmd_wire_add ("add-wire-account",
+ "payto://x-taler-bank/localhost/2",
+ MHD_HTTP_NO_CONTENT,
+ false),
+ TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
+ CONFIG_FILE),
+ TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
+ 2),
+ TALER_TESTING_cmd_exchanges_with_url ("check-exchange",
+ MHD_HTTP_OK,
+ "http://localhost:8081/"),
+ TALER_TESTING_cmd_batch ("withdraw",
+ withdraw),
+ TALER_TESTING_cmd_batch ("spend",
+ spend),
+ TALER_TESTING_cmd_batch ("track",
+ track),
+ TALER_TESTING_cmd_end ()
+ };
+
+ TALER_TESTING_run_with_fakebank (is,
+ commands,
+ bc.exchange_auth.wire_gateway_url);
+}
+
+
+int
+main (int argc,
+ char *const *argv)
+{
+ /* These environment variables get in the way... */
+ unsetenv ("XDG_DATA_HOME");
+ unsetenv ("XDG_CONFIG_HOME");
+ GNUNET_log_setup ("test-kyc-api",
+ "INFO",
+ NULL);
+ /* Check fakebank port is available and get configuration data. */
+ if (GNUNET_OK !=
+ TALER_TESTING_prepare_fakebank (CONFIG_FILE,
+ "exchange-account-2",
+ &bc))
+ return 77;
+ TALER_TESTING_cleanup_files (CONFIG_FILE);
+ /* @helpers. Run keyup, create tables, ... Note: it
+ * fetches the port number from config in order to see
+ * if it's available. */
+ switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+ GNUNET_YES,
+ &ec))
+ {
+ case GNUNET_SYSERR:
+ GNUNET_break (0);
+ return 1;
+ case GNUNET_NO:
+ return 77;
+ case GNUNET_OK:
+ if (GNUNET_OK !=
+ /* Set up event loop and reschedule context, plus
+ * start/stop the exchange. It calls TALER_TESTING_setup
+ * which creates the 'is' object.
+ */
+ TALER_TESTING_setup_with_exchange (&run,
+ NULL,
+ CONFIG_FILE))
+ return 1;
+ break;
+ default:
+ GNUNET_break (0);
+ return 1;
+ }
+ return 0;
+}
+
+
+/* end of test_kyc_api.c */
diff --git a/src/testing/test_kyc_api.conf b/src/testing/test_kyc_api.conf
new file mode 100644
index 000000000..03a5e2453
--- /dev/null
+++ b/src/testing/test_kyc_api.conf
@@ -0,0 +1,140 @@
+
+# This file is in the public domain.
+#
+[PATHS]
+# Persistent data storage for the testcase
+TALER_TEST_HOME = test_exchange_api_home/
+TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
+
+[taler-exchange-secmod-rsa]
+# Reduce from 1 year to speed up test
+LOOKAHEAD_SIGN = 24 days
+
+[taler-exchange-secmod-eddsa]
+# Reduce from 1 year to speed up test
+LOOKAHEAD_SIGN = 24 days
+# Reduce from 12 weeks to ensure we have multiple
+DURATION = 14 days
+
+
+[taler]
+# Currency supported by the exchange (can only be one)
+CURRENCY = EUR
+CURRENCY_ROUND_UNIT = EUR:0.01
+
+[auditor]
+BASE_URL = "http://localhost:8083/"
+
+# HTTP port the auditor listens to
+PORT = 8083
+
+TINY_AMOUNT = EUR:0.01
+
+[exchange]
+
+# HTTP port the exchange listens to
+PORT = 8081
+
+# Master public key used to sign the exchange's various keys
+MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
+
+# How to access our database
+DB = postgres
+
+# Base URL of the exchange. Must be set to a URL where the
+# exchange (or the twister) is actually listening.
+BASE_URL = "http://localhost:8081/"
+
+[exchangedb-postgres]
+CONFIG = "postgres:///talercheck"
+
+[auditordb-postgres]
+CONFIG = "postgres:///talercheck"
+
+# Sections starting with "exchange-account-" configure the bank accounts
+# of the exchange. The "URL" specifies the account in
+# payto://-format.
+[exchange-account-1]
+# What is the URL of our account?
+PAYTO_URI = "payto://x-taler-bank/localhost/42"
+
+[exchange-accountcredentials-1]
+WIRE_GATEWAY_URL = "http://localhost:8082/42/"
+
+[bank]
+HTTP_PORT = 8082
+
+# ENABLE_CREDIT = YES
+
+[exchange-account-2]
+# What is the bank account (with the "Taler Bank" demo system)?
+PAYTO_URI = "payto://x-taler-bank/localhost/2"
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+
+# Authentication information for basic authentication
+[exchange-accountcredentials-2]
+WIRE_GATEWAY_URL = "http://localhost:8082/2/"
+WIRE_GATEWAY_AUTH_METHOD = "basic"
+USERNAME = user
+PASSWORD = pass
+
+
+
+
+# Sections starting with "coin_" specify which denominations
+# the exchange should support (and their respective fee structure)
+[coin_eur_ct_1]
+value = EUR:0.01
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.00
+fee_deposit = EUR:0.00
+fee_refresh = EUR:0.01
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_ct_10]
+value = EUR:0.10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_1]
+value = EUR:1
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_5]
+value = EUR:5
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_10]
+value = EUR:10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024