From d5619de525930cf76e5ff6bce3418e5b478dbe9f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 Jan 2023 11:25:18 +0100 Subject: [PATCH] fix test_kyc_api: adapt test logic to improved OAuth2.0 kyc API: --- src/include/taler_exchange_service.h | 3 +-- src/include/taler_testing_lib.h | 2 -- src/lib/exchange_api_kyc_proof.c | 7 +++---- src/testing/test_kyc_api.c | 7 ------- src/testing/testing_api_cmd_kyc_proof.c | 17 ++++++----------- 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 938b74457..b2d0bf710 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -3600,8 +3600,7 @@ struct TALER_EXCHANGE_KycProofHandle; * @param h_payto hash of payto URI identifying the target account * @param logic name of the KYC logic to run * @param args additional args to pass, can be NULL - * or a string to append to the URL. Must - * then begin with '/' or '?'. + * or a string to append to the URL. Must then begin with '&'. * @param cb function to call with the result * @param cb_cls closure for @a cb * @return NULL on error diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 0418ab17e..846be4183 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -2535,7 +2535,6 @@ TALER_TESTING_cmd_check_kyc_get (const char *label, * @param logic_section name of the KYC provider section * in the exchange configuration for this proof * @param code OAuth 2.0 code to use - * @param state OAuth 2.0 state to use * @param expected_response_code expected HTTP status * @return the command */ @@ -2545,7 +2544,6 @@ TALER_TESTING_cmd_proof_kyc_oauth2 ( const char *payment_target_reference, const char *logic_section, const char *code, - const char *state, unsigned int expected_response_code); diff --git a/src/lib/exchange_api_kyc_proof.c b/src/lib/exchange_api_kyc_proof.c index 0436e1c52..1298df4fd 100644 --- a/src/lib/exchange_api_kyc_proof.c +++ b/src/lib/exchange_api_kyc_proof.c @@ -154,8 +154,7 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange, if (NULL == args) args = ""; else - GNUNET_assert ( (args[0] == '?') || - (args[0] == '/') ); + GNUNET_assert (args[0] == '&'); if (GNUNET_YES != TEAH_handle_is_ready (exchange)) { @@ -172,9 +171,9 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange, sizeof (hstr)); *end = '\0'; GNUNET_asprintf (&arg_str, - "/kyc-proof/%s/%s%s", - hstr, + "/kyc-proof/%s?state=%s%s", logic, + hstr, args); } kph = GNUNET_new (struct TALER_EXCHANGE_KycProofHandle); diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 8ab4cffc8..dc302f3a4 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -131,7 +131,6 @@ run (void *cls, "withdraw-coin-1-lacking-kyc", "kyc-provider-test-oauth2", "pass", - "state", MHD_HTTP_SEE_OTHER), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-with-kyc", "create-reserve-1", @@ -175,7 +174,6 @@ run (void *cls, "track-deposit-kyc-ready", "kyc-provider-test-oauth2", "bad", - "state", MHD_HTTP_BAD_GATEWAY), TALER_TESTING_cmd_oauth ("start-oauth-service", 6666), @@ -183,13 +181,11 @@ run (void *cls, "track-deposit-kyc-ready", "kyc-provider-test-oauth2", "bad", - "state", MHD_HTTP_FORBIDDEN), TALER_TESTING_cmd_proof_kyc_oauth2 ("proof-kyc-fail", "track-deposit-kyc-ready", "kyc-provider-test-oauth2", "pass", - "state", MHD_HTTP_SEE_OTHER), CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"), TALER_TESTING_cmd_check_bank_transfer ( @@ -216,7 +212,6 @@ run (void *cls, "wallet-kyc-fail", "kyc-provider-test-oauth2", "pass", - "state", MHD_HTTP_SEE_OTHER), TALER_TESTING_cmd_check_kyc_get ("wallet-kyc-check", "wallet-kyc-fail", @@ -311,7 +306,6 @@ run (void *cls, "purse-merge-into-reserve", "kyc-provider-test-oauth2", "pass", - "state", MHD_HTTP_SEE_OTHER), TALER_TESTING_cmd_purse_merge ( "purse-merge-into-reserve", @@ -353,7 +347,6 @@ run (void *cls, "purse-create-with-reserve", "kyc-provider-test-oauth2", "pass", - "state", MHD_HTTP_SEE_OTHER), TALER_TESTING_cmd_purse_create_with_reserve ( "purse-create-with-reserve", diff --git a/src/testing/testing_api_cmd_kyc_proof.c b/src/testing/testing_api_cmd_kyc_proof.c index ed0df5564..ff76e415c 100644 --- a/src/testing/testing_api_cmd_kyc_proof.c +++ b/src/testing/testing_api_cmd_kyc_proof.c @@ -43,11 +43,6 @@ struct KycProofGetState */ const char *code; - /** - * State to pass. - */ - const char *state; - /** * Logic section name to pass to `/kyc-proof/` handler. */ @@ -158,10 +153,12 @@ proof_kyc_run (void *cls, TALER_TESTING_interpreter_fail (kps->is); return; } - GNUNET_asprintf (&uargs, - "?code=%s&state=%s", - kps->code, - kps->state); + if (NULL == kps->code) + uargs = NULL; + else + GNUNET_asprintf (&uargs, + "&code=%s", + kps->code); kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange, h_payto, kps->logic, @@ -235,14 +232,12 @@ TALER_TESTING_cmd_proof_kyc_oauth2 ( const char *payment_target_reference, const char *logic_section, const char *code, - const char *state, 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;