From a046899b2ccd452f786051a41bc385cfb574bbcb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 20 Aug 2022 21:29:29 +0200 Subject: -major KYC update, fixes misc. issues --- src/testing/test_kyc_api.c | 30 ++++++++++++++++++--------- src/testing/testing_api_cmd_batch_withdraw.c | 25 +++++++++++++++------- src/testing/testing_api_cmd_deposits_get.c | 22 ++++++++++++++++---- src/testing/testing_api_cmd_kyc_check_get.c | 27 +++++++++--------------- src/testing/testing_api_cmd_kyc_proof.c | 31 +++++++--------------------- src/testing/testing_api_cmd_kyc_wallet_get.c | 24 ++++++++++++++------- src/testing/testing_api_cmd_purse_merge.c | 10 ++++----- src/testing/testing_api_cmd_reserve_purse.c | 10 ++++----- src/testing/testing_api_cmd_withdraw.c | 20 +++++++++++++----- 9 files changed, 115 insertions(+), 84 deletions(-) (limited to 'src/testing') diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 4d2e01b04..c25c94d39 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -124,8 +124,11 @@ run (void *cls, "EUR:5", 0, /* age restriction off */ MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), + TALER_TESTING_cmd_check_kyc_get ("check-kyc-withdraw", + "withdraw-coin-1-lacking-kyc", + MHD_HTTP_ACCEPTED), TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc", - "create-reserve-1", + "withdraw-coin-1-lacking-kyc", "kyc-provider-test-oauth2", "pass", "state", @@ -202,21 +205,22 @@ 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_wallet_kyc_get ("wallet-kyc-fail", + NULL, + "EUR:1000000", + MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), + TALER_TESTING_cmd_check_kyc_get ("check-kyc-wallet", + "wallet-kyc-fail", + MHD_HTTP_ACCEPTED), 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", - MHD_HTTP_OK), + TALER_TESTING_cmd_check_kyc_get ("wallet-kyc-check", + "wallet-kyc-fail", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_end () }; @@ -300,6 +304,9 @@ run (void *cls, MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, "push-get-contract", "p2p_create-reserve-1"), + TALER_TESTING_cmd_check_kyc_get ("check-kyc-purse-merge", + "purse-merge-into-reserve", + MHD_HTTP_ACCEPTED), TALER_TESTING_cmd_proof_kyc_oauth2 ("p2p_proof-kyc", "purse-merge-into-reserve", "kyc-provider-test-oauth2", @@ -338,6 +345,9 @@ run (void *cls, true /* upload contract */, GNUNET_TIME_UNIT_MINUTES, /* expiration */ "p2p_create-reserve-3"), + TALER_TESTING_cmd_check_kyc_get ("check-kyc-purse-create", + "purse-create-with-reserve", + MHD_HTTP_ACCEPTED), TALER_TESTING_cmd_proof_kyc_oauth2 ("p2p_proof-kyc-pull", "purse-create-with-reserve", "kyc-provider-test-oauth2", diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c index 252fbd7e8..b68ca99f7 100644 --- a/src/testing/testing_api_cmd_batch_withdraw.c +++ b/src/testing/testing_api_cmd_batch_withdraw.c @@ -141,10 +141,16 @@ struct BatchWithdrawState struct CoinState *coins; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement payto hash *if* the exchange replied with a + * request for KYC. + */ + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC. */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Length of the @e coins array. @@ -213,10 +219,6 @@ reserve_batch_withdraw_cb (void *cls, cs->exchange_vals = pcd->exchange_vals; } break; - case MHD_HTTP_ACCEPTED: - /* nothing to check */ - ws->kyc_uuid = wr->details.accepted.legitimization_uuid; - break; case MHD_HTTP_FORBIDDEN: /* nothing to check */ break; @@ -229,6 +231,13 @@ reserve_batch_withdraw_cb (void *cls, case MHD_HTTP_GONE: /* theoretically could check that the key was actually */ break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + /* nothing to check */ + ws->requirement_row + = wr->details.unavailable_for_legal_reasons.requirement_row; + ws->h_payto + = wr->details.unavailable_for_legal_reasons.h_payto; + break; default: /* Unsupported status code (by test harness) */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -417,7 +426,9 @@ batch_withdraw_traits (void *cls, TALER_TESTING_make_trait_reserve_pub (&ws->reserve_pub), TALER_TESTING_make_trait_amounts (index, &cs->amount), - TALER_TESTING_make_trait_legitimization_uuid (&ws->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), + TALER_TESTING_make_trait_h_payto ( + &ws->h_payto), TALER_TESTING_make_trait_payto_uri ( (const char **) &ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url ( diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 5f1be9bb4..8fd4e813c 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -50,10 +50,18 @@ struct TrackTransactionState unsigned int expected_response_code; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement payto hash *if* the exchange replied with a + * request for KYC (#MHD_HTTP_ACCEPTED). + * Note: set based on our @e merchant_payto_uri, as + * the exchange does not respond with the payto hash. + */ + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC (#MHD_HTTP_ACCEPTED). */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Reference to any operation that can provide a transaction. @@ -158,7 +166,10 @@ deposit_wtid_cb (void *cls, break; case MHD_HTTP_ACCEPTED: /* allowed, nothing to check here */ - tts->kyc_uuid = dr->details.accepted.legitimization_uuid; + TALER_payto_hash (tts->merchant_payto_uri, + &tts->h_payto); + tts->requirement_row + = dr->details.accepted.requirement_row; break; case MHD_HTTP_NOT_FOUND: /* allowed, nothing to check here */ @@ -321,7 +332,10 @@ track_transaction_traits (void *cls, struct TrackTransactionState *tts = cls; struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_wtid (&tts->wtid), - TALER_TESTING_make_trait_legitimization_uuid (&tts->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row ( + &tts->requirement_row), + TALER_TESTING_make_trait_h_payto ( + &tts->h_payto), TALER_TESTING_make_trait_payto_uri ( (const char **) &tts->merchant_payto_uri), TALER_TESTING_trait_end () diff --git a/src/testing/testing_api_cmd_kyc_check_get.c b/src/testing/testing_api_cmd_kyc_check_get.c index a67a08c18..3241aae3e 100644 --- a/src/testing/testing_api_cmd_kyc_check_get.c +++ b/src/testing/testing_api_cmd_kyc_check_get.c @@ -93,7 +93,7 @@ check_kyc_cb (void *cls, case MHD_HTTP_OK: break; case MHD_HTTP_ACCEPTED: - kcg->kyc_url = GNUNET_strdup (ks->details.kyc_url); + kcg->kyc_url = GNUNET_strdup (ks->details.accepted.kyc_url); break; case MHD_HTTP_NO_CONTENT: break; @@ -119,9 +119,8 @@ check_kyc_run (void *cls, { struct KycCheckGetState *kcg = cls; const struct TALER_TESTING_Command *res_cmd; - const char **payto_uri; - const uint64_t *payment_target; - struct TALER_PaytoHashP h_payto; + const uint64_t *requirement_row; + const struct TALER_PaytoHashP *h_payto; (void) cmd; kcg->is = is; @@ -135,36 +134,30 @@ check_kyc_run (void *cls, return; } if (GNUNET_OK != - TALER_TESTING_get_trait_payto_uri (res_cmd, - &payto_uri)) + TALER_TESTING_get_trait_legi_requirement_row (res_cmd, + &requirement_row)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (kcg->is); return; } if (GNUNET_OK != - TALER_TESTING_get_trait_legitimization_uuid (res_cmd, - &payment_target)) + TALER_TESTING_get_trait_h_payto (res_cmd, + &h_payto)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (kcg->is); return; } - if ( (NULL == *payto_uri) || - (0 == *payment_target) ) + if (0 == *requirement_row) { GNUNET_break (0); TALER_TESTING_interpreter_fail (kcg->is); return; } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Running KYC check for payto URI: %s\n", - *payto_uri); - TALER_payto_hash (*payto_uri, - &h_payto); kcg->kwh = TALER_EXCHANGE_kyc_check (is->exchange, - *payment_target, - &h_payto, + *requirement_row, + h_payto, TALER_KYCLOGIC_KYC_UT_INDIVIDUAL, GNUNET_TIME_UNIT_SECONDS, &check_kyc_cb, diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index 52fb65219..ed0df5564 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -136,8 +136,7 @@ proof_kyc_run (void *cls, { struct KycProofGetState *kps = cls; const struct TALER_TESTING_Command *res_cmd; - const char **payto_uri; - struct TALER_PaytoHashP h_payto; + const struct TALER_PaytoHashP *h_payto; char *uargs; (void) cmd; @@ -152,35 +151,19 @@ proof_kyc_run (void *cls, return; } if (GNUNET_OK != - TALER_TESTING_get_trait_payto_uri (res_cmd, - &payto_uri)) + TALER_TESTING_get_trait_h_payto (res_cmd, + &h_payto)) { - const struct TALER_PaytoHashP *hpt; - - if (GNUNET_OK != - TALER_TESTING_get_trait_h_payto (res_cmd, - &hpt)) - { - GNUNET_break (0); - TALER_TESTING_interpreter_fail (kps->is); - return; - } - h_payto = *hpt; - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Triggering KYC proof for %s\n", - *payto_uri); - TALER_payto_hash (*payto_uri, - &h_payto); + GNUNET_break (0); + TALER_TESTING_interpreter_fail (kps->is); + return; } GNUNET_asprintf (&uargs, "?code=%s&state=%s", kps->code, kps->state); kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange, - &h_payto, + h_payto, kps->logic, uargs, &proof_kyc_cb, diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c index 775aa1a82..23df3b9df 100644 --- a/src/testing/testing_api_cmd_kyc_wallet_get.c +++ b/src/testing/testing_api_cmd_kyc_wallet_get.c @@ -59,10 +59,16 @@ struct KycWalletGetState unsigned int expected_response_code; /** - * Set to the KYC UUID *if* the exchange replied with - * a request for KYC (#MHD_HTTP_ACCEPTED). + * Set to the KYC requirement payto hash *if* the exchange replied with a + * request for KYC (#MHD_HTTP_OK). */ - uint64_t kyc_uuid; + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with + * a request for KYC (#MHD_HTTP_OK). + */ + uint64_t requirement_row; /** * Handle to the "track transaction" pending operation. @@ -111,15 +117,18 @@ wallet_kyc_cb (void *cls, } switch (wkr->http_status) { - case MHD_HTTP_OK: - kwg->kyc_uuid = wkr->legitimization_uuid; - break; case MHD_HTTP_NO_CONTENT: break; case MHD_HTTP_FORBIDDEN: GNUNET_break (0); TALER_TESTING_interpreter_fail (is); return; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + kwg->requirement_row + = wkr->details.unavailable_for_legal_reasons.requirement_row; + kwg->h_payto + = wkr->details.unavailable_for_legal_reasons.h_payto; + break; default: GNUNET_break (0); break; @@ -232,7 +241,8 @@ wallet_kyc_traits (void *cls, struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_reserve_priv (&kwg->reserve_priv), TALER_TESTING_make_trait_reserve_pub (&kwg->reserve_pub), - TALER_TESTING_make_trait_legitimization_uuid (&kwg->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&kwg->requirement_row), + TALER_TESTING_make_trait_h_payto (&kwg->h_payto), TALER_TESTING_make_trait_payto_uri ( (const char **) &kwg->reserve_payto_uri), TALER_TESTING_trait_end () diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index e40bcedcf..2ab3a2357 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -78,10 +78,10 @@ struct PurseMergeState struct TALER_PaytoHashP h_payto; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC. */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Reserve history entry that corresponds to this operation. @@ -169,8 +169,8 @@ merge_cb (void *cls, break; case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: /* KYC required */ - ds->kyc_uuid = - dr->details.unavailable_for_legal_reasons.legitimization_uuid; + ds->requirement_row = + dr->details.unavailable_for_legal_reasons.requirement_row; break; } @@ -385,7 +385,7 @@ merge_traits (void *cls, TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_timestamp (0, &ds->merge_timestamp), - TALER_TESTING_make_trait_legitimization_uuid (&ds->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), TALER_TESTING_make_trait_h_payto (&ds->h_payto), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index cd9ea1ea3..cdffa97fe 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -104,10 +104,10 @@ struct ReservePurseState struct TALER_PaytoHashP h_payto; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC. */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Contract terms for the purse. @@ -165,8 +165,8 @@ purse_cb (void *cls, { case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: /* KYC required */ - ds->kyc_uuid = - dr->details.unavailable_for_legal_reasons.legitimization_uuid; + ds->requirement_row = + dr->details.unavailable_for_legal_reasons.requirement_row; break; } TALER_TESTING_interpreter_next (ds->is); @@ -309,7 +309,7 @@ purse_traits (void *cls, TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv), TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_reserve_sig (&ds->reserve_sig), - TALER_TESTING_make_trait_legitimization_uuid (&ds->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), TALER_TESTING_make_trait_h_payto (&ds->h_payto), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 96e703fdf..ce2c49ccc 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -171,10 +171,16 @@ struct WithdrawState struct GNUNET_TIME_Relative total_backoff; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement payto hash *if* the exchange replied with a + * request for KYC. + */ + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC. */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Expected HTTP response code to the request. @@ -318,8 +324,10 @@ reserve_withdraw_cb (void *cls, break; case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: /* KYC required */ - ws->kyc_uuid = - wr->details.unavailable_for_legal_reasons.legitimization_uuid; + ws->requirement_row = + wr->details.unavailable_for_legal_reasons.requirement_row; + ws->h_payto + = wr->details.unavailable_for_legal_reasons.h_payto; break; default: /* Unsupported status code (by test harness) */ @@ -538,7 +546,9 @@ withdraw_traits (void *cls, TALER_TESTING_make_trait_reserve_priv (&ws->reserve_priv), TALER_TESTING_make_trait_reserve_pub (&ws->reserve_pub), TALER_TESTING_make_trait_amount (&ws->amount), - TALER_TESTING_make_trait_legitimization_uuid (&ws->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&ws->requirement_row), + TALER_TESTING_make_trait_h_payto ( + &ws->h_payto), TALER_TESTING_make_trait_payto_uri ( (const char **) &ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url ( -- cgit v1.2.3