summaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_merchant_api.c101
-rw-r--r--src/testing/testing_api_cmd_delete_instance.c7
-rw-r--r--src/testing/testing_api_cmd_get_product.c12
-rw-r--r--src/testing/testing_api_cmd_get_products.c9
4 files changed, 122 insertions, 7 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,
diff --git a/src/testing/testing_api_cmd_delete_instance.c b/src/testing/testing_api_cmd_delete_instance.c
index 9bb3efb7..ca2acb76 100644
--- a/src/testing/testing_api_cmd_delete_instance.c
+++ b/src/testing/testing_api_cmd_delete_instance.c
@@ -92,7 +92,11 @@ delete_instance_cb (void *cls,
}
switch (hr->http_status)
{
- case MHD_HTTP_OK:
+ case MHD_HTTP_NO_CONTENT:
+ break;
+ case MHD_HTTP_UNAUTHORIZED:
+ break;
+ case MHD_HTTP_NOT_FOUND:
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -105,7 +109,6 @@ delete_instance_cb (void *cls,
/**
* Run the "DELETE instance" CMD.
*
- *
* @param cls closure.
* @param cmd command being run now.
* @param is interpreter state.
diff --git a/src/testing/testing_api_cmd_get_product.c b/src/testing/testing_api_cmd_get_product.c
index 88050a42..d1f844b0 100644
--- a/src/testing/testing_api_cmd_get_product.c
+++ b/src/testing/testing_api_cmd_get_product.c
@@ -109,10 +109,6 @@ get_product_cb (void *cls,
struct GetProductState *gis = cls;
const struct TALER_TESTING_Command *product_cmd;
- product_cmd = TALER_TESTING_interpreter_lookup_command (
- gis->is,
- gis->product_reference);
-
gis->igh = NULL;
if (gis->http_status != hr->http_status)
{
@@ -129,6 +125,10 @@ get_product_cb (void *cls,
case MHD_HTTP_OK:
{
const char *expected_description;
+
+ product_cmd = TALER_TESTING_interpreter_lookup_command (
+ gis->is,
+ gis->product_reference);
if (GNUNET_OK !=
TALER_TESTING_get_trait_string (product_cmd,
0,
@@ -276,6 +276,10 @@ get_product_cb (void *cls,
}
}
break;
+ case MHD_HTTP_UNAUTHORIZED:
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unhandled HTTP status.\n");
diff --git a/src/testing/testing_api_cmd_get_products.c b/src/testing/testing_api_cmd_get_products.c
index 2df168ee..534ffea5 100644
--- a/src/testing/testing_api_cmd_get_products.c
+++ b/src/testing/testing_api_cmd_get_products.c
@@ -135,9 +135,16 @@ get_products_cb (void *cls,
}
}
break;
+ case MHD_HTTP_UNAUTHORIZED:
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ /* instance does not exist */
+ break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unhandled HTTP status.\n");
+ "Unhandled HTTP status %u (%d).\n",
+ hr->http_status,
+ hr->ec);
}
TALER_TESTING_interpreter_next (gis->is);
}