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 /src/backenddb | |
parent | 69341625aad4b0a1b3642103226f11c2ec4d943c (diff) | |
download | merchant-83c11d7428c6d4ba2e1749630724c39811a24241.tar.gz merchant-83c11d7428c6d4ba2e1749630724c39811a24241.tar.bz2 merchant-83c11d7428c6d4ba2e1749630724c39811a24241.zip |
pull changes
Diffstat (limited to 'src/backenddb')
-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 |
4 files changed, 21 insertions, 21 deletions
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, |