From 39e6ebbc169a250b6ae11928f5ce58696f09f19f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 17 Nov 2021 11:01:54 +0100 Subject: complete KYC test --- src/testing/testing_api_cmd_kyc_get.c | 93 ++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'src/testing/testing_api_cmd_kyc_get.c') diff --git a/src/testing/testing_api_cmd_kyc_get.c b/src/testing/testing_api_cmd_kyc_get.c index 0d7a405e..07fe84e1 100644 --- a/src/testing/testing_api_cmd_kyc_get.c +++ b/src/testing/testing_api_cmd_kyc_get.c @@ -61,6 +61,12 @@ struct KycGetState */ const char *exchange_url; + /** + * Set to the payment target UUID of the first exchange account + * for which we failed to pass the KYC check, or 0. + */ + uint64_t payment_target_uuid; + /** * Expected HTTP response code. */ @@ -117,6 +123,61 @@ kyc_get_cb (void *cls, kr->hr.http_status); TALER_TESTING_FAIL (cs->is); } + switch (kr->hr.http_status) + { + case MHD_HTTP_ACCEPTED: + if (0 != kr->details.kyc_status.pending_kycs_length) + { + const char *url; + const char *tok; + const char *end; + char *dec; + const char *eq; + unsigned long long uuid; + size_t toklen; + char dummy; + + url = kr->details.kyc_status.pending_kycs[0].kyc_url; + tok = strstr (url, "&redirect_uri="); + if (NULL == tok) + TALER_TESTING_FAIL (cs->is); + tok += strlen ("&redirect_uri="); + end = strchr (tok, '&'); + if (NULL == end) + toklen = strlen (tok); + else + toklen = end - tok; + (void) GNUNET_STRINGS_urldecode (tok, + toklen, + &dec); + eq = strrchr (dec, '/'); + if (NULL == eq) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Received unexpected KYC URL `%s' (%s)\n", + url, + dec); + GNUNET_free (dec); + TALER_TESTING_FAIL (cs->is); + } + eq++; + if (1 != sscanf (eq, + "%llu%c", + &uuid, + &dummy)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Received unexpected KYC URL `%s' (%s)\n", + url, + dec); + GNUNET_free (dec); + TALER_TESTING_FAIL (cs->is); + } + GNUNET_free (dec); + cs->payment_target_uuid = uuid; + } + break; + } TALER_TESTING_interpreter_next (cs->is); } @@ -181,6 +242,35 @@ kyc_get_run (void *cls, } +/** + * Offer internal data from "KYC" GET CMD. + * + * @param cls closure. + * @param[out] ret result (could be anything). + * @param trait name of the trait. + * @param index index number of the object to offer. + * @return #GNUNET_OK on success. + */ +static enum GNUNET_GenericReturnValue +kyc_get_traits (void *cls, + const void **ret, + const char *trait, + unsigned int index) +{ + struct KycGetState *cs = cls; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_payment_target_uuid ( + &cs->payment_target_uuid), + TALER_TESTING_trait_end () + }; + + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); +} + + struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_kyc_get (const char *label, const char *merchant_url, @@ -202,7 +292,8 @@ TALER_TESTING_cmd_merchant_kyc_get (const char *label, .cls = cs, .label = label, .run = &kyc_get_run, - .cleanup = &kyc_get_cleanup + .cleanup = &kyc_get_cleanup, + .traits = &kyc_get_traits }; return cmd; -- cgit v1.2.3