diff options
Diffstat (limited to 'src/testing/testing_api_cmd_take_aml_decision.c')
-rw-r--r-- | src/testing/testing_api_cmd_take_aml_decision.c | 92 |
1 files changed, 65 insertions, 27 deletions
diff --git a/src/testing/testing_api_cmd_take_aml_decision.c b/src/testing/testing_api_cmd_take_aml_decision.c index 0992945d6..c0e23de22 100644 --- a/src/testing/testing_api_cmd_take_aml_decision.c +++ b/src/testing/testing_api_cmd_take_aml_decision.c @@ -73,6 +73,11 @@ struct AmlDecisionState const char *justification; /** + * KYC requirement to add. + */ + const char *kyc_requirement; + + /** * Threshold transaction amount. */ struct TALER_Amount new_threshold; @@ -85,31 +90,26 @@ struct AmlDecisionState /** - * Callback to analyze the /management/XXX response, just used to check + * Callback to analyze the /aml-decision/$OFFICER_PUB response, just used to check * if the response code is acceptable. * * @param cls closure. - * @param hr HTTP response details + * @param adr response details */ static void -take_aml_decision_cb (void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr) +take_aml_decision_cb ( + void *cls, + const struct TALER_EXCHANGE_AddAmlDecisionResponse *adr) { struct AmlDecisionState *ds = cls; + const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr; ds->dh = NULL; if (ds->expected_response != hr->http_status) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Unexpected response code %u to command %s in %s:%u\n", - hr->http_status, - ds->is->commands[ds->is->ip].label, - __FILE__, - __LINE__); - json_dumpf (hr->reply, - stderr, - 0); - TALER_TESTING_interpreter_fail (ds->is); + TALER_TESTING_unexpected_status (ds->is, + hr->http_status, + ds->expected_response); return; } TALER_TESTING_interpreter_next (ds->is); @@ -133,8 +133,25 @@ take_aml_decision_run (void *cls, const struct TALER_PaytoHashP *h_payto; const struct TALER_AmlOfficerPrivateKeyP *officer_priv; const struct TALER_TESTING_Command *ref; + json_t *kyc_requirements = NULL; + const char *exchange_url; (void) cmd; + { + const struct TALER_TESTING_Command *exchange_cmd; + + exchange_cmd = TALER_TESTING_interpreter_get_command (is, + "exchange"); + if (NULL == exchange_cmd) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_exchange_url (exchange_cmd, + &exchange_url)); + } now = GNUNET_TIME_timestamp_get (); ds->is = is; ref = TALER_TESTING_interpreter_lookup_command (is, @@ -145,9 +162,14 @@ take_aml_decision_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_h_payto (ref, - &h_payto)); + if (GNUNET_OK != + TALER_TESTING_get_trait_h_payto (ref, + &h_payto)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } ref = TALER_TESTING_interpreter_lookup_command (is, ds->officer_ref_cmd); if (NULL == ref) @@ -156,21 +178,37 @@ take_aml_decision_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_officer_priv (ref, - &officer_priv)); + if (GNUNET_OK != + TALER_TESTING_get_trait_officer_priv (ref, + &officer_priv)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } ds->h_payto = *h_payto; + if (NULL != ds->kyc_requirement) + { + kyc_requirements = json_array (); + GNUNET_assert (NULL != kyc_requirements); + GNUNET_assert (0 == + json_array_append (kyc_requirements, + json_string (ds->kyc_requirement))); + } + ds->dh = TALER_EXCHANGE_add_aml_decision ( - is->ctx, - is->exchange_url, + TALER_TESTING_interpreter_get_context (is), + exchange_url, ds->justification, now, &ds->new_threshold, h_payto, ds->new_state, + kyc_requirements, officer_priv, &take_aml_decision_cb, ds); + json_decref (kyc_requirements); if (NULL == ds->dh) { GNUNET_break (0); @@ -195,10 +233,8 @@ take_aml_decision_cleanup (void *cls, if (NULL != ds->dh) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %u (%s) did not complete\n", - ds->is->ip, - cmd->label); + TALER_TESTING_command_incomplete (ds->is, + cmd->label); TALER_EXCHANGE_add_aml_decision_cancel (ds->dh); ds->dh = NULL; } @@ -225,7 +261,7 @@ take_aml_decision_traits (void *cls, struct AmlDecisionState *ws = cls; struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_h_payto (&ws->h_payto), - TALER_TESTING_make_trait_aml_justification (&ws->justification), + TALER_TESTING_make_trait_aml_justification (ws->justification), TALER_TESTING_make_trait_aml_decision (&ws->new_state), TALER_TESTING_make_trait_amount (&ws->new_threshold), TALER_TESTING_trait_end () @@ -246,6 +282,7 @@ TALER_TESTING_cmd_take_aml_decision ( const char *new_threshold, const char *justification, enum TALER_AmlDecisionState new_state, + const char *kyc_requirement, unsigned int expected_response) { struct AmlDecisionState *ds; @@ -253,6 +290,7 @@ TALER_TESTING_cmd_take_aml_decision ( ds = GNUNET_new (struct AmlDecisionState); ds->officer_ref_cmd = ref_officer; ds->account_ref_cmd = ref_operation; + ds->kyc_requirement = kyc_requirement; if (GNUNET_OK != TALER_string_to_amount (new_threshold, &ds->new_threshold)) |