diff options
author | priscilla <priscilla.huang@efrei.net> | 2023-02-20 04:40:12 -0500 |
---|---|---|
committer | priscilla <priscilla.huang@efrei.net> | 2023-02-20 12:19:40 -0500 |
commit | 83c11d7428c6d4ba2e1749630724c39811a24241 (patch) | |
tree | f9b51c1c2b718166185a8d5338d21271996c2358 | |
parent | 69341625aad4b0a1b3642103226f11c2ec4d943c (diff) |
pull changes
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-templates-ID.c | 6 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-patch-templates-ID.c | 14 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-templates.c | 19 | ||||
-rw-r--r-- | src/backenddb/merchant-0004.sql | 6 | ||||
-rw-r--r-- | src/backenddb/merchantdb_helper.c | 2 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 20 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 14 | ||||
-rw-r--r-- | src/include/taler_merchant_testing_lib.h | 2 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 4 | ||||
-rw-r--r-- | src/lib/merchant_api_get_template.c | 8 | ||||
-rw-r--r-- | src/lib/merchant_api_patch_template.c | 6 | ||||
-rw-r--r-- | src/lib/merchant_api_post_templates.c | 6 |
12 files changed, 42 insertions, 65 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-templates-ID.c b/src/backend/taler-merchant-httpd_private-get-templates-ID.c index 953582ca..f15a03f8 100644 --- a/src/backend/taler-merchant-httpd_private-get-templates-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-templates-ID.c @@ -69,12 +69,12 @@ TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_pack_string ("template_description", tp.template_description), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("image", - tp.image)), + GNUNET_JSON_pack_string ("pos_key", + tp.pos_key)), GNUNET_JSON_pack_object_steal ("template_contract", tp.template_contract)); GNUNET_free (tp.template_description); - GNUNET_free (tp.image); + GNUNET_free (tp.pos_key); return ret; } diff --git a/src/backend/taler-merchant-httpd_private-patch-templates-ID.c b/src/backend/taler-merchant-httpd_private-patch-templates-ID.c index b1116f62..57c6dd95 100644 --- a/src/backend/taler-merchant-httpd_private-patch-templates-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-templates-ID.c @@ -113,8 +113,8 @@ TMH_private_patch_templates_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_spec_string ("template_description", (const char **) &tp.template_description), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_string ("image", - (const char **) &tp.image), + GNUNET_JSON_spec_string ("pos_key", + (const char **) &tp.pos_key), NULL), GNUNET_JSON_spec_json ("template_contract", &tp.template_contract), @@ -145,16 +145,6 @@ TMH_private_patch_templates_ID (const struct TMH_RequestHandler *rh, "template_contract"); } - if ((NULL != tp.image) && (! TMH_image_data_url_valid (tp.image))) - { - 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, - "image"); - } - qs = TMH_db->update_template (TMH_db->cls, mi->settings.id, template_id, diff --git a/src/backend/taler-merchant-httpd_private-post-templates.c b/src/backend/taler-merchant-httpd_private-post-templates.c index 9cc33eaa..91f8c182 100644 --- a/src/backend/taler-merchant-httpd_private-post-templates.c +++ b/src/backend/taler-merchant-httpd_private-post-templates.c @@ -47,10 +47,8 @@ templates_equal (const struct TALER_MERCHANTDB_TemplateDetails *t1, { return ( (0 == strcmp (t1->template_description, t2->template_description)) && - ( ( (NULL == t1->image) && (NULL == t2->image) ) || - ( (NULL != t1->image) && (NULL != t2->image) && - (0 == strcmp (t1->image, - t2->image)) ) ) && + (0 == strcmp (t1->pos_key, + t2->pos_key) ) && (1 == json_equal (t1->template_contract, t2->template_contract)) ); } @@ -72,7 +70,7 @@ TMH_private_post_templates (const struct TMH_RequestHandler *rh, (const char **) &tp.template_description), GNUNET_JSON_spec_mark_optional( GNUNET_JSON_spec_string ("image", - (const char **) &tp.image), + (const char **) &tp.pos_key), NULL), GNUNET_JSON_spec_json ("template_contract", &tp.template_contract), @@ -107,17 +105,6 @@ TMH_private_post_templates (const struct TMH_RequestHandler *rh, "template_contract"); } - if ( (NULL != tp.image) && - (! TMH_image_data_url_valid (tp.image)) ) - { - 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, - "image"); - } - /* finally, interact with DB until no serialization error */ for (unsigned int i = 0; i<MAX_RETRIES; i++) { diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql index b63594ee..3864f37d 100644 --- a/src/backenddb/merchant-0004.sql +++ b/src/backenddb/merchant-0004.sql @@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS merchant_template REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE ,template_id VARCHAR NOT NULL ,template_description VARCHAR NOT NULL - ,image BYTEA + ,pos_key VARCHAR ,template_contract VARCHAR NOT NULL -- in JSON format ,UNIQUE (merchant_serial, template_id) ); @@ -42,8 +42,8 @@ COMMENT ON TABLE merchant_template IS 'template used by the merchant (may be incomplete, frontend can override)'; COMMENT ON COLUMN merchant_template.template_description IS 'Human-readable template description'; -COMMENT ON COLUMN merchant_template.image - IS 'NOT NULL, but can be 0 bytes; must contain an ImageDataUrl'; +COMMENT ON COLUMN merchant_template.pos_key + IS 'A base64-encoded key of the point-of-sale. It will be use by the TOTP'; COMMENT ON COLUMN merchant_template.template_contract IS 'The template contract will contains some additional information.'; diff --git a/src/backenddb/merchantdb_helper.c b/src/backenddb/merchantdb_helper.c index 0a49f5d6..dc59572c 100644 --- a/src/backenddb/merchantdb_helper.c +++ b/src/backenddb/merchantdb_helper.c @@ -43,7 +43,7 @@ TALER_MERCHANTDB_template_details_free ( struct TALER_MERCHANTDB_TemplateDetails *tp) { GNUNET_free (tp->template_description); - GNUNET_free (tp->image); + GNUNET_free (tp->pos_key); json_decref (tp->template_contract); } diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 9f07d3aa..836eb07a 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -6875,9 +6875,9 @@ postgres_insert_template (void *cls, GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (template_id), GNUNET_PQ_query_param_string (td->template_description), - (NULL == td->image) + (NULL == td->pos_key) ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string (td->image), + : GNUNET_PQ_query_param_string (td->pos_key), TALER_PQ_query_param_json (td->template_contract), GNUNET_PQ_query_param_end }; @@ -6911,9 +6911,9 @@ postgres_update_template (void *cls, GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (template_id), GNUNET_PQ_query_param_string (td->template_description), - (NULL == td->image) + (NULL == td->pos_key) ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string (td->image), + : GNUNET_PQ_query_param_string (td->pos_key), TALER_PQ_query_param_json (td->template_contract), GNUNET_PQ_query_param_end }; @@ -7074,8 +7074,8 @@ postgres_lookup_template (void *cls, GNUNET_PQ_result_spec_string ("template_description", &td->template_description), GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("image", - &td->image), + GNUNET_PQ_result_spec_string ("pos_key", + &td->pos_key), NULL), TALER_PQ_result_spec_json ("template_contract", &td->template_contract), @@ -7083,7 +7083,7 @@ postgres_lookup_template (void *cls, }; check_connection (pg); - td->image = NULL; + td->pos_key = NULL; return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "lookup_template", params, @@ -10274,7 +10274,7 @@ postgres_connect (void *cls) GNUNET_PQ_make_prepare ("lookup_template", "SELECT" " template_description" - ",image" + ",pos_key" ",template_contract" " FROM merchant_template" " JOIN merchant_instances" @@ -10296,7 +10296,7 @@ postgres_connect (void *cls) "(merchant_serial" ",template_id" ",template_description" - ",image" + ",pos_key" ",template_contract" ")" " SELECT merchant_serial," @@ -10307,7 +10307,7 @@ postgres_connect (void *cls) GNUNET_PQ_make_prepare ("update_template", "UPDATE merchant_template SET" " template_description=$3" - ",image=$4" + ",pos_key=$4" ",template_contract=$5" " WHERE merchant_serial=" " (SELECT merchant_serial" diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 346a5427..5a84e8b2 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -6875,7 +6875,7 @@ make_template (const char *id, { template->id = id; template->template.template_description = "This is a test template"; - template->template.image = NULL; + template->template.pos_key = NULL; template->template.template_contract = json_array (); GNUNET_assert (NULL != template->template.template_contract); } @@ -6889,7 +6889,7 @@ make_template (const char *id, static void free_template_data (struct TemplateData *template) { - GNUNET_free (template->template.image); + GNUNET_free (template->template.pos_key); json_decref (template->template.template_contract); } @@ -6907,9 +6907,9 @@ check_templates_equal (const struct TALER_MERCHANTDB_TemplateDetails *a, { if ((0 != strcmp (a->template_description, b->template_description)) || - ( (NULL == a->image) && (NULL != b->image)) || - ( (NULL != a->image) && (NULL == b->image)) || - ( (NULL != a->image) && (0 != strcmp (a->image, b->image))) || + ( (NULL == a->pos_key) && (NULL != b->pos_key)) || + ( (NULL != a->pos_key) && (NULL == b->pos_key)) || + ( (NULL != a->pos_key) && (0 != strcmp (a->pos_key, b->pos_key))) || (1 != json_equal (a->template_contract, b->template_contract))) return 1; @@ -7220,8 +7220,8 @@ run_test_templates (struct TestTemplates_Closure *cls) /* Test template update */ cls->templates[0].template.template_description = "This is a test template that has been updated!"; - GNUNET_free (cls->templates[0].template.image); - cls->templates[0].template.image = GNUNET_strdup ("image"); + GNUNET_free (cls->templates[0].template.pos_key); + cls->templates[0].template.pos_key = GNUNET_strdup ("pos_key"); GNUNET_assert (0 == json_array_append_new ( cls->templates[0].template.template_contract, diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index 1039d2ef..02f386c4 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -1866,7 +1866,7 @@ TALER_TESTING_cmd_checkserver2 (const char *label, op (h_wire, const struct TALER_MerchantWireHashP) \ op (proposal_reference, const char *) \ op (template_description, const char *) \ - op (template_image, const char *) \ + op (template_pos_key, const char *) \ op (template_id, const char *) \ op (template_contract, const json_t) \ op (event_type, const char *) \ diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 4168fffc..dc44ba86 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -327,9 +327,9 @@ struct TALER_MERCHANTDB_TemplateDetails char *template_description; /** - * Base64-encoded image, or NULL. + * Base64-encoded key, or NULL. */ - char *image; + char *pos_key; /** * In this template contract, we can have additional information. diff --git a/src/lib/merchant_api_get_template.c b/src/lib/merchant_api_get_template.c index 920333b6..3edb98a1 100644 --- a/src/lib/merchant_api_get_template.c +++ b/src/lib/merchant_api_get_template.c @@ -93,15 +93,15 @@ handle_get_template_finished (void *cls, case MHD_HTTP_OK: { const char *template_description; - const char *image; + const char *pos_key; json_t *template_contract; bool rst_ok = true; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("template_description", &template_description), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_string ("image", - &image), + GNUNET_JSON_spec_string ("pos_key", + &pos_key), NULL), GNUNET_JSON_spec_json ("template_contract", &template_contract), @@ -118,7 +118,7 @@ handle_get_template_finished (void *cls, tgh->cb (tgh->cb_cls, &hr, template_description, - image, + pos_key, template_contract); GNUNET_JSON_parse_free (spec); TALER_MERCHANT_template_get_cancel (tgh); diff --git a/src/lib/merchant_api_patch_template.c b/src/lib/merchant_api_patch_template.c index 44357cc0..5034101d 100644 --- a/src/lib/merchant_api_patch_template.c +++ b/src/lib/merchant_api_patch_template.c @@ -162,7 +162,7 @@ TALER_MERCHANT_template_patch ( const char *backend_url, const char *template_id, const char *template_description, - const char *image, + const char *pos_key, json_t *template_contract, TALER_MERCHANT_TemplatePatchCallback cb, void *cb_cls) @@ -174,8 +174,8 @@ TALER_MERCHANT_template_patch ( GNUNET_JSON_pack_string ("template_description", template_description), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("image", - image)), + GNUNET_JSON_pack_string ("pos_key", + pos_key)), GNUNET_JSON_pack_object_incref ("template_contract", (json_t *) template_contract)); tph = GNUNET_new (struct TALER_MERCHANT_TemplatePatchHandle); diff --git a/src/lib/merchant_api_post_templates.c b/src/lib/merchant_api_post_templates.c index 9592a5e3..735368db 100644 --- a/src/lib/merchant_api_post_templates.c +++ b/src/lib/merchant_api_post_templates.c @@ -199,7 +199,7 @@ TALER_MERCHANT_templates_post ( const char *backend_url, const char *template_id, const char *template_description, - const char *image, + const char *pos_key, const json_t *template_contract, TALER_MERCHANT_TemplatesPostCallback cb, void *cb_cls) @@ -218,8 +218,8 @@ TALER_MERCHANT_templates_post ( GNUNET_JSON_pack_string ("template_description", template_description), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("image", - image)), + GNUNET_JSON_pack_string ("pos_key", + pos_key)), GNUNET_JSON_pack_object_incref ("template_contract", (json_t *) template_contract)); tph = GNUNET_new (struct TALER_MERCHANT_TemplatesPostHandle); |