summaryrefslogtreecommitdiff
path: root/src/testing/test_merchant_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-04-17 21:46:53 +0200
committerChristian Grothoff <christian@grothoff.org>2021-04-17 21:46:53 +0200
commit08d795551739e047805fd2f89d6c16ca743289d1 (patch)
tree98a73efa4c7ff9e08c68e58c7e972a09983bc6e9 /src/testing/test_merchant_api.c
parent657d5ba149cad6c24704a3544994f1200caf639e (diff)
downloadmerchant-08d795551739e047805fd2f89d6c16ca743289d1.tar.gz
merchant-08d795551739e047805fd2f89d6c16ca743289d1.tar.bz2
merchant-08d795551739e047805fd2f89d6c16ca743289d1.zip
add tests and bugfixes to fix #6778 and #6779
Diffstat (limited to 'src/testing/test_merchant_api.c')
-rw-r--r--src/testing/test_merchant_api.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 6d9314b6..052b0c1d 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -84,6 +84,11 @@ static struct TALER_TESTING_ExchangeConfiguration ec;
static char *merchant_url;
/**
+ * Merchant instance "i1a" base URL.
+ */
+static char *merchant_url_i1a;
+
+/**
* Merchant process.
*/
static struct GNUNET_OS_Process *merchantd;
@@ -842,6 +847,97 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
+ struct TALER_TESTING_Command auth[] = {
+ TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1a",
+ merchant_url,
+ "i1a",
+ PAYTO_I1,
+ "EUR",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1",
+ merchant_url_i1a,
+ "nx-product",
+ MHD_HTTP_NOT_FOUND,
+ NULL),
+ TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-1",
+ merchant_url_i1a,
+ MHD_HTTP_OK,
+ NULL),
+ TALER_TESTING_cmd_merchant_post_instance_auth (
+ "instance-create-i1a-auth-fail",
+ merchant_url,
+ "i1a",
+ "my-secret",
+ MHD_HTTP_BAD_REQUEST),
+ TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-2",
+ merchant_url_i1a,
+ "nx-product",
+ MHD_HTTP_NOT_FOUND,
+ NULL),
+ TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-2",
+ merchant_url_i1a,
+ MHD_HTTP_OK,
+ NULL),
+ TALER_TESTING_cmd_merchant_post_instance_auth (
+ "instance-create-i1a-auth-ok",
+ merchant_url,
+ "i1a",
+ RFC_8959_PREFIX "my-secret",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-3",
+ merchant_url_i1a,
+ "nx-product",
+ MHD_HTTP_UNAUTHORIZED,
+ NULL),
+ TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-3",
+ merchant_url_i1a,
+ MHD_HTTP_UNAUTHORIZED,
+ NULL),
+ TALER_TESTING_cmd_set_authorization ("set-auth-valid",
+ "Bearer " RFC_8959_PREFIX "my-secret"),
+ TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-4",
+ merchant_url_i1a,
+ "nx-product",
+ MHD_HTTP_NOT_FOUND,
+ NULL),
+ TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-4",
+ merchant_url_i1a,
+ MHD_HTTP_OK,
+ NULL),
+ TALER_TESTING_cmd_merchant_post_instance_auth (
+ "instance-create-i1a-change-auth",
+ merchant_url_i1a,
+ NULL,
+ RFC_8959_PREFIX "my-other-secret",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-5",
+ merchant_url_i1a,
+ "nx-product",
+ MHD_HTTP_UNAUTHORIZED,
+ NULL),
+ TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-5",
+ merchant_url_i1a,
+ MHD_HTTP_UNAUTHORIZED,
+ NULL),
+ TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a-fail",
+ merchant_url_i1a,
+ NULL,
+ MHD_HTTP_UNAUTHORIZED),
+ TALER_TESTING_cmd_set_authorization ("set-auth-none",
+ NULL),
+ TALER_TESTING_cmd_merchant_post_instance_auth (
+ "instance-create-i1a-clear-auth",
+ merchant_url,
+ "i1a",
+ NULL,
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a",
+ merchant_url,
+ "i1a",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_end ()
+ };
+
struct TALER_TESTING_Command tip[] = {
TALER_TESTING_cmd_merchant_post_reserves ("create-reserve-tip-1",
merchant_url,
@@ -1454,6 +1550,8 @@ run (void *cls,
refund),
TALER_TESTING_cmd_batch ("tip",
tip),
+ TALER_TESTING_cmd_batch ("auth",
+ auth),
/**
* End the suite.
*/
@@ -1491,6 +1589,9 @@ main (int argc,
(merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
return 77;
+ GNUNET_asprintf (&merchant_url_i1a,
+ "%sinstances/i1a/",
+ merchant_url);
TALER_TESTING_cleanup_files (CONFIG_FILE);
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,