merchant

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

commit c9d29b909d092dc9d5c230f496905fa3a07f64f0
parent 79b90fbb7780c2a1d250971fa42565e137432bc8
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  5 Aug 2021 18:55:53 +0200

-merge sebastjm's #6945 branch/fix, and fix an issue in the test logic

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 27++++++++++++++++++++-------
Msrc/backend/taler-merchant-httpd_private-delete-instances-ID.h | 2+-
Msrc/backend/taler-merchant-httpd_private-get-instances-ID.h | 2+-
Msrc/lib/merchant_api_delete_instance.c | 2+-
Msrc/lib/merchant_api_get_instances.c | 2+-
Msrc/lib/merchant_api_patch_instance.c | 2+-
Msrc/lib/merchant_api_post_instance_auth.c | 2+-
Msrc/lib/merchant_api_post_instances.c | 4++--
Msrc/testing/Makefile.am | 1+
Msrc/testing/test_key_rotation.sh | 2+-
Msrc/testing/test_merchant_api.c | 12++++++------
Msrc/testing/test_merchant_instance_response.sh | 2+-
Msrc/testing/test_merchant_order_creation.sh | 2+-
Msrc/testing/test_merchant_product_creation.sh | 2+-
Msrc/testing/test_merchant_reserve_creation.sh | 6++----
15 files changed, 41 insertions(+), 29 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -1149,7 +1149,7 @@ url_handler (void *cls, size_t *upload_data_size, void **con_cls) { - static struct TMH_RequestHandler private_handlers[] = { + static struct TMH_RequestHandler management_handlers[] = { /* GET /instances */ { .url_prefix = "/instances", @@ -1180,7 +1180,7 @@ url_handler (void *cls, .have_id_segment = true, .handler = &TMH_private_get_instances_default_ID }, - /* DELETE /private/instances/$ID */ + /* DELETE /instances/$ID */ { .url_prefix = "/instances/", .method = MHD_HTTP_METHOD_DELETE, @@ -1213,9 +1213,14 @@ url_handler (void *cls, .have_id_segment = true, .handler = &TMH_private_post_instances_default_ID_auth, /* Body should be pretty small. */ - .max_upload = 1024 * 1024, + .max_upload = 1024 * 1024 }, + { + NULL + } + }; + static struct TMH_RequestHandler private_handlers[] = { /* GET /instances/$ID/: */ { .url_prefix = "/", @@ -1733,13 +1738,21 @@ url_handler (void *cls, } { + const char *management_prefix = "/management/"; const char *private_prefix = "/private/"; if ( (0 == strncmp (url, - private_prefix, - strlen (private_prefix))) || - (0 == strcmp (url, - "/private")) ) + management_prefix, + strlen (management_prefix))) ) + { + handlers = management_handlers; + url += strlen (management_prefix) - 1; + } + else if ( (0 == strncmp (url, + private_prefix, + strlen (private_prefix))) || + (0 == strcmp (url, + "/private")) ) { handlers = private_handlers; url += strlen (private_prefix) - 1; diff --git a/src/backend/taler-merchant-httpd_private-delete-instances-ID.h b/src/backend/taler-merchant-httpd_private-delete-instances-ID.h @@ -39,7 +39,7 @@ TMH_private_delete_instances_ID (const struct TMH_RequestHandler *rh, /** - * Handle a DELETE "/private/instances/$ID" request. + * Handle a DELETE "/management/instances/$ID" request. * * @param rh context of the handler * @param connection the MHD connection to handle diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID.h b/src/backend/taler-merchant-httpd_private-get-instances-ID.h @@ -39,7 +39,7 @@ TMH_private_get_instances_ID (const struct TMH_RequestHandler *rh, /** - * Handle a GET "/private/instances/$ID" request. + * Handle a GET "/management/instances/$ID" request. * * @param rh context of the handler * @param connection the MHD connection to handle diff --git a/src/lib/merchant_api_delete_instance.c b/src/lib/merchant_api_delete_instance.c @@ -147,7 +147,7 @@ instance_delete (struct GNUNET_CURL_Context *ctx, char *path; GNUNET_asprintf (&path, - "private/instances/%s", + "management/instances/%s", instance_id); idh->url = TALER_url_join (backend_url, path, diff --git a/src/lib/merchant_api_get_instances.c b/src/lib/merchant_api_get_instances.c @@ -241,7 +241,7 @@ TALER_MERCHANT_instances_get (struct GNUNET_CURL_Context *ctx, igh->cb = instances_cb; igh->cb_cls = instances_cb_cls; igh->url = TALER_url_join (backend_url, - "private/instances", + "management/instances", NULL); if (NULL == igh->url) { diff --git a/src/lib/merchant_api_patch_instance.c b/src/lib/merchant_api_patch_instance.c @@ -217,7 +217,7 @@ TALER_MERCHANT_instance_patch ( char *path; GNUNET_asprintf (&path, - "private/instances/%s", + "management/instances/%s", instance_id); iph->url = TALER_url_join (backend_url, path, diff --git a/src/lib/merchant_api_post_instance_auth.c b/src/lib/merchant_api_post_instance_auth.c @@ -145,7 +145,7 @@ TALER_MERCHANT_instance_auth_post ( char *path; GNUNET_asprintf (&path, - "private/instances/%s/auth", + "management/instances/%s/auth", instance_id); iaph->url = TALER_url_join (backend_url, path, diff --git a/src/lib/merchant_api_post_instances.c b/src/lib/merchant_api_post_instances.c @@ -93,7 +93,7 @@ handle_post_instances_finished (void *cls, iph->job = NULL; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "POST /private/instances completed with response code %u\n", + "POST /management/instances completed with response code %u\n", (unsigned int) response_code); switch (response_code) { @@ -255,7 +255,7 @@ TALER_MERCHANT_instances_post ( iph->cb = cb; iph->cb_cls = cb_cls; iph->url = TALER_url_join (backend_url, - "private/instances", + "management/instances", NULL); if (NULL == iph->url) { diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am @@ -11,6 +11,7 @@ check_SCRIPTS = \ test-merchant-walletharness.sh \ test_merchant_instance_response.sh \ test_merchant_product_creation.sh \ + test_merchant_reserve_creation.sh \ test_merchant_order_creation.sh lib_LTLIBRARIES = \ diff --git a/src/testing/test_key_rotation.sh b/src/testing/test_key_rotation.sh @@ -172,7 +172,7 @@ echo "OK" echo -n "Setting up merchant instance" STATUS=$(curl -H "Content-Type: application/json" -X POST \ - http://localhost:9966/private/instances \ + 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_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' \ -w "%{http_code}" -s -o /dev/null) diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -943,21 +943,21 @@ run (void *cls, "Bearer " RFC_8959_PREFIX "my-other-secret"), TALER_TESTING_cmd_merchant_post_instance_auth ( "instance-create-i1a-auth-ok-idempotent", - merchant_url, - "i1a", + merchant_url_i1a, + NULL, RFC_8959_PREFIX "my-other-secret", MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_instance_auth ( "instance-create-i1a-clear-auth", - merchant_url, - "i1a", + merchant_url_i1a, + NULL, NULL, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_set_authorization ("set-auth-none", NULL), TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a", - merchant_url, - "i1a", + merchant_url_i1a, + NULL, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_end () }; diff --git a/src/testing/test_merchant_instance_response.sh b/src/testing/test_merchant_instance_response.sh @@ -28,7 +28,7 @@ fi STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ - http://localhost:9966/private/instances \ + 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_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' \ -w "%{http_code}" -s -o /dev/null) diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh @@ -27,7 +27,7 @@ echo -n "Configuring merchant instance ..." # create with 2 address STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ - http://localhost:9966/private/instances \ + 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_ms" : 50000},"default_pay_delay":{"d_ms": 60000}}' \ -w "%{http_code}" -s -o /dev/null) diff --git a/src/testing/test_merchant_product_creation.sh b/src/testing/test_merchant_product_creation.sh @@ -6,7 +6,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/private/instances \ + http://localhost:9966/management/instances \ -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_ms" : 50000},"default_pay_delay":{"d_ms": 60000}}' \ -w "%{http_code}" -s -o /dev/null) diff --git a/src/testing/test_merchant_reserve_creation.sh b/src/testing/test_merchant_reserve_creation.sh @@ -8,7 +8,7 @@ echo -n "Configuring merchant instance ..." # create instance STATUS=$(curl -H "Content-Type: application/json" -X POST \ -H 'Authorization: Bearer secret-token:super_secret' \ - http://localhost:9966/private/instances \ + http://localhost:9966/management/instances \ -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/'$BANK_URL'/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_ms" : 50000},"default_pay_delay":{"d_ms": 60000}}' \ -w "%{http_code}" -s -o /dev/null) @@ -89,7 +89,7 @@ STATUS=$(curl 'http://localhost:9966/instances/default/private/reserves/'$RESERV if [ "$STATUS" != "200" ] then - echo 'should respond failed, we didn't funded yet. got:' $STATUS + echo 'should respond failed, we did not fund yet. got:' $STATUS exit 1 fi @@ -154,5 +154,3 @@ echo "FAILED (which is ok)" exit 0 - -