aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-08-11 23:35:33 +0200
committerChristian Grothoff <christian@grothoff.org>2022-08-11 23:35:33 +0200
commit1009084e94b8e8cf19e3b5568c3cccaba2bd2209 (patch)
treea346997dedd05f685ba7addc59e288dfa550ad0e /src/testing
parentb061ea85c84facfc78c34edface367c5f040bc9c (diff)
downloadexchange-1009084e94b8e8cf19e3b5568c3cccaba2bd2209.tar.xz
major rework of the KYC logic, making it more configurable, not complete, but tests pass again
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_kyc_api.c68
-rw-r--r--src/testing/test_kyc_api.conf38
-rw-r--r--src/testing/testing_api_cmd_batch_withdraw.c2
-rw-r--r--src/testing/testing_api_cmd_kyc_proof.c28
-rw-r--r--src/testing/testing_api_cmd_kyc_wallet_get.c12
-rw-r--r--src/testing/testing_api_cmd_withdraw.c5
6 files changed, 111 insertions, 42 deletions
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index 303c7e11a..cfd793a69 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2021 Taler Systems SA
+ Copyright (C) 2014-2022 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
@@ -124,11 +124,12 @@ run (void *cls,
"EUR:5",
0, /* age restriction off */
MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
- TALER_TESTING_cmd_proof_kyc ("proof-kyc",
- "create-reserve-1",
- "pass",
- "state",
- MHD_HTTP_SEE_OTHER),
+ TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc",
+ "create-reserve-1",
+ "kyc-provider-test-oauth2",
+ "pass",
+ "state",
+ MHD_HTTP_SEE_OTHER),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-with-kyc",
"create-reserve-1",
"EUR:5",
@@ -158,26 +159,35 @@ run (void *cls,
struct TALER_TESTING_Command track[] = {
CMD_EXEC_AGGREGATOR ("run-aggregator-before-kyc"),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-no-kyc"),
+ TALER_TESTING_cmd_track_transaction (
+ "track-deposit-kyc-ready",
+ "deposit-simple",
+ 0,
+ MHD_HTTP_ACCEPTED,
+ NULL),
TALER_TESTING_cmd_check_kyc_get ("check-kyc-deposit",
- "track-deposit",
+ "track-deposit-kyc-ready",
MHD_HTTP_ACCEPTED),
- TALER_TESTING_cmd_proof_kyc ("proof-kyc-no-service",
- "track-deposit",
- "bad",
- "state",
- MHD_HTTP_BAD_GATEWAY),
+ TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc-no-service",
+ "track-deposit-kyc-ready",
+ "kyc-provider-test-oauth2",
+ "bad",
+ "state",
+ MHD_HTTP_BAD_GATEWAY),
TALER_TESTING_cmd_oauth ("start-oauth-service",
6666),
- TALER_TESTING_cmd_proof_kyc ("proof-kyc-fail",
- "track-deposit",
- "bad",
- "state",
- MHD_HTTP_FORBIDDEN),
- TALER_TESTING_cmd_proof_kyc ("proof-kyc-fail",
- "track-deposit",
- "pass",
- "state",
- MHD_HTTP_SEE_OTHER),
+ TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc-fail",
+ "track-deposit-kyc-ready",
+ "kyc-provider-test-oauth2",
+ "bad",
+ "state",
+ MHD_HTTP_FORBIDDEN),
+ TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc-fail",
+ "track-deposit-kyc-ready",
+ "kyc-provider-test-oauth2",
+ "pass",
+ "state",
+ MHD_HTTP_SEE_OTHER),
CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"),
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-499c",
@@ -190,15 +200,19 @@ run (void *cls,
};
struct TALER_TESTING_Command wallet_kyc[] = {
+ TALER_TESTING_cmd_oauth ("start-oauth-service",
+ 6666),
TALER_TESTING_cmd_wallet_kyc_get (
"wallet-kyc-fail",
NULL,
+ "EUR:1000000",
MHD_HTTP_OK),
- TALER_TESTING_cmd_proof_kyc ("proof-wallet-kyc",
- "wallet-kyc-fail",
- "pass",
- "state",
- MHD_HTTP_SEE_OTHER),
+ TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-wallet-kyc",
+ "wallet-kyc-fail",
+ "kyc-provider-test-oauth2",
+ "pass",
+ "state",
+ MHD_HTTP_SEE_OTHER),
TALER_TESTING_cmd_check_kyc_get (
"wallet-kyc-check",
"wallet-kyc-fail",
diff --git a/src/testing/test_kyc_api.conf b/src/testing/test_kyc_api.conf
index 09e7cdc7e..56c8eb858 100644
--- a/src/testing/test_kyc_api.conf
+++ b/src/testing/test_kyc_api.conf
@@ -46,16 +46,12 @@ DB = postgres
BASE_URL = "http://localhost:8081/"
+# Obsolete options, migrate to withdraw once implemented...
KYC_MODE = OAUTH2
-
-KYC_WALLET_BALANCE_LIMIT = EUR:1
-
KYC_WITHDRAW_PERIOD = "31 days"
-
KYC_WITHDRAW_LIMIT = EUR:8
[exchange-kyc-oauth2]
-
KYC_OAUTH2_AUTH_URL = http://localhost:6666/oauth/v2/token
KYC_OAUTH2_LOGIN_URL = http://localhost:6666/oauth/v2/login
KYC_INFO_URL = http://localhost:6666/api/user/me
@@ -63,6 +59,38 @@ KYC_OAUTH2_CLIENT_ID = taler-exchange
KYC_OAUTH2_CLIENT_SECRET = exchange-secret
KYC_OAUTH2_POST_URL = http://example.com/
+# end of obsolete options...
+
+[kyc-provider-test-oauth2]
+COST = 0
+LOGIC = oauth2
+USER_TYPE = INDIVIDUAL
+PROVIDED_CHECKS = DUMMY
+KYC_OAUTH2_VALIDITY = forever
+KYC_OAUTH2_AUTH_URL = http://localhost:6666/oauth/v2/token
+KYC_OAUTH2_LOGIN_URL = http://localhost:6666/oauth/v2/login
+KYC_OAUTH2_INFO_URL = http://localhost:6666/api/user/me
+KYC_OAUTH2_CLIENT_ID = taler-exchange
+KYC_OAUTH2_CLIENT_SECRET = exchange-secret
+KYC_OAUTH2_POST_URL = http://example.com/
+
+[kyc-legitimization-balance-high]
+OPERATION_TYPE = BALANCE
+REQUIRED_CHECKS = DUMMY
+THRESHOLD = EUR:8
+
+[kyc-legitimization-deposit-any]
+OPERATION_TYPE = DEPOSIT
+REQUIRED_CHECKS = DUMMY
+THRESHOLD = EUR:0
+TIMEFRAME = 1d
+
+[kyc-legitimization-withdraw]
+OPERATION_TYPE = WITHDRAW
+REQUIRED_CHECKS = DUMMY
+THRESHOLD = EUR:8
+TIMEFRAME = 1d
+
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c
index fb290f1e8..0cc881155 100644
--- a/src/testing/testing_api_cmd_batch_withdraw.c
+++ b/src/testing/testing_api_cmd_batch_withdraw.c
@@ -283,7 +283,7 @@ batch_withdraw_run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv,
&ws->reserve_pub.eddsa_pub);
ws->reserve_payto_uri
- = TALER_payto_from_reserve (ws->exchange_url,
+ = TALER_reserve_make_payto (ws->exchange_url,
&ws->reserve_pub);
for (unsigned int i = 0; i<ws->num_coins; i++)
diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c
index f9a65afb3..52fb65219 100644
--- a/src/testing/testing_api_cmd_kyc_proof.c
+++ b/src/testing/testing_api_cmd_kyc_proof.c
@@ -49,6 +49,11 @@ struct KycProofGetState
const char *state;
/**
+ * Logic section name to pass to `/kyc-proof/` handler.
+ */
+ const char *logic;
+
+ /**
* Expected HTTP response code.
*/
unsigned int expected_response_code;
@@ -133,6 +138,7 @@ proof_kyc_run (void *cls,
const struct TALER_TESTING_Command *res_cmd;
const char **payto_uri;
struct TALER_PaytoHashP h_payto;
+ char *uargs;
(void) cmd;
kps->is = is;
@@ -169,12 +175,17 @@ proof_kyc_run (void *cls,
TALER_payto_hash (*payto_uri,
&h_payto);
}
+ GNUNET_asprintf (&uargs,
+ "?code=%s&state=%s",
+ kps->code,
+ kps->state);
kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange,
&h_payto,
- kps->code,
- kps->state,
+ kps->logic,
+ uargs,
&proof_kyc_cb,
kps);
+ GNUNET_free (uargs);
GNUNET_assert (NULL != kps->kph);
}
@@ -236,17 +247,20 @@ proof_kyc_traits (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_proof_kyc (const char *label,
- const char *payment_target_reference,
- const char *code,
- const char *state,
- unsigned int expected_response_code)
+TALER_TESTING_cmd_proof_kyc_oauth2 (
+ const char *label,
+ const char *payment_target_reference,
+ const char *logic_section,
+ const char *code,
+ const char *state,
+ unsigned int expected_response_code)
{
struct KycProofGetState *kps;
kps = GNUNET_new (struct KycProofGetState);
kps->code = code;
kps->state = state;
+ kps->logic = logic_section;
kps->payment_target_reference = payment_target_reference;
kps->expected_response_code = expected_response_code;
{
diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c
index 91ad09ff9..d86692f80 100644
--- a/src/testing/testing_api_cmd_kyc_wallet_get.c
+++ b/src/testing/testing_api_cmd_kyc_wallet_get.c
@@ -70,6 +70,11 @@ struct KycWalletGetState
struct TALER_EXCHANGE_KycWalletHandle *kwh;
/**
+ * Balance to pass to the exchange.
+ */
+ struct TALER_Amount balance;
+
+ /**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
@@ -170,10 +175,11 @@ wallet_kyc_run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
&kwg->reserve_pub.eddsa_pub);
kwg->reserve_payto_uri
- = TALER_payto_from_reserve (TALER_EXCHANGE_get_base_url (is->exchange),
+ = TALER_reserve_make_payto (TALER_EXCHANGE_get_base_url (is->exchange),
&kwg->reserve_pub);
kwg->kwh = TALER_EXCHANGE_kyc_wallet (is->exchange,
&kwg->reserve_priv,
+ &kwg->balance,
&wallet_kyc_cb,
kwg);
GNUNET_assert (NULL != kwg->kwh);
@@ -242,6 +248,7 @@ wallet_kyc_traits (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_wallet_kyc_get (const char *label,
const char *reserve_reference,
+ const char *threshold_balance,
unsigned int expected_response_code)
{
struct KycWalletGetState *kwg;
@@ -249,6 +256,9 @@ TALER_TESTING_cmd_wallet_kyc_get (const char *label,
kwg = GNUNET_new (struct KycWalletGetState);
kwg->reserve_reference = reserve_reference;
kwg->expected_response_code = expected_response_code;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (threshold_balance,
+ &kwg->balance));
{
struct TALER_TESTING_Command cmd = {
.cls = kwg,
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index 44e295338..6b77a35e7 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -320,6 +320,9 @@ reserve_withdraw_cb (void *cls,
case MHD_HTTP_GONE:
/* theoretically could check that the key was actually */
break;
+ case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
+ /* KYC required */
+ break;
default:
/* Unsupported status code (by test harness) */
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -375,7 +378,7 @@ withdraw_run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv,
&ws->reserve_pub.eddsa_pub);
ws->reserve_payto_uri
- = TALER_payto_from_reserve (ws->exchange_url,
+ = TALER_reserve_make_payto (ws->exchange_url,
&ws->reserve_pub);
if (NULL == ws->reuse_coin_key_ref)