merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit feaf7bae8baf8ec701d02374e18a6b978dcfb9f8
parent ad925ccc324ca2b84676a39d63b776ba337da492
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 11 Apr 2023 11:00:09 +0200

implement test for #7684

Diffstat:
Msrc/include/taler_merchant_testing_lib.h | 15+++++++++------
Msrc/testing/test_kyc_api.c | 23+++++++++++++++++++----
Msrc/testing/testing_api_cmd_kyc_get.c | 34++++++++++++++++++++++++++++------
3 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -1477,15 +1477,18 @@ TALER_TESTING_cmd_tip_pickup (const char *label, * of the bank account to check KYC for; NULL to check all accounts * @param exchange_url base URL of the exchange to check KYC status for * @param expected_http_status expected HTTP status + * @param expected_aml_state expected AML state (only effecitve if @e expected_http_status is #MHD_HTTP_OK) * @return the command */ 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); /* ****** Templates ******* */ diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c @@ -221,7 +221,8 @@ run (void *cls, NULL, NULL, EXCHANGE_URL, - MHD_HTTP_NO_CONTENT), + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), /* now we get the legi UUID */ TALER_TESTING_cmd_merchant_get_order ("get-order-kyc", merchant_url, @@ -236,7 +237,8 @@ run (void *cls, NULL, NULL, EXCHANGE_URL, - MHD_HTTP_ACCEPTED), + MHD_HTTP_ACCEPTED, + TALER_AML_NORMAL), TALER_TESTING_cmd_proof_kyc_oauth2 ("kyc-do", "kyc-pending", "kyc-provider-test-oauth2", @@ -327,8 +329,14 @@ run (void *cls, CMD_EXEC_AGGREGATOR ("run-aggregator-aml-frozen"), /* AML-frozen: hence nothing happened at the bank yet: */ TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-aml-2"), - - /* FIXME-7684: add logic to get AML state from merchant here */ + /* Now we should get a status of frozen */ + TALER_TESTING_cmd_merchant_kyc_get ("aml-frozen", + merchant_url, + NULL, /* no instance ID */ + NULL, /* no wire ref */ + EXCHANGE_URL, + MHD_HTTP_ACCEPTED, + TALER_AML_FROZEN), TALER_TESTING_cmd_sleep ("sleep to de-collide AML timestamps", 1), TALER_TESTING_cmd_take_aml_decision ("unfreeze", @@ -339,6 +347,13 @@ run (void *cls, TALER_AML_NORMAL, NULL, MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_kyc_get ("aml-unfrozen", + merchant_url, + NULL, /* no instance ID */ + NULL, /* no wire ref */ + EXCHANGE_URL, + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), CMD_EXEC_AGGREGATOR ("run-aggregator-aml-normal"), TALER_TESTING_cmd_check_bank_transfer ( "check_bank_transfer-498c-post-unfreeze", diff --git 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,6 +131,20 @@ kyc_get_cb (void *cls, switch (kr->hr.http_status) { case MHD_HTTP_ACCEPTED: + + 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; @@ -299,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; @@ -314,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,