diff options
Diffstat (limited to 'src/testing/testing_api_cmd_kyc_get.c')
-rw-r--r-- | src/testing/testing_api_cmd_kyc_get.c | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/src/testing/testing_api_cmd_kyc_get.c b/src/testing/testing_api_cmd_kyc_get.c index 96d0b58c..a8f29264 100644 --- a/src/testing/testing_api_cmd_kyc_get.c +++ b/src/testing/testing_api_cmd_kyc_get.c @@ -73,6 +73,11 @@ struct KycGetState unsigned int expected_http_status; /** + * Expected AML state. + */ + enum TALER_AmlDecisionState expected_aml_state; + + /** * Interpreter state. */ struct TALER_TESTING_Interpreter *is; @@ -126,7 +131,21 @@ kyc_get_cb (void *cls, switch (kr->hr.http_status) { case MHD_HTTP_ACCEPTED: - if (0 != kr->details.kyc_status.pending_kycs_length) + + if ( ( (TALER_AML_NORMAL != cs->expected_aml_state) && + (0 == kr->details.kyc_status.pending_kycs_length) ) || + ( (0 < kr->details.kyc_status.pending_kycs_length) && + (cs->expected_aml_state != + kr->details.kyc_status.pending_kycs[0].aml_status) ) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Expected AML state %u, got %u/%u\n", + cs->expected_aml_state, + kr->details.kyc_status.pending_kycs[0].aml_status, + kr->details.kyc_status.pending_kycs_length); + TALER_TESTING_FAIL (cs->is); + } + for (unsigned int i = 0; i<kr->details.kyc_status.pending_kycs_length; i++) { const char *url; const char *tok; @@ -136,7 +155,21 @@ kyc_get_cb (void *cls, const char *nq; size_t toklen; - url = kr->details.kyc_status.pending_kycs[0].kyc_url; + url = kr->details.kyc_status.pending_kycs[i].kyc_url; + if (NULL == url) + { + /* AML status here must be either pending or frozne */ + switch (kr->details.kyc_status.pending_kycs[i].aml_status) + { + case TALER_AML_NORMAL: + TALER_TESTING_FAIL (cs->is); + case TALER_AML_PENDING: + continue; + case TALER_AML_FROZEN: + continue; + } + TALER_TESTING_FAIL (cs->is); + } tok = strstr (url, "&redirect_uri="); if (NULL == tok) TALER_TESTING_FAIL (cs->is); @@ -159,18 +192,18 @@ kyc_get_cb (void *cls, GNUNET_free (dec); TALER_TESTING_FAIL (cs->is); } - eq += strlen ("/kyc-proof/"); - eq = strstr (eq, "state="); + GNUNET_free (dec); + + eq = strstr (url, "&state="); if (NULL == eq) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received unexpected 'state'-less KYC URL `%s' (%s)\n", url, dec); - GNUNET_free (dec); TALER_TESTING_FAIL (cs->is); } - eq += strlen ("state="); + eq += strlen ("&state="); nq = strchr (eq, '&'); if (NULL == nq) nq = eq + strlen (eq); @@ -183,11 +216,9 @@ kyc_get_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received unexpected KYC URL `%s' (%s) - no h_payto in state\n", url, - dec); - GNUNET_free (dec); + eq); TALER_TESTING_FAIL (cs->is); } - GNUNET_free (dec); } break; } @@ -234,7 +265,8 @@ kyc_get_run (void *cls, } } if (NULL == cs->instance_id) - cs->kgh = TALER_MERCHANT_kyc_get (is->ctx, + cs->kgh = TALER_MERCHANT_kyc_get (TALER_TESTING_interpreter_get_context ( + is), cs->merchant_url, h_wire, cs->exchange_url, @@ -242,14 +274,15 @@ kyc_get_run (void *cls, &kyc_get_cb, cs); else - cs->kgh = TALER_MERCHANT_management_kyc_get (is->ctx, - cs->merchant_url, - cs->instance_id, - h_wire, - cs->exchange_url, - GNUNET_TIME_UNIT_ZERO, - &kyc_get_cb, - cs); + cs->kgh = TALER_MERCHANT_management_kyc_get ( + TALER_TESTING_interpreter_get_context (is), + cs->merchant_url, + cs->instance_id, + h_wire, + cs->exchange_url, + GNUNET_TIME_UNIT_ZERO, + &kyc_get_cb, + cs); GNUNET_assert (NULL != cs->kgh); } @@ -285,12 +318,14 @@ kyc_get_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_kyc_get (const char *label, - const char *merchant_url, - const char *instance_id, - const char *h_wire_ref, - const char *exchange_url, - unsigned int expected_http_status) +TALER_TESTING_cmd_merchant_kyc_get ( + const char *label, + const char *merchant_url, + const char *instance_id, + const char *h_wire_ref, + const char *exchange_url, + unsigned int expected_http_status, + enum TALER_AmlDecisionState expected_aml_state) { struct KycGetState *cs; @@ -300,6 +335,7 @@ TALER_TESTING_cmd_merchant_kyc_get (const char *label, cs->h_wire_ref = h_wire_ref; cs->exchange_url = exchange_url; cs->expected_http_status = expected_http_status; + cs->expected_aml_state = expected_aml_state; { struct TALER_TESTING_Command cmd = { .cls = cs, |