diff options
| author | Christian Grothoff <christian@grothoff.org> | 2023-01-29 21:52:07 +0100 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2023-01-29 21:52:07 +0100 | 
| commit | a1c0c2fafde7f516223eabac8002f443dbef86ea (patch) | |
| tree | 387a9f077d5438ff86b9c35d77737d0c46d66101 /src/testing | |
| parent | e8c8aa9efe8f407268e6f6e35d996f35756bc055 (diff) | |
add test for KYC required on reserve close
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/test_exchange_api-cs.conf | 21 | ||||
| -rw-r--r-- | src/testing/test_exchange_p2p.c | 28 | ||||
| -rw-r--r-- | src/testing/test_kyc_api.c | 2 | ||||
| -rw-r--r-- | src/testing/testing_api_cmd_reserve_close.c | 64 | 
4 files changed, 105 insertions, 10 deletions
| diff --git a/src/testing/test_exchange_api-cs.conf b/src/testing/test_exchange_api-cs.conf index 9485a724..a746f7d2 100644 --- a/src/testing/test_exchange_api-cs.conf +++ b/src/testing/test_exchange_api-cs.conf @@ -27,6 +27,27 @@ BASE_URL = "http://localhost:8083/"  # HTTP port the auditor listens to  PORT = 8083 + +[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_OAUTH2_ATTRIBUTE_TEMPLATE = "{"full_name":"{{last_name}}, {{first_name}}"}" + +[kyc-legitimization-close] +OPERATION_TYPE = CLOSE +REQUIRED_CHECKS = DUMMY +THRESHOLD = EUR:0 +TIMEFRAME = 1d +  [exchange]  TERMS_ETAG = 0 diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c index 7c3bdd57..6eea4a0b 100644 --- a/src/testing/test_exchange_p2p.c +++ b/src/testing/test_exchange_p2p.c @@ -20,11 +20,9 @@   * @file testing/test_exchange_p2p.c   * @brief testcase to test exchange's P2P payments   * @author Christian Grothoff - * - * TODO: - * - enable reserve close test once implementation is complete!   */  #include "platform.h" +#include "taler_attributes.h"  #include "taler_util.h"  #include "taler_signatures.h"  #include "taler_exchange_service.h" @@ -454,10 +452,30 @@ run (void *cls,                                                MHD_HTTP_NOT_FOUND,                                                "nx-attribute-name",                                                NULL), -    /* FIXME: do KYC for reserve, then get actual attributes attested */ +    TALER_TESTING_cmd_oauth ("start-oauth-service", +                             6666), +    TALER_TESTING_cmd_reserve_close ("reserve-101-close-kyc", +                                     "create-reserve-101", +                                     /* 42b => not to origin */ +                                     "payto://x-taler-bank/localhost/42?receiver-name=42b", +                                     MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS), + +    TALER_TESTING_cmd_check_kyc_get ("check-kyc-close-pending", +                                     "reserve-101-close-kyc", +                                     MHD_HTTP_ACCEPTED), +    TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-close-kyc", +                                        "reserve-101-close-kyc", +                                        "kyc-provider-test-oauth2", +                                        "pass", +                                        MHD_HTTP_SEE_OTHER), +    TALER_TESTING_cmd_check_kyc_get ("check-kyc-close-ok", +                                     "reserve-101-close-kyc", +                                     MHD_HTTP_NO_CONTENT), +    /* Now it should pass */      TALER_TESTING_cmd_reserve_close ("reserve-101-close",                                       "create-reserve-101", -                                     NULL, /* to origin */ +                                     /* 42b => not to origin */ +                                     "payto://x-taler-bank/localhost/42?receiver-name=42b",                                       MHD_HTTP_OK),      TALER_TESTING_cmd_exec_closer ("close-reserves-101",                                     config_file, diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 8de5ee7b..44f302c6 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -227,7 +227,7 @@ run (void *cls,                                                MHD_HTTP_OK,                                                TALER_ATTRIBUTE_FULL_NAME,                                                NULL), -    TALER_TESTING_cmd_reserve_attest ("wallet-get-attestable", +    TALER_TESTING_cmd_reserve_attest ("wallet-get-attest",                                        "wallet-kyc-fail",                                        MHD_HTTP_OK,                                        TALER_ATTRIBUTE_FULL_NAME, diff --git a/src/testing/testing_api_cmd_reserve_close.c b/src/testing/testing_api_cmd_reserve_close.c index 4c243c74..63d51160 100644 --- a/src/testing/testing_api_cmd_reserve_close.c +++ b/src/testing/testing_api_cmd_reserve_close.c @@ -67,6 +67,18 @@ struct CloseState     * Interpreter state.     */    struct TALER_TESTING_Interpreter *is; + +  /** +   * 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 requirement_row;  }; @@ -98,10 +110,19 @@ reserve_close_cb (void *cls,      TALER_TESTING_interpreter_fail (ss->is);      return;    } -  if (MHD_HTTP_OK != rs->hr.http_status) +  switch (rs->hr.http_status)    { -    TALER_TESTING_interpreter_next (is); -    return; +  case MHD_HTTP_OK: +    break; +  case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: +    /* nothing to check */ +    ss->requirement_row +      = rs->details.unavailable_for_legal_reasons.requirement_row; +    ss->h_payto +      = rs->details.unavailable_for_legal_reasons.h_payto; +    break; +  default: +    break;    }    TALER_TESTING_interpreter_next (is);  } @@ -178,6 +199,40 @@ close_cleanup (void *cls,  } +/** + * Offer internal data to a "close" CMD state to other + * commands. + * + * @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 +close_traits (void *cls, +              const void **ret, +              const char *trait, +              unsigned int index) +{ +  struct CloseState *cs = cls; +  struct TALER_TESTING_Trait traits[] = { +    TALER_TESTING_make_trait_legi_requirement_row ( +      &cs->requirement_row), +    TALER_TESTING_make_trait_h_payto ( +      &cs->h_payto), +    TALER_TESTING_trait_end () +  }; + +  if (cs->expected_response_code != MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS) +    return GNUNET_NO; +  return TALER_TESTING_get_trait (traits, +                                  ret, +                                  trait, +                                  index); +} + +  struct TALER_TESTING_Command  TALER_TESTING_cmd_reserve_close (const char *label,                                   const char *reserve_reference, @@ -196,7 +251,8 @@ TALER_TESTING_cmd_reserve_close (const char *label,        .cls = ss,        .label = label,        .run = &close_run, -      .cleanup = &close_cleanup +      .cleanup = &close_cleanup, +      .traits = &close_traits      };      return cmd; | 
