summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-21 17:32:18 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-21 17:32:18 +0200
commit245a7eb5b63bdc18ab1b41738d5ba12884afc7e0 (patch)
treeb315216c740c9de6e14167ecb2928e435853ad01
parent0eee3574dcb7bf1971a2e106f666caa41f8589f3 (diff)
downloadmerchant-245a7eb5b63bdc18ab1b41738d5ba12884afc7e0.tar.gz
merchant-245a7eb5b63bdc18ab1b41738d5ba12884afc7e0.tar.bz2
merchant-245a7eb5b63bdc18ab1b41738d5ba12884afc7e0.zip
-fix test regressions
-rw-r--r--src/backend/taler-merchant-httpd_helper.c8
-rw-r--r--src/backend/taler-merchant-httpd_private-get-products-ID.c7
-rw-r--r--src/testing/test_merchant_api.c22
-rw-r--r--src/testing/testing_api_cmd_patch_product.c5
-rw-r--r--src/testing/testing_api_cmd_post_products.c6
5 files changed, 32 insertions, 16 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c
index 20be2b45..b869770f 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -106,8 +106,8 @@ TMH_image_data_url_valid (const char *image_data_url)
image_data_url,
strlen ("data:image/")))
return false;
- if (NULL == strstr (";base64,",
- image_data_url))
+ if (NULL == strstr (image_data_url,
+ ";base64,"))
return false;
// FIXME: write generic URI syntax validation */
return true;
@@ -173,6 +173,7 @@ TMH_setup_wire_account (const char *payto_uri)
return wm;
}
+
enum GNUNET_GenericReturnValue
TMH_check_auth_config (struct MHD_Connection *connection,
const json_t *jauth,
@@ -218,7 +219,8 @@ TMH_check_auth_config (struct MHD_Connection *connection,
TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_BAD_AUTH,
- "bad authentication config")) ? GNUNET_NO : GNUNET_SYSERR;
+ "bad authentication config")) ?
+ GNUNET_NO : GNUNET_SYSERR;
}
return GNUNET_OK;
}
diff --git a/src/backend/taler-merchant-httpd_private-get-products-ID.c b/src/backend/taler-merchant-httpd_private-get-products-ID.c
index 18d7c78e..48b04499 100644
--- a/src/backend/taler-merchant-httpd_private-get-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-products-ID.c
@@ -37,7 +37,7 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh,
struct TMH_HandlerContext *hc)
{
struct TMH_MerchantInstance *mi = hc->instance;
- struct TALER_MERCHANTDB_ProductDetails pd;
+ struct TALER_MERCHANTDB_ProductDetails pd = { 0 };
enum GNUNET_DB_QueryStatus qs;
GNUNET_assert (NULL != mi);
@@ -65,7 +65,7 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh,
MHD_RESULT ret;
reply = json_pack (
- "{s:s, s:o, s:s, s:o, s:o,"
+ "{s:s, s:o, s:s, s:o, s:s,"
" s:o, s:I, s:I, s:I, s:o}",
"description",
pd.description,
@@ -77,13 +77,13 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh,
TALER_JSON_from_amount (&pd.price),
"image",
pd.image,
+ /* end of first group of 5 */
"taxes",
pd.taxes,
"total_stock",
(INT64_MAX == pd.total_stock)
? (json_int_t) -1
: (json_int_t) pd.total_stock,
- /* end of first group of 5 */
"total_sold",
(json_int_t) pd.total_sold,
"total_lost",
@@ -92,6 +92,7 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh,
pd.address);
GNUNET_assert (NULL != reply);
GNUNET_free (pd.description);
+ GNUNET_free (pd.image);
GNUNET_free (pd.unit);
if (0 != pd.next_restock.abs_value_us)
GNUNET_assert (0 ==
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index ef8d74cf..047582b0 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -556,8 +556,8 @@ run (void *cls,
json_object (),
"can",
"EUR:1",
- "IMAGE-DATA",
- json_object (),
+ "data:image/jpeg;base64,RAWDATA",
+ json_array (),
5,
0,
json_object (),
@@ -938,14 +938,20 @@ run (void *cls,
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-auth-ok",
+ merchant_url,
+ "i1a",
+ 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",
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",
@@ -1504,8 +1510,8 @@ run (void *cls,
json_pack ("{s:s}", "en", "text"),
"kg",
"EUR:1",
- "IMAGE",
- json_object (),
+ "data:image/jpeg;base64,RAWDATA",
+ json_array (),
40,
0,
json_pack ("{s:s}",
@@ -1531,8 +1537,8 @@ run (void *cls,
json_pack ("{s:s}", "en", "text"),
"kg",
"EUR:1",
- "IMAGE",
- json_object (),
+ "data:image/jpeg;base64,RAWDATA",
+ json_array (),
40,
0,
json_pack ("{s:s}",
diff --git a/src/testing/testing_api_cmd_patch_product.c b/src/testing/testing_api_cmd_patch_product.c
index ed64d8f3..fd0b8d49 100644
--- a/src/testing/testing_api_cmd_patch_product.c
+++ b/src/testing/testing_api_cmd_patch_product.c
@@ -275,6 +275,8 @@ TALER_TESTING_cmd_merchant_patch_product (
{
struct PatchProductState *pis;
+ GNUNET_assert ( (NULL == taxes) ||
+ json_is_array (taxes));
pis = GNUNET_new (struct PatchProductState);
pis->merchant_url = merchant_url;
pis->product_id = product_id;
@@ -290,7 +292,8 @@ TALER_TESTING_cmd_merchant_patch_product (
pis->total_stock = total_stock;
pis->total_lost = total_lost;
pis->address = address; /* ownership taken */
- pis->next_restock = next_restock; {
+ pis->next_restock = next_restock;
+ {
struct TALER_TESTING_Command cmd = {
.cls = pis,
.label = label,
diff --git a/src/testing/testing_api_cmd_post_products.c b/src/testing/testing_api_cmd_post_products.c
index 5d1abb48..8216318f 100644
--- a/src/testing/testing_api_cmd_post_products.c
+++ b/src/testing/testing_api_cmd_post_products.c
@@ -269,6 +269,10 @@ TALER_TESTING_cmd_merchant_post_products2 (
{
struct PostProductsState *pis;
+ GNUNET_assert ((NULL == taxes) ||
+ json_is_array (taxes));
+ GNUNET_assert ((NULL == description_i18n) ||
+ json_is_object (description_i18n));
pis = GNUNET_new (struct PostProductsState);
pis->merchant_url = merchant_url;
pis->product_id = product_id;
@@ -315,7 +319,7 @@ TALER_TESTING_cmd_merchant_post_products (const char *label,
"test-unit",
price,
"",
- json_object (),
+ json_array (),
4,
json_pack ("{s:s}", "street", "my street"),
GNUNET_TIME_UNIT_ZERO_ABS,