diff options
34 files changed, 668 insertions, 445 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 99548ef8..c6b99bfc 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -130,7 +130,7 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_spa.c \ taler-merchant-httpd_spa.h \ taler-merchant-httpd_statics.c \ - taler-merchant-httpd_statics.h + taler-merchant-httpd_statics.h taler_merchant_httpd_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ @@ -138,6 +138,7 @@ taler_merchant_httpd_LDADD = \ -ltalertemplating \ -ltalermhd \ -ltalerbank \ + -ltalerkyclogic \ -ltalerjson \ -ltalerutil \ -ltalerpq \ diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c index e25da307..e7ab0468 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c @@ -698,8 +698,7 @@ kyc_with_exchange (void *cls, eh, ekr->exchange_kyc_serial, &h_payto, - /* FIXME-#7796: get from settings! */ - TALER_KYCLOGIC_KYC_UT_BUSINESS, + ekr->kc->mi->settings.ut, kc->timeout, &exchange_check_cb, ekr); diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID.c b/src/backend/taler-merchant-httpd_private-get-instances-ID.c index 5cc7764f..c51d3de0 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-instances-ID.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2019-2021 Taler Systems SA + (C) 2019-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -73,6 +73,9 @@ get_instances_ID (struct TMH_MerchantInstance *mi, ja), GNUNET_JSON_pack_string ("name", mi->settings.name), + GNUNET_JSON_pack_string ( + "user_type", + TALER_KYCLOGIC_kyc_user_type2s (mi->settings.ut)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("website", mi->settings.website)), diff --git a/src/backend/taler-merchant-httpd_private-get-instances.c b/src/backend/taler-merchant-httpd_private-get-instances.c index dc0f566f..50b5c0c2 100644 --- a/src/backend/taler-merchant-httpd_private-get-instances.c +++ b/src/backend/taler-merchant-httpd_private-get-instances.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2019-2021 Taler Systems SA + (C) 2019-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -74,6 +74,9 @@ add_instance (void *cls, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("name", mi->settings.name), + GNUNET_JSON_pack_string ( + "user_type", + TALER_KYCLOGIC_kyc_user_type2s (mi->settings.ut)), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("website", mi->settings.website)), diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index 5bd53a57..77a75da4 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -64,7 +64,7 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, struct TALER_MERCHANTDB_InstanceSettings is; json_t *payto_uris; const char *name; - // FIXME-#7796: uint32_t ut; + const char *uts = "business"; struct TMH_WireMethod *wm_head = NULL; struct TMH_WireMethod *wm_tail = NULL; struct GNUNET_JSON_Specification spec[] = { @@ -72,7 +72,10 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, &payto_uris), GNUNET_JSON_spec_string ("name", &name), - // FIXME-#7796: GNUNET_JSON_spec_uint32 ("user_type", &ut), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("user_type", + &uts), + NULL), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("website", (const char **) &is.website), @@ -121,7 +124,19 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, ? MHD_YES : MHD_NO; } - // FIXME-#7796: is.user_type = (enum TALER_KYCLOGIC_KycUserType) ut; + if (NULL == uts) + uts = "business"; + if (GNUNET_OK != + TALER_KYCLOGIC_kyc_user_type_from_string (uts, + &is.ut)) + { + GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "user_type"); + } if (! TMH_location_object_valid (is.address)) { GNUNET_break_op (0); @@ -187,7 +202,7 @@ patch_instances_ID (struct TMH_MerchantInstance *mi, /* Check for equality of settings */ if (! ( (0 == strcmp (mi->settings.name, name)) && - // FIXME-#7796: (mi->settings.user_type == is.user_type) && + (mi->settings.ut == is.ut) && ((mi->settings.email == is.email) || (NULL != is.email && NULL != mi->settings.email && 0 == strcmp (mi->settings.email, diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 89bd937e..4d9320ba 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2020, 2021 Taler Systems SA + (C) 2020-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -149,6 +149,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, struct TALER_MERCHANTDB_InstanceAuthSettings ias; json_t *payto_uris; const char *auth_token = NULL; + const char *uts = "business"; struct TMH_WireMethod *wm_head = NULL; struct TMH_WireMethod *wm_tail = NULL; json_t *jauth; @@ -160,6 +161,10 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_string ("name", (const char **) &is.name), GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("user_type", + &uts), + NULL), + GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_string ("email", (const char **) &is.email), NULL), @@ -204,6 +209,20 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, : MHD_NO; } + if (NULL == uts) + uts = "business"; + if (GNUNET_OK != + TALER_KYCLOGIC_kyc_user_type_from_string (uts, + &is.ut)) + { + GNUNET_break_op (0); + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "user_type"); + } + { enum GNUNET_GenericReturnValue ret; diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am index a21c209b..008af262 100644 --- a/src/backenddb/Makefile.am +++ b/src/backenddb/Makefile.am @@ -16,11 +16,9 @@ sql_DATA = \ merchant-0002.sql \ merchant-0003.sql \ merchant-0004.sql \ + merchant-0005.sql \ drop.sql -# merchant-0005.sql \ -- FIXME-#7796 - - if HAVE_POSTGRESQL if HAVE_GNUNETPQ plugin_LTLIBRARIES = \ diff --git a/src/backenddb/drop.sql b/src/backenddb/drop.sql index fbfd9e6a..c4185d8b 100644 --- a/src/backenddb/drop.sql +++ b/src/backenddb/drop.sql @@ -23,7 +23,7 @@ BEGIN; -- Unlike the other SQL files, it SHOULD be updated to reflect the -- latest requirements for dropping tables. --- Unregister patch (0003.sql) +SELECT _v.unregister_patch('merchant-0005'); SELECT _v.unregister_patch('merchant-0004'); SELECT _v.unregister_patch('merchant-0003'); SELECT _v.unregister_patch('merchant-0002'); diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index b49bc54a..5553c059 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -482,6 +482,7 @@ lookup_instances_cb (void *cls, { bool no_auth; bool no_salt; + uint32_t ut32; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("merchant_serial", &lic->instance_serial), @@ -499,6 +500,8 @@ lookup_instances_cb (void *cls, &lic->is.id), GNUNET_PQ_result_spec_string ("merchant_name", &lic->is.name), + GNUNET_PQ_result_spec_uint32 ("user_type", + &ut32), TALER_PQ_result_spec_json ("address", &lic->is.address), TALER_PQ_result_spec_json ("jurisdiction", @@ -547,6 +550,7 @@ lookup_instances_cb (void *cls, lic->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } + lic->is.ut = (enum TALER_KYCLOGIC_KycUserType) ut32; lic->qs = GNUNET_PQ_eval_prepared_multi_select (lic->pg->conn, "lookup_accounts", params, @@ -699,12 +703,14 @@ postgres_insert_instance ( const struct TALER_MERCHANTDB_InstanceAuthSettings *ias) { struct PostgresClosure *pg = cls; + uint32_t ut32 = (uint32_t) is->ut; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (merchant_pub), GNUNET_PQ_query_param_auto_from_type (&ias->auth_hash), GNUNET_PQ_query_param_auto_from_type (&ias->auth_salt), GNUNET_PQ_query_param_string (is->id), GNUNET_PQ_query_param_string (is->name), + GNUNET_PQ_query_param_uint32 (&ut32), TALER_PQ_query_param_json (is->address), TALER_PQ_query_param_json (is->jurisdiction), TALER_PQ_query_param_amount (&is->default_max_deposit_fee), @@ -1057,6 +1063,7 @@ postgres_update_instance (void *cls, const struct TALER_MERCHANTDB_InstanceSettings *is) { struct PostgresClosure *pg = cls; + uint32_t ut32 = (uint32_t) is->ut; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (is->id), GNUNET_PQ_query_param_string (is->name), @@ -1077,6 +1084,7 @@ postgres_update_instance (void *cls, (NULL == is->logo) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (is->logo), + GNUNET_PQ_query_param_uint32 (&ut32), GNUNET_PQ_query_param_end }; @@ -7627,6 +7635,7 @@ postgres_connect (void *cls) ",auth_salt" ",merchant_id" ",merchant_name" + ",user_type" ",address" ",jurisdiction" ",default_max_deposit_fee_val" @@ -7649,6 +7658,7 @@ postgres_connect (void *cls) ",auth_salt" ",merchant_id" ",merchant_name" + ",user_type" ",address" ",jurisdiction" ",default_max_deposit_fee_val" @@ -7671,6 +7681,7 @@ postgres_connect (void *cls) ",auth_salt" ",merchant_id" ",merchant_name" + ",user_type" ",address" ",jurisdiction" ",default_max_deposit_fee_val" @@ -7684,7 +7695,7 @@ postgres_connect (void *cls) ",email" ",logo)" "VALUES" - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)"), + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)"), /* for postgres_insert_instance() */ GNUNET_PQ_make_prepare ("insert_keys", "INSERT INTO merchant_keys" @@ -7771,7 +7782,8 @@ postgres_connect (void *cls) ",website=$12" ",email=$13" ",logo=$14" - " WHERE merchant_id = $1"), + ",user_type=$15" + " WHERE merchant_id=$1"), /* for postgres_update_instance_auth() */ GNUNET_PQ_make_prepare ("update_instance_auth", "UPDATE merchant_instances SET" diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 3d55e4b0..863f1676 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -303,6 +303,7 @@ struct TALER_MERCHANT_ConfigInformation }; +// FIXME: change signature! /** * Function called with information about the merchant. * @@ -384,6 +385,11 @@ struct TALER_MERCHANT_InstanceInformation */ json_t *payment_targets; + /** + * User type for the instance. + */ + enum TALER_KYCLOGIC_KycUserType ut; + }; @@ -394,19 +400,47 @@ struct TALER_MERCHANT_InstancesGetHandle; /** + * Response to a GET /instances request. + */ +struct TALER_MERCHANT_InstancesGetResponse +{ + /** + * HTTP response data + */ + struct TALER_MERCHANT_HttpResponse hr; + + union + { + /** + * Data returned on #MHD_HTTP_OK status. + */ + struct + { + /** + * length of the @e iis array + */ + unsigned int iis_length; + + /** + * array with instance information of length @e iis_length + */ + const struct TALER_MERCHANT_InstanceInformation *iis; + } success; + } details; + +}; + + +/** * Function called with the result of the GET /instances operation. * * @param cls closure - * @param hr HTTP response data - * @param iis_length length of the @a iis array - * @param iis array with instance information of length @a iis_length + * @param igr response data */ typedef void (*TALER_MERCHANT_InstancesGetCallback)( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int iis_length, - const struct TALER_MERCHANT_InstanceInformation iis[]); + const struct TALER_MERCHANT_InstancesGetResponse *igr); /** @@ -466,6 +500,7 @@ typedef void * @param accounts_length how many bank accounts this instance has * @param payto_uris URIs of the bank accounts of the merchant instance * @param name name of the merchant instance + * @param ut user type of the merchant instance * @param address physical address of the merchant instance * @param jurisdiction jurisdiction of the merchant instance * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay @@ -487,6 +522,7 @@ TALER_MERCHANT_instances_post ( unsigned int accounts_length, const char *payto_uris[], const char *name, + enum TALER_KYCLOGIC_KycUserType ut, const json_t *address, const json_t *jurisdiction, const struct TALER_Amount *default_max_wire_fee, @@ -539,6 +575,7 @@ typedef void * @param accounts_length length of the @a accounts array * @param payto_uris URIs of the bank accounts of the merchant instance * @param name name of the merchant instance + * @param ut user type of the merchant instance * @param address physical address of the merchant instance * @param jurisdiction jurisdiction of the merchant instance * @param default_max_wire_fee default maximum wire fee merchant is willing to fully pay @@ -559,6 +596,7 @@ TALER_MERCHANT_instance_patch ( unsigned int accounts_length, const char *payto_uris[], const char *name, + enum TALER_KYCLOGIC_KycUserType ut, const json_t *address, const json_t *jurisdiction, const struct TALER_Amount *default_max_wire_fee, @@ -682,7 +720,7 @@ struct TALER_MERCHANT_InstanceDetails /** * public key of the merchant instance */ - const struct TALER_MerchantPublicKeyP *merchant_pub; + struct TALER_MerchantPublicKeyP merchant_pub; /** * physical address of the merchant instance @@ -697,17 +735,12 @@ struct TALER_MERCHANT_InstanceDetails /** * default maximum wire fee merchant is willing to fully pay */ - const struct TALER_Amount *default_max_wire_fee; - - /** - * default amortization factor for excess wire fees - */ - uint32_t default_wire_fee_amortization; + struct TALER_Amount default_max_wire_fee; /** * default maximum deposit fee merchant is willing to pay */ - const struct TALER_Amount *default_max_deposit_fee; + struct TALER_Amount default_max_deposit_fee; /** * default wire transfer delay merchant will ask for @@ -718,6 +751,52 @@ struct TALER_MERCHANT_InstanceDetails * default validity period for offers merchant makes */ struct GNUNET_TIME_Relative default_pay_delay; + + /** + * Default amortization factor for excess wire fees + */ + uint32_t default_wire_fee_amortization; + + /** + * User type for the instance. + */ + enum TALER_KYCLOGIC_KycUserType ut; +}; + + +struct TALER_MERCHANT_InstanceGetResponse +{ + /** + * HTTP response data + */ + struct TALER_MERCHANT_HttpResponse hr; + + union + { + + /** + * Data returned on #MHD_HTTP_OK. + */ + struct + { + /** + * Length of the @e accounts array. + */ + unsigned int accounts_length; + + /** + * bank accounts of the merchant instance + */ + const struct TALER_MERCHANT_Account *accounts; + + /** + * Details about the instance. + */ + struct TALER_MERCHANT_InstanceDetails details; + + } success; + } + details; }; @@ -725,18 +804,12 @@ struct TALER_MERCHANT_InstanceDetails * Function called with the result of the GET /instances/$ID operation. * * @param cls closure - * @param hr HTTP response data - * @param accounts_length length of the @a accounts array - * @param accounts bank accounts of the merchant instance - * @param details details about the instance configuration + * @param igr response details */ typedef void (*TALER_MERCHANT_InstanceGetCallback)( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int accounts_length, - const struct TALER_MERCHANT_Account accounts[], - const struct TALER_MERCHANT_InstanceDetails *details); + const struct TALER_MERCHANT_InstanceGetResponse *igr); /** @@ -878,19 +951,45 @@ struct TALER_MERCHANT_InventoryEntry /** + * Response to a GET /products request. + */ +struct TALER_MERCHANT_GetProductsResponse +{ + /** + * HTTP response details + */ + struct TALER_MERCHANT_HttpResponse hr; + + union + { + struct + { + + /** + * length of the @a products array + */ + unsigned int products_length; + + /** + * array of products the requested instance offers + */ + const struct TALER_MERCHANT_InventoryEntry *products; + } success; + + } details; +}; + + +/** * Function called with the result of the GET /products operation. * * @param cls closure - * @param hr HTTP response details - * @param products_length length of the @a products array - * @param products array of products the requested instance offers + * @param gpr response details */ typedef void (*TALER_MERCHANT_ProductsGetCallback)( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int products_length, - const struct TALER_MERCHANT_InventoryEntry products[]); + const struct TALER_MERCHANT_GetProductsResponse *gpr); /** @@ -929,6 +1028,7 @@ TALER_MERCHANT_products_get_cancel ( struct TALER_MERCHANT_ProductGetHandle; +// FIXME: change signature! /** * Function called with the result of the GET /products operation. * @@ -1481,6 +1581,7 @@ struct TALER_MERCHANT_OrderEntry }; +// FIXME: change signature! /** * Function called with the result of the GET /orders operation. * @@ -2088,6 +2189,7 @@ TALER_MERCHANT_order_delete_cancel ( struct TALER_MERCHANT_OrderClaimHandle; +// FIXME: change signature! /** * Callback called to process a POST /orders/$ID/claim response. * @@ -2474,6 +2576,7 @@ struct TALER_MERCHANT_AbortedCoin }; +// FIXME: change signature! /** * Callbacks of this type are used to serve the result of submitting a * /orders/$ID/abort request to a merchant. @@ -2617,6 +2720,7 @@ TALER_MERCHANT_order_forget_cancel (struct struct TALER_MERCHANT_OrderRefundHandle; +// FIXME: change signature! /** * Callback to process a POST /orders/ID/refund request * @@ -2712,6 +2816,7 @@ struct TALER_MERCHANT_RefundDetail }; +// FIXME: change signature! /** * Callback to process a (public) POST /orders/ID/refund request * @@ -2969,6 +3074,8 @@ struct TALER_MERCHANT_TransferData }; + +// FIXME: change signature! /** * Callbacks of this type are used to work the result of submitting a * GET /transfers request to a merchant @@ -3047,6 +3154,7 @@ TALER_MERCHANT_transfers_get_cancel ( struct TALER_MERCHANT_PostReservesHandle; +// FIXME: change signature! /** * Callbacks of this type are used to work the result of submitting a * POST /reserves request to a merchant @@ -3152,6 +3260,7 @@ struct TALER_MERCHANT_ReserveSummary }; +// FIXME: change signature! /** * Callback to process a GET /reserves request * @@ -3232,6 +3341,7 @@ struct TALER_MERCHANT_TipDetails }; +// FIXME: change signature! /** * Callback to process a GET /reserve/$RESERVE_PUB request * @@ -3293,6 +3403,7 @@ TALER_MERCHANT_reserve_get_cancel ( struct TALER_MERCHANT_TipAuthorizeHandle; +// FIXME: change signature! /** * Callback for a /reserves/$RESERVE_PUB/tip-authorize request. Returns the result of * the operation. @@ -3703,6 +3814,7 @@ struct TALER_MERCHANT_TipEntry }; +// FIXME: change signature! /** * Callback to process a GET /private/tips request. * @@ -3880,6 +3992,7 @@ TALER_MERCHANT_tip_pickup_cancel (struct TALER_MERCHANT_TipPickupHandle *tph); struct TALER_MERCHANT_TipPickup2Handle; +// FIXME: change signature! /** * Callback for a POST /tips/$TIP_ID/pickup request. Returns the result of * the operation. Note that the client MUST still do the unblinding of the @a @@ -4136,6 +4249,7 @@ struct TALER_MERCHANT_TemplateEntry }; +// FIXME: change signature! /** * Function called with the result of the GET /templates operation. * @@ -4497,6 +4611,7 @@ struct TALER_MERCHANT_WebhookEntry }; +// FIXME: change signature! /** * Function called with the result of the GET /webhooks operation. * diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 68cdf3d7..07bfffd6 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -196,7 +196,6 @@ struct TALER_MERCHANTDB_InstanceSettings /** * Type of user this merchant represents. - * FIXME: not yet initialized! */ enum TALER_KYCLOGIC_KycUserType ut; }; diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 36e249ed..6f1a41fe 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -71,6 +71,7 @@ libtalermerchant_la_LIBADD = \ -ltalerexchange \ -ltalercurl \ -ltalerjson \ + -ltalerkyclogic \ -ltalerutil \ -lgnunetcurl \ -lgnunetjson \ diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c index bb71a1ed..c8fbfc00 100644 --- a/src/lib/merchant_api_get_instance.c +++ b/src/lib/merchant_api_get_instance.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018, 2020 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -28,6 +28,7 @@ #include "taler_merchant_service.h" #include "merchant_api_curl_defaults.h" #include <taler/taler_json_lib.h> +#include <taler/taler_kyclogic_lib.h> #include <taler/taler_signatures.h> @@ -79,9 +80,9 @@ handle_get_instance_finished (void *cls, { struct TALER_MERCHANT_InstanceGetHandle *igh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_InstanceGetResponse igr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; igh->job = NULL; @@ -93,36 +94,38 @@ handle_get_instance_finished (void *cls, case MHD_HTTP_OK: { json_t *accounts; - const char *name; - struct TALER_MerchantPublicKeyP merchant_pub; + const char *uts; json_t *address; json_t *jurisdiction; - struct TALER_Amount default_max_wire_fee; - uint32_t default_wire_fee_amortization; - struct TALER_Amount default_max_deposit_fee; - struct GNUNET_TIME_Relative default_wire_transfer_delay; - struct GNUNET_TIME_Relative default_pay_delay; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("accounts", &accounts), GNUNET_JSON_spec_string ("name", - &name), - GNUNET_JSON_spec_fixed_auto ("merchant_pub", - &merchant_pub), + &igr.details.success.details.name), + GNUNET_JSON_spec_string ("user_type", + &uts), + GNUNET_JSON_spec_fixed_auto ( + "merchant_pub", + &igr.details.success.details.merchant_pub), GNUNET_JSON_spec_json ("address", &address), GNUNET_JSON_spec_json ("jurisdiction", &jurisdiction), - TALER_JSON_spec_amount_any ("default_max_wire_fee", - &default_max_wire_fee), - GNUNET_JSON_spec_uint32 ("default_wire_fee_amortization", - &default_wire_fee_amortization), - TALER_JSON_spec_amount_any ("default_max_deposit_fee", - &default_max_deposit_fee), - GNUNET_JSON_spec_relative_time ("default_wire_transfer_delay", - &default_wire_transfer_delay), - GNUNET_JSON_spec_relative_time ("default_pay_delay", - &default_pay_delay), + TALER_JSON_spec_amount_any ( + "default_max_wire_fee", + &igr.details.success.details.default_max_wire_fee), + GNUNET_JSON_spec_uint32 ( + "default_wire_fee_amortization", + &igr.details.success.details.default_wire_fee_amortization), + TALER_JSON_spec_amount_any ( + "default_max_deposit_fee", + &igr.details.success.details.default_max_deposit_fee), + GNUNET_JSON_spec_relative_time ( + "default_wire_transfer_delay", + &igr.details.success.details.default_wire_transfer_delay), + GNUNET_JSON_spec_relative_time ( + "default_pay_delay", + &igr.details.success.details.default_pay_delay), GNUNET_JSON_spec_end () }; @@ -161,6 +164,8 @@ handle_get_instance_finished (void *cls, { GNUNET_break_op (0); ret = GNUNET_SYSERR; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } aa[index].payto_uri = payto_uris[index]; @@ -168,59 +173,57 @@ handle_get_instance_finished (void *cls, if (GNUNET_OK == ret) { - struct TALER_MERCHANT_InstanceDetails details = { - .name = name, - .merchant_pub = &merchant_pub, - .address = address, - .jurisdiction = jurisdiction, - .default_max_wire_fee = &default_max_wire_fee, - .default_wire_fee_amortization = default_wire_fee_amortization, - .default_max_deposit_fee = &default_max_deposit_fee, - .default_wire_transfer_delay = default_wire_transfer_delay, - .default_pay_delay = default_pay_delay - }; - + igr.details.success.details.address = address; + igr.details.success.details.jurisdiction = jurisdiction; + if (GNUNET_OK != + TALER_KYCLOGIC_kyc_user_type_from_string ( + uts, + &igr.details.success.details.ut)) + { + GNUNET_break_op (0); + ret = GNUNET_SYSERR; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + GNUNET_JSON_parse_free (spec); + break; + } + igr.details.success.accounts_length = accounts_length; + igr.details.success.accounts = aa; igh->cb (igh->cb_cls, - &hr, - accounts_length, - aa, - &details); + &igr); GNUNET_JSON_parse_free (spec); TALER_MERCHANT_instance_get_cancel (igh); return; } } GNUNET_break_op (0); - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; GNUNET_JSON_parse_free (spec); break; } case MHD_HTTP_UNAUTHORIZED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; case MHD_HTTP_NOT_FOUND: /* instance does not exist */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); break; default: /* unexpected response code */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code, - (int) hr.ec); + (int) igr.hr.ec); break; } igh->cb (igh->cb_cls, - &hr, - 0, - NULL, - NULL); + &igr); TALER_MERCHANT_instance_get_cancel (igh); } diff --git a/src/lib/merchant_api_get_instances.c b/src/lib/merchant_api_get_instances.c index 52a462b9..d7b1b85a 100644 --- a/src/lib/merchant_api_get_instances.c +++ b/src/lib/merchant_api_get_instances.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018, 2020 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -67,26 +67,37 @@ struct TALER_MERCHANT_InstancesGetHandle /** * Parse instance information from @a ia. * + * @param json overall reply body * @param ia JSON array (or NULL!) with instance data * @param igh operation handle * @return #GNUNET_OK on success */ -static int -parse_instances (const json_t *ia, +static enum GNUNET_GenericReturnValue +parse_instances (const json_t *json, + const json_t *ia, struct TALER_MERCHANT_InstancesGetHandle *igh) { unsigned int iis_len = json_array_size (ia); - struct TALER_MERCHANT_InstanceInformation iis[iis_len]; + struct TALER_MERCHANT_InstanceInformation iis[GNUNET_NZL (iis_len)]; size_t index; json_t *value; - int ret; + enum GNUNET_GenericReturnValue ret; + struct TALER_MERCHANT_InstancesGetResponse igr = { + .hr.http_status = MHD_HTTP_OK, + .hr.reply = json, + .details.success.iis_length = iis_len, + .details.success.iis = iis + }; ret = GNUNET_OK; json_array_foreach (ia, index, value) { struct TALER_MERCHANT_InstanceInformation *ii = &iis[index]; + const char *uts; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("name", &ii->name), + GNUNET_JSON_spec_string ("user_type", + &uts), GNUNET_JSON_spec_string ("id", &ii->id), GNUNET_JSON_spec_fixed_auto ("merchant_pub", @@ -105,10 +116,20 @@ parse_instances (const json_t *ia, ret = GNUNET_SYSERR; continue; } + if (GNUNET_OK != + TALER_KYCLOGIC_kyc_user_type_from_string (uts, + &ii->ut)) + { + GNUNET_break_op (0); + ret = GNUNET_SYSERR; + GNUNET_JSON_parse_free (spec); + break; + } if (! json_is_array (ii->payment_targets)) { GNUNET_break_op (0); ret = GNUNET_SYSERR; + GNUNET_JSON_parse_free (spec); break; } for (unsigned int i = 0; i<json_array_size (ii->payment_targets); i++) @@ -118,22 +139,20 @@ parse_instances (const json_t *ia, { GNUNET_break_op (0); ret = GNUNET_SYSERR; + GNUNET_JSON_parse_free (spec); break; } } if (GNUNET_SYSERR == ret) + { + GNUNET_JSON_parse_free (spec); break; + } } if (GNUNET_OK == ret) { - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = MHD_HTTP_OK - }; - igh->cb (igh->cb_cls, - &hr, - iis_len, - iis); + &igr); igh->cb = NULL; /* just to be sure */ } for (unsigned int i = 0; i<iis_len; i++) @@ -158,9 +177,9 @@ handle_instances_finished (void *cls, { struct TALER_MERCHANT_InstancesGetHandle *igh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_InstancesGetResponse igr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; igh->job = NULL; @@ -183,14 +202,15 @@ handle_instances_finished (void *cls, spec, NULL, NULL)) { - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { if ( (! json_is_array (instances)) || (GNUNET_OK == - parse_instances (instances, + parse_instances (json, + instances, igh)) ) { GNUNET_JSON_parse_free (spec); @@ -199,31 +219,29 @@ handle_instances_finished (void *cls, } else { - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + igr.hr.http_status = 0; + igr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); break; } case MHD_HTTP_UNAUTHORIZED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); break; default: /* unexpected response code */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + igr.hr.ec = TALER_JSON_get_error_code (json); + igr.hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code, - (int) hr.ec); + (int) igr.hr.ec); break; } igh->cb (igh->cb_cls, - &hr, - 0, - NULL); + &igr); TALER_MERCHANT_instances_get_cancel (igh); } diff --git a/src/lib/merchant_api_get_products.c b/src/lib/merchant_api_get_products.c index c3cc30e7..ce26b496 100644 --- a/src/lib/merchant_api_get_products.c +++ b/src/lib/merchant_api_get_products.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018, 2020 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -67,19 +67,21 @@ struct TALER_MERCHANT_ProductsGetHandle /** * Parse product information from @a ia. * + * @param json overall JSON reply * @param ia JSON array (or NULL!) with product data * @param pgh operation handle * @return #GNUNET_OK on success */ -static int -parse_products (const json_t *ia, +static enum GNUNET_GenericReturnValue +parse_products (const json_t *json, + const json_t *ia, struct TALER_MERCHANT_ProductsGetHandle *pgh) { unsigned int ies_len = json_array_size (ia); struct TALER_MERCHANT_InventoryEntry ies[ies_len]; size_t index; json_t *value; - int ret; + enum GNUNET_GenericReturnValue ret; ret = GNUNET_OK; json_array_foreach (ia, index, value) { @@ -104,14 +106,15 @@ parse_products (const json_t *ia, } if (GNUNET_OK == ret) { - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = MHD_HTTP_OK + struct TALER_MERCHANT_GetProductsResponse gpr = { + .hr.http_status = MHD_HTTP_OK, + .hr.reply = json, + .details.success.products_length = ies_len, + .details.success.products = ies }; pgh->cb (pgh->cb_cls, - &hr, - ies_len, - ies); + &gpr); pgh->cb = NULL; /* just to be sure */ } return ret; @@ -133,9 +136,9 @@ handle_get_products_finished (void *cls, { struct TALER_MERCHANT_ProductsGetHandle *pgh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_GetProductsResponse gpr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; pgh->job = NULL; @@ -158,14 +161,15 @@ handle_get_products_finished (void *cls, spec, NULL, NULL)) { - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + gpr.hr.http_status = 0; + gpr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { if ( (! json_is_array (products)) || (GNUNET_OK == - parse_products (products, + parse_products (json, + products, pgh)) ) { GNUNET_JSON_parse_free (spec); @@ -174,32 +178,30 @@ handle_get_products_finished (void *cls, } else { - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + gpr.hr.http_status = 0; + gpr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); break; } case MHD_HTTP_UNAUTHORIZED: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + gpr.hr.ec = TALER_JSON_get_error_code (json); + gpr.hr.hint = TALER_JSON_get_error_hint (json); /* Nothing really to verify, merchant says we need to authenticate. */ break; default: /* unexpected response code */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + gpr.hr.ec = TALER_JSON_get_error_code (json); + gpr.hr.hint = TALER_JSON_get_error_hint (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code, - (int) hr.ec); + (int) gpr.hr.ec); break; } pgh->cb (pgh->cb_cls, - &hr, - 0, - NULL); + &gpr); TALER_MERCHANT_products_get_cancel (pgh); } diff --git a/src/lib/merchant_api_patch_instance.c b/src/lib/merchant_api_patch_instance.c index 0613a852..9d4cea84 100644 --- a/src/lib/merchant_api_patch_instance.c +++ b/src/lib/merchant_api_patch_instance.c @@ -31,6 +31,7 @@ #include "merchant_api_curl_defaults.h" #include "merchant_api_common.h" #include <taler/taler_json_lib.h> +#include <taler/taler_kyclogic_lib.h> #include <taler/taler_curl_lib.h> @@ -160,6 +161,7 @@ TALER_MERCHANT_instance_patch ( unsigned int accounts_length, const char *payto_uris[], const char *name, + enum TALER_KYCLOGIC_KycUserType ut, const json_t *address, const json_t *jurisdiction, const struct TALER_Amount *default_max_wire_fee, @@ -173,7 +175,14 @@ TALER_MERCHANT_instance_patch ( struct TALER_MERCHANT_InstancePatchHandle *iph; json_t *jpayto_uris; json_t *req_obj; + const char *uts; + uts = TALER_KYCLOGIC_kyc_user_type2s (ut); + if (NULL == uts) + { + GNUNET_break (0); + return NULL; + } jpayto_uris = json_array (); if (NULL == jpayto_uris) { @@ -196,6 +205,8 @@ TALER_MERCHANT_instance_patch ( jpayto_uris), GNUNET_JSON_pack_string ("name", name), + GNUNET_JSON_pack_string ("user_type", + uts), GNUNET_JSON_pack_object_incref ("address", (json_t *) address), GNUNET_JSON_pack_object_incref ("jurisdiction", diff --git a/src/lib/merchant_api_post_instances.c b/src/lib/merchant_api_post_instances.c index 183b3400..85069dc3 100644 --- a/src/lib/merchant_api_post_instances.c +++ b/src/lib/merchant_api_post_instances.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -32,6 +32,7 @@ #include "merchant_api_common.h" #include <taler/taler_json_lib.h> #include <taler/taler_curl_lib.h> +#include <taler/taler_kyclogic_lib.h> /** @@ -166,6 +167,7 @@ TALER_MERCHANT_instances_post ( unsigned int accounts_length, const char *payto_uris[], const char *name, + enum TALER_KYCLOGIC_KycUserType ut, const json_t *address, const json_t *jurisdiction, const struct TALER_Amount *default_max_wire_fee, @@ -181,7 +183,14 @@ TALER_MERCHANT_instances_post ( json_t *jpayto_uris; json_t *req_obj; json_t *auth_obj; + const char *uts; + uts = TALER_KYCLOGIC_kyc_user_type2s (ut); + if (NULL == uts) + { + GNUNET_break (0); + return NULL; + } if (NULL != auth_token) { if (0 != strncasecmp (RFC_8959_PREFIX, @@ -236,6 +245,8 @@ TALER_MERCHANT_instances_post ( instance_id), GNUNET_JSON_pack_string ("name", name), + GNUNET_JSON_pack_string ("user_type", + uts), GNUNET_JSON_pack_object_incref ("address", (json_t *) address), GNUNET_JSON_pack_object_incref ("jurisdiction", diff --git a/src/testing/test_key_rotation.sh b/src/testing/test_key_rotation.sh index b3609b1d..7c116511 100755 --- a/src/testing/test_key_rotation.sh +++ b/src/testing/test_key_rotation.sh @@ -190,7 +190,7 @@ echo "OK" echo -n "Setting up merchant instance" STATUS=$(curl -H "Content-Type: application/json" -X POST \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index b25e7519..d4fe16cd 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -241,7 +241,8 @@ run (void *cls, NULL, NULL, EXCHANGE_URL, - MHD_HTTP_NO_CONTENT), + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), TALER_TESTING_cmd_merchant_post_orders_no_claim ("create-proposal-4", merchant_url, MHD_HTTP_OK, @@ -318,7 +319,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1", merchant_url, MHD_HTTP_OK, - "1", + "1", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, true, @@ -337,7 +338,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1-idem", merchant_url, MHD_HTTP_OK, - "1", + "1", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, true, @@ -433,8 +434,8 @@ run (void *cls, MHD_HTTP_OK, NULL, "poll-order-wallet-start-1"), - /* Check for webhook */ - cmd_webhook ("pending-webhooks-pay-w1"), + /* Check for webhook */ + cmd_webhook ("pending-webhooks-pay-w1"), /* Check webhook did anything: have a command that inspects traits of the testserver and check if the traits have the right values set! */ TALER_TESTING_cmd_checkserver ("check-http-server-for-webhooks", @@ -498,7 +499,7 @@ run (void *cls, merchant_url, PAYTO_I1, "EUR:4.98", - NULL , + NULL, /*non-routable IP address so we are sure to not get any reply*/ @@ -630,7 +631,7 @@ run (void *cls, "order-p3", GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_FOREVER_TS, - true, + true, "EUR:5.0", "unsupported-wire-method", "product-3/2", @@ -1545,7 +1546,7 @@ run (void *cls, "EUR:4.99", NULL), - + TALER_TESTING_cmd_end () }; @@ -1969,7 +1970,7 @@ run (void *cls, TALER_TESTING_cmd_batch ("pay-abort", pay_abort), TALER_TESTING_cmd_batch ("refund", - refund), + refund), TALER_TESTING_cmd_batch ("tip", tip), TALER_TESTING_cmd_batch ("templates", diff --git a/src/testing/test_merchant_instance_auth.sh b/src/testing/test_merchant_instance_auth.sh index f4534b9a..4c3bf0a0 100755 --- a/src/testing/test_merchant_instance_auth.sh +++ b/src/testing/test_merchant_instance_auth.sh @@ -30,7 +30,7 @@ echo -n "Configuring 'default' instance ..." STATUS=$(curl -H "Content-Type: application/json" -X POST \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"token","token":"secret-token:new_value"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ + -d '{"auth":{"method":"token","token":"secret-token:new_value"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_instance_creation.sh b/src/testing/test_merchant_instance_creation.sh index 9fee5773..27d35365 100755 --- a/src/testing/test_merchant_instance_creation.sh +++ b/src/testing/test_merchant_instance_creation.sh @@ -40,7 +40,7 @@ echo -n "Configuring default instance ..." STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_instance_purge.sh b/src/testing/test_merchant_instance_purge.sh index 60467385..01653415 100755 --- a/src/testing/test_merchant_instance_purge.sh +++ b/src/testing/test_merchant_instance_purge.sh @@ -24,7 +24,7 @@ echo -n "Configuring default instance ..." STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_instance_response.sh b/src/testing/test_merchant_instance_response.sh index 41ac983b..c05b000f 100755 --- a/src/testing/test_merchant_instance_response.sh +++ b/src/testing/test_merchant_instance_response.sh @@ -45,7 +45,7 @@ fi STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"token","token":"secret-token:other_secret"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ + -d '{"auth":{"method":"token","token":"secret-token:other_secret"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_kyc.sh b/src/testing/test_merchant_kyc.sh index e95e7586..e7364af3 100755 --- a/src/testing/test_merchant_kyc.sh +++ b/src/testing/test_merchant_kyc.sh @@ -25,7 +25,7 @@ echo -n "Configuring a merchant instance before configuring the default instance STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43","payto://x-taler-bank/localhost:8082/44"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43","payto://x-taler-bank/localhost:8082/44"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_order_autocleanup.sh b/src/testing/test_merchant_order_autocleanup.sh index 4a53edca..a3e61de8 100755 --- a/src/testing/test_merchant_order_autocleanup.sh +++ b/src/testing/test_merchant_order_autocleanup.sh @@ -28,7 +28,7 @@ echo -n "Configuring merchant instance ..." STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43","payto://x-taler-bank/localhost:8082/44"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43","payto://x-taler-bank/localhost:8082/44"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] @@ -41,7 +41,7 @@ fi STATUS=$(curl -H "Content-Type: application/json" -X PATCH \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/instances/default/private/ \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:8082/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh index 684803b8..0c2188e0 100755 --- a/src/testing/test_merchant_order_creation.sh +++ b/src/testing/test_merchant_order_creation.sh @@ -46,7 +46,7 @@ FORTYTHREE=`get_payto_uri fortythree x` STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'","payto://iban/SANDBOXX/DE270744?receiver-name=Forty+Four"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'","payto://iban/SANDBOXX/DE270744?receiver-name=Forty+Four"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] @@ -60,7 +60,7 @@ fi STATUS=$(curl -H "Content-Type: application/json" -X PATCH \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/instances/default/private/ \ - -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000000},"default_pay_delay":{"d_us": 60000000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_product_creation.sh b/src/testing/test_merchant_product_creation.sh index 702b0e53..51910d4a 100755 --- a/src/testing/test_merchant_product_creation.sh +++ b/src/testing/test_merchant_product_creation.sh @@ -24,7 +24,7 @@ echo -n "Configuring merchant instance ..." STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["'$FORTYTHREE'"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_reserve_creation.sh b/src/testing/test_merchant_reserve_creation.sh index f97986b3..58b6611a 100755 --- a/src/testing/test_merchant_reserve_creation.sh +++ b/src/testing/test_merchant_reserve_creation.sh @@ -28,7 +28,7 @@ FORTYTHREE=`get_payto_uri fortythree x` STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:1'$NEXUS_PORT'/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost:1'$NEXUS_PORT'/43"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/test_merchant_transfer_tracking.sh b/src/testing/test_merchant_transfer_tracking.sh index 8fb7be64..646589b6 100755 --- a/src/testing/test_merchant_transfer_tracking.sh +++ b/src/testing/test_merchant_transfer_tracking.sh @@ -47,7 +47,7 @@ GNUNET_PAYTO=`get_payto_uri gnunet x` STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["'$TOR_PAYTO'","'$GNUNET_PAYTO'"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["'$TOR_PAYTO'","'$GNUNET_PAYTO'"],"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] @@ -67,7 +67,7 @@ TUTORIAL_PAYTO=`get_payto_uri tutorial x` STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ http://localhost:9966/management/instances \ - -d '{"auth":{"method":"external"},"payto_uris":["'$SURVEY_PAYTO'","'$TUTORIAL_PAYTO'"],"id":"test","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ + -d '{"auth":{"method":"external"},"payto_uris":["'$SURVEY_PAYTO'","'$TUTORIAL_PAYTO'"],"id":"test","name":"default","user_type":"business","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \ -w "%{http_code}" -s -o /dev/null) if [ "$STATUS" != "204" ] diff --git a/src/testing/testing_api_cmd_get_instance.c b/src/testing/testing_api_cmd_get_instance.c index 95dc7282..0127a13d 100644 --- a/src/testing/testing_api_cmd_get_instance.c +++ b/src/testing/testing_api_cmd_get_instance.c @@ -96,17 +96,11 @@ struct GetInstanceState * Callback for a /get/instance/$ID operation. * * @param cls closure for this function - * @param hr HTTP response - * @param accounts_length how many bank accounts the instance has - * @param accounts the list of the instance's bank accounts - * @param details all the details related to this particular instance + * @param igr response */ static void get_instance_cb (void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int accounts_length, - const struct TALER_MERCHANT_Account accounts[], - const struct TALER_MERCHANT_InstanceDetails *details) + const struct TALER_MERCHANT_InstanceGetResponse *igr) { struct GetInstanceState *gis = cls; const struct TALER_TESTING_Command *instance_cmd; @@ -116,210 +110,218 @@ get_instance_cb (void *cls, gis->instance_reference); gis->igh = NULL; - if (gis->http_status != hr->http_status) + if (gis->http_status != igr->hr.http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u (%d) to command %s\n", - hr->http_status, - (int) hr->ec, + igr->hr.http_status, + (int) igr->hr.ec, TALER_TESTING_interpreter_get_current_label (gis->is)); TALER_TESTING_interpreter_fail (gis->is); return; } - switch (hr->http_status) + switch (igr->hr.http_status) { case MHD_HTTP_OK: { - const char **name; - - if (GNUNET_OK != - TALER_TESTING_get_trait_instance_name (instance_cmd, - &name)) - TALER_TESTING_interpreter_fail (gis->is); - if (0 != strcmp (details->name, - *name)) + const struct TALER_MERCHANT_InstanceDetails *details = + &igr->details.success.details; { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance name does not match: Got `%s', wanted `%s'\n", - details->name, - *name); - TALER_TESTING_interpreter_fail (gis->is); - return; + const char **name; + + if (GNUNET_OK != + TALER_TESTING_get_trait_instance_name (instance_cmd, + &name)) + TALER_TESTING_interpreter_fail (gis->is); + if (0 != strcmp (details->name, + *name)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance name does not match: Got `%s', wanted `%s'\n", + details->name, + *name); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const json_t *address; - - if (GNUNET_OK != - TALER_TESTING_get_trait_address (instance_cmd, - &address)) - TALER_TESTING_interpreter_fail (gis->is); - if (1 != json_equal (details->address, - address)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance address does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const json_t *address; + + if (GNUNET_OK != + TALER_TESTING_get_trait_address (instance_cmd, + &address)) + TALER_TESTING_interpreter_fail (gis->is); + if (1 != json_equal (details->address, + address)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance address does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const struct json_t *jurisdiction; - - if (GNUNET_OK != - TALER_TESTING_get_trait_jurisdiction (instance_cmd, - &jurisdiction)) - TALER_TESTING_interpreter_fail (gis->is); - if (1 != json_equal (details->jurisdiction, - jurisdiction)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance jurisdiction does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const struct json_t *jurisdiction; + + if (GNUNET_OK != + TALER_TESTING_get_trait_jurisdiction (instance_cmd, + &jurisdiction)) + TALER_TESTING_interpreter_fail (gis->is); + if (1 != json_equal (details->jurisdiction, + jurisdiction)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance jurisdiction does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const struct TALER_Amount *default_max_wire_fee; - - if (GNUNET_OK != - TALER_TESTING_get_trait_max_wire_fee (instance_cmd, - &default_max_wire_fee)) - TALER_TESTING_interpreter_fail (gis->is); - if ((GNUNET_OK != TALER_amount_cmp_currency ( - details->default_max_wire_fee, - default_max_wire_fee)) || - (0 != TALER_amount_cmp (details->default_max_wire_fee, - default_max_wire_fee))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance default max wire fee does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const struct TALER_Amount *default_max_wire_fee; + + if (GNUNET_OK != + TALER_TESTING_get_trait_max_wire_fee (instance_cmd, + &default_max_wire_fee)) + TALER_TESTING_interpreter_fail (gis->is); + if ((GNUNET_OK != + TALER_amount_cmp_currency ( + &details->default_max_wire_fee, + default_max_wire_fee)) || + (0 != TALER_amount_cmp (&details->default_max_wire_fee, + default_max_wire_fee))) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance default max wire fee does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const uint32_t *default_wire_fee_amortization; - - if (GNUNET_OK != - TALER_TESTING_get_trait_wire_fee_amortization (instance_cmd, - & - default_wire_fee_amortization)) - TALER_TESTING_interpreter_fail (gis->is); - if (details->default_wire_fee_amortization != - *default_wire_fee_amortization) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance default wire fee amortization does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const uint32_t *default_wire_fee_amortization; + + if (GNUNET_OK != + TALER_TESTING_get_trait_wire_fee_amortization ( + instance_cmd, + &default_wire_fee_amortization)) + TALER_TESTING_interpreter_fail (gis->is); + if (details->default_wire_fee_amortization != + *default_wire_fee_amortization) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance default wire fee amortization does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const struct TALER_Amount *default_max_deposit_fee; - - if (GNUNET_OK != - TALER_TESTING_get_trait_max_deposit_fee (instance_cmd, - &default_max_deposit_fee)) - TALER_TESTING_interpreter_fail (gis->is); - if ( (GNUNET_OK != - TALER_amount_cmp_currency ( - details->default_max_deposit_fee, - default_max_deposit_fee)) || - (0 != TALER_amount_cmp (details->default_max_deposit_fee, - default_max_deposit_fee)) ) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance default max deposit fee %s does not match\n", - TALER_amount2s (details->default_max_deposit_fee)); - TALER_TESTING_interpreter_fail (gis->is); - return; + const struct TALER_Amount *default_max_deposit_fee; + + if (GNUNET_OK != + TALER_TESTING_get_trait_max_deposit_fee (instance_cmd, + &default_max_deposit_fee)) + TALER_TESTING_interpreter_fail (gis->is); + if ( (GNUNET_OK != + TALER_amount_cmp_currency ( + &details->default_max_deposit_fee, + default_max_deposit_fee)) || + (0 != TALER_amount_cmp (&details->default_max_deposit_fee, + default_max_deposit_fee)) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance default max deposit fee %s does not match\n", + TALER_amount2s (&details->default_max_deposit_fee)); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const struct GNUNET_TIME_Relative *default_wire_transfer_delay; - - if (GNUNET_OK != - TALER_TESTING_get_trait_wire_delay (instance_cmd, - &default_wire_transfer_delay)) - TALER_TESTING_interpreter_fail (gis->is); - if (details->default_wire_transfer_delay.rel_value_us != - default_wire_transfer_delay->rel_value_us) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance default wire transfer delay does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const struct GNUNET_TIME_Relative *default_wire_transfer_delay; + + if (GNUNET_OK != + TALER_TESTING_get_trait_wire_delay (instance_cmd, + &default_wire_transfer_delay)) + TALER_TESTING_interpreter_fail (gis->is); + if (details->default_wire_transfer_delay.rel_value_us != + default_wire_transfer_delay->rel_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance default wire transfer delay does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - { - const struct GNUNET_TIME_Relative *default_pay_delay; - if (GNUNET_OK != - TALER_TESTING_get_trait_pay_delay (instance_cmd, - &default_pay_delay)) - TALER_TESTING_interpreter_fail (gis->is); - if (details->default_pay_delay.rel_value_us != - default_pay_delay->rel_value_us) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance default pay delay does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const struct GNUNET_TIME_Relative *default_pay_delay; + if (GNUNET_OK != + TALER_TESTING_get_trait_pay_delay (instance_cmd, + &default_pay_delay)) + TALER_TESTING_interpreter_fail (gis->is); + if (details->default_pay_delay.rel_value_us != + default_pay_delay->rel_value_us) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance default pay delay does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - } - /* We aren't guaranteed an order for the accounts, so we just have to check - that we can match each account returned with exactly one account - expected. */ - if (gis->cmp_accounts) - { - unsigned int expected_accounts_length = - gis->active_accounts_length + gis->inactive_accounts_length; - unsigned int matches[accounts_length]; - - if (accounts_length != expected_accounts_length) + /* We aren't guaranteed an order for the accounts, so we just have to check + that we can match each account returned with exactly one account + expected. */ + if (gis->cmp_accounts) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Accounts length does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } + unsigned int have_al = igr->details.success.accounts_length; + unsigned int expected_accounts_length = + gis->active_accounts_length + gis->inactive_accounts_length; + unsigned int matches[GNUNET_NZL (have_al)]; + + if (have_al != expected_accounts_length) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Accounts length does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } - memset (matches, - 0, - sizeof (unsigned int) * accounts_length); + memset (matches, + 0, + sizeof (matches)); - /* Compare the accounts */ - for (unsigned int i = 0; i < accounts_length; ++i) - { - for (unsigned int j = 0; j < gis->active_accounts_length; ++j) + /* Compare the accounts */ + for (unsigned int i = 0; i < have_al; ++i) { - if ((0 == strcasecmp (accounts[i].payto_uri, - gis->active_accounts[j])) && - (true == accounts[i].active)) + const struct TALER_MERCHANT_Account *account + = &igr->details.success.accounts[i]; + for (unsigned int j = 0; j < gis->active_accounts_length; ++j) { - matches[i] += 1; + if ((0 == strcasecmp (account->payto_uri, + gis->active_accounts[j])) && + account->active) + { + matches[i] += 1; + } } - } - for (unsigned int j = 0; j < gis->inactive_accounts_length; ++j) - { - if ((0 == strcasecmp (accounts[i].payto_uri, - gis->inactive_accounts[j])) && - (false == accounts[i].active)) + for (unsigned int j = 0; j < gis->inactive_accounts_length; ++j) { - matches[i] += 1; + if ((0 == strcasecmp (account->payto_uri, + gis->inactive_accounts[j])) && + (! account->active)) + { + matches[i] += 1; + } } } - } - // Each account should have exactly one match. - for (unsigned int i = 0; i < accounts_length; ++i) - { - if (1 != matches[i]) + // Each account should have exactly one match. + for (unsigned int i = 0; i < have_al; ++i) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance account does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + if (1 != matches[i]) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance account does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } } } @@ -331,7 +333,7 @@ get_instance_cb (void *cls, default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unhandled HTTP status %u for GET instance ID.\n", - hr->http_status); + igr->hr.http_status); } TALER_TESTING_interpreter_next (gis->is); } diff --git a/src/testing/testing_api_cmd_get_instances.c b/src/testing/testing_api_cmd_get_instances.c index 8aee04b1..5fb17746 100644 --- a/src/testing/testing_api_cmd_get_instances.c +++ b/src/testing/testing_api_cmd_get_instances.c @@ -71,16 +71,13 @@ struct GetInstancesState * Callback for a GET /instances operation. * * @param cls closure for this function - * @param hr HTTP response - * @param iis_length how many instances are returned - * @param iis all the instances details + * @param igr response */ static void get_instances_cb (void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int iis_length, - const struct TALER_MERCHANT_InstanceInformation iis[]) + const struct TALER_MERCHANT_InstancesGetResponse *igr) { + const struct TALER_MERCHANT_HttpResponse *hr = &igr->hr; struct GetInstancesState *gis = cls; gis->igh = NULL; @@ -97,68 +94,75 @@ get_instances_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - if (iis_length != gis->instances_length) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Length of instances found does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } - for (unsigned int i = 0; i < iis_length; ++i) - { - const struct TALER_TESTING_Command *instance_cmd; - - instance_cmd = TALER_TESTING_interpreter_lookup_command ( - gis->is, - gis->instances[i]); + unsigned int iis_length + = igr->details.success.iis_length; + const struct TALER_MERCHANT_InstanceInformation *iis + = igr->details.success.iis; + if (iis_length != gis->instances_length) { - const char **name; - - if (GNUNET_OK != - TALER_TESTING_get_trait_instance_name (instance_cmd, - &name)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch instance name\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } - if (0 != strcmp (iis[i].name, - *name)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance name does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Length of instances found does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; } - + for (unsigned int i = 0; i < iis_length; ++i) { - const char **id; + const struct TALER_TESTING_Command *instance_cmd; + + instance_cmd = TALER_TESTING_interpreter_lookup_command ( + gis->is, + gis->instances[i]); - if (GNUNET_OK != - TALER_TESTING_get_trait_instance_id (instance_cmd, - &id)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch instance id\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const char **name; + + if (GNUNET_OK != + TALER_TESTING_get_trait_instance_name (instance_cmd, + &name)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch instance name\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } + if (0 != strcmp (iis[i].name, + *name)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance name does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } - if (0 != strcmp (iis[i].id, - *id)) + { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Instance id does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const char **id; + + if (GNUNET_OK != + TALER_TESTING_get_trait_instance_id (instance_cmd, + &id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch instance id\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } + if (0 != strcmp (iis[i].id, + *id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Instance id does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } } - } - // FIXME: compare payment_targets - break; + // FIXME: compare payment_targets + break; + } default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unhandled HTTP status %u for GET /instances.\n", diff --git a/src/testing/testing_api_cmd_get_products.c b/src/testing/testing_api_cmd_get_products.c index 190bb4c1..dbf5be39 100644 --- a/src/testing/testing_api_cmd_get_products.c +++ b/src/testing/testing_api_cmd_get_products.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -71,17 +71,14 @@ struct GetProductsState * Callback for a GET /products operation. * * @param cls closure for this function - * @param hr HTTP response details - * @param products_length length of the @a products array - * @param products array of products the requested instance offers + * @param gpr response details */ static void get_products_cb (void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - unsigned int products_length, - const struct TALER_MERCHANT_InventoryEntry products[]) + const struct TALER_MERCHANT_GetProductsResponse *gpr) { struct GetProductsState *gis = cls; + const struct TALER_MERCHANT_HttpResponse *hr = &gpr->hr; gis->igh = NULL; if (gis->http_status != hr->http_status) @@ -97,40 +94,47 @@ get_products_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - if (products_length != gis->products_length) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Length of products found does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } - for (unsigned int i = 0; i < gis->products_length; ++i) - { - const struct TALER_TESTING_Command *product_cmd; - - product_cmd = TALER_TESTING_interpreter_lookup_command ( - gis->is, - gis->products[i]); + unsigned int products_length + = gpr->details.success.products_length; + const struct TALER_MERCHANT_InventoryEntry *products + = gpr->details.success.products; + if (products_length != gis->products_length) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Length of products found does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } + for (unsigned int i = 0; i < gis->products_length; ++i) { - const char **product_id; + const struct TALER_TESTING_Command *product_cmd; + + product_cmd = TALER_TESTING_interpreter_lookup_command ( + gis->is, + gis->products[i]); - if (GNUNET_OK != - TALER_TESTING_get_trait_product_id (product_cmd, - &product_id)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Could not fetch product id\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; - } - if (0 != strcmp (products[i].product_id, - *product_id)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Product id does not match\n"); - TALER_TESTING_interpreter_fail (gis->is); - return; + const char **product_id; + + if (GNUNET_OK != + TALER_TESTING_get_trait_product_id (product_cmd, + &product_id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not fetch product id\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } + if (0 != strcmp (products[i].product_id, + *product_id)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Product id does not match\n"); + TALER_TESTING_interpreter_fail (gis->is); + return; + } } } } diff --git a/src/testing/testing_api_cmd_patch_instance.c b/src/testing/testing_api_cmd_patch_instance.c index 348163af..4ea0fba1 100644 --- a/src/testing/testing_api_cmd_patch_instance.c +++ b/src/testing/testing_api_cmd_patch_instance.c @@ -179,6 +179,7 @@ patch_instance_run (void *cls, pis->payto_uris_length, pis->payto_uris, pis->name, + TALER_KYCLOGIC_KYC_UT_BUSINESS, pis->address, pis->jurisdiction, &pis->default_max_wire_fee, diff --git a/src/testing/testing_api_cmd_post_instances.c b/src/testing/testing_api_cmd_post_instances.c index 4d1f0d26..61e54e53 100644 --- a/src/testing/testing_api_cmd_post_instances.c +++ b/src/testing/testing_api_cmd_post_instances.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -186,6 +186,7 @@ post_instances_run (void *cls, pis->payto_uris_length, pis->payto_uris, pis->name, + TALER_KYCLOGIC_KYC_UT_BUSINESS, pis->address, pis->jurisdiction, &pis->default_max_wire_fee, |