diff options
Diffstat (limited to 'src/testing/testing_api_cmd_kyc_proof.c')
-rw-r--r-- | src/testing/testing_api_cmd_kyc_proof.c | 93 |
1 files changed, 43 insertions, 50 deletions
diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index f9a65afb3..b079fffce 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -44,9 +44,9 @@ struct KycProofGetState const char *code; /** - * State to pass. + * Logic section name to pass to `/kyc-proof/` handler. */ - const char *state; + const char *logic; /** * Expected HTTP response code. @@ -83,18 +83,13 @@ proof_kyc_cb (void *cls, { struct KycProofGetState *kcg = cls; struct TALER_TESTING_Interpreter *is = kcg->is; - struct TALER_TESTING_Command *cmd = &is->commands[is->ip]; kcg->kph = NULL; if (kcg->expected_response_code != kpr->http_status) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - kpr->http_status, - cmd->label, - __FILE__, - __LINE__); - TALER_TESTING_interpreter_fail (is); + TALER_TESTING_unexpected_status (is, + kpr->http_status, + kcg->expected_response_code); return; } switch (kpr->http_status) @@ -131,11 +126,18 @@ 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; + const char *exchange_url; (void) cmd; kps->is = is; + exchange_url = TALER_TESTING_get_exchange_url (is); + if (NULL == exchange_url) + { + GNUNET_break (0); + return; + } res_cmd = TALER_TESTING_interpreter_lookup_command ( kps->is, kps->payment_target_reference); @@ -146,35 +148,28 @@ 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; + GNUNET_break (0); + TALER_TESTING_interpreter_fail (kps->is); + return; } + if (NULL == kps->code) + uargs = NULL; else - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Triggering KYC proof for %s\n", - *payto_uri); - TALER_payto_hash (*payto_uri, - &h_payto); - } - kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange, - &h_payto, - kps->code, - kps->state, - &proof_kyc_cb, - kps); + GNUNET_asprintf (&uargs, + "&code=%s", + kps->code); + kps->kph = TALER_EXCHANGE_kyc_proof ( + TALER_TESTING_interpreter_get_context (is), + exchange_url, + h_payto, + kps->logic, + uargs, + &proof_kyc_cb, + kps); + GNUNET_free (uargs); GNUNET_assert (NULL != kps->kph); } @@ -194,10 +189,8 @@ proof_kyc_cleanup (void *cls, if (NULL != kps->kph) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %u (%s) did not complete\n", - kps->is->ip, - cmd->label); + TALER_TESTING_command_incomplete (kps->is, + cmd->label); TALER_EXCHANGE_kyc_proof_cancel (kps->kph); kps->kph = NULL; } @@ -223,8 +216,7 @@ proof_kyc_traits (void *cls, { struct KycProofGetState *kps = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_web_url ( - (const char **) &kps->redirect_url), + TALER_TESTING_make_trait_web_url (kps->redirect_url), TALER_TESTING_trait_end () }; @@ -236,17 +228,18 @@ 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, + 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; { |