gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] 01/03: update changes


From: gnunet
Subject: [taler-merchant] 01/03: update changes
Date: Tue, 21 Feb 2023 18:54:01 +0100

This is an automated email from the git hooks/post-receive script.

priscilla-huang pushed a commit to branch master
in repository merchant.

commit 9ac6fc8c84748f3de070b44822ec47c4f854bd15
Author: priscilla <priscilla.huang@efrei.net>
AuthorDate: Tue Feb 21 12:39:40 2023 -0500

    update changes
---
 src/backenddb/merchant-0004.sql            |  5 ++++-
 src/backenddb/plugin_merchantdb_postgres.c | 14 +++++++++++++-
 src/backenddb/test_merchantdb.c            |  2 ++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql
index 7c86a636..e74ff1f9 100644
--- a/src/backenddb/merchant-0004.sql
+++ b/src/backenddb/merchant-0004.sql
@@ -32,7 +32,8 @@ 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
-  ,pos_key VARCHAR
+  ,pos_key VARCHAR DEFAULT NULL,
+  ,pos_algorithm INT NOT NULL DEFAULT (0);
   ,template_contract VARCHAR NOT NULL -- in JSON format
   ,UNIQUE (merchant_serial, template_id)
   );
@@ -42,6 +43,8 @@ COMMENT ON COLUMN merchant_template.template_description
   IS 'Human-readable template description';
 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.pos_algorithm
+  IS 'algorithm to used to generate the confirmation code. It is link with the 
pos_key';
 COMMENT ON COLUMN merchant_template.template_contract
   IS 'The template contract will contains some additional information.';
 
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 93d179fa..af028c72 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -6952,6 +6952,7 @@ postgres_insert_template (void *cls,
                           const struct TALER_MERCHANTDB_TemplateDetails *td)
 {
   struct PostgresClosure *pg = cls;
+  uint32_t pos32 = (uint32_t) td->pos_algorithm;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_string (instance_id),
     GNUNET_PQ_query_param_string (template_id),
@@ -6959,6 +6960,7 @@ postgres_insert_template (void *cls,
     (NULL == td->pos_key)
     ? GNUNET_PQ_query_param_null ()
     : GNUNET_PQ_query_param_string (td->pos_key),
+    GNUNET_PQ_query_param_uint32 (&pos32),
     TALER_PQ_query_param_json (td->template_contract),
     GNUNET_PQ_query_param_end
   };
@@ -6988,6 +6990,7 @@ postgres_update_template (void *cls,
                           const struct TALER_MERCHANTDB_TemplateDetails *td)
 {
   struct PostgresClosure *pg = cls;
+  uint32_t pos32 = (uint32_t) td->pos_algorithm;
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_string (instance_id),
     GNUNET_PQ_query_param_string (template_id),
@@ -6995,6 +6998,7 @@ postgres_update_template (void *cls,
     (NULL == td->pos_key)
     ? GNUNET_PQ_query_param_null ()
     : GNUNET_PQ_query_param_string (td->pos_key),
+    GNUNET_PQ_query_param_uint32 (&pos32),
     TALER_PQ_query_param_json (td->template_contract),
     GNUNET_PQ_query_param_end
   };
@@ -7151,6 +7155,7 @@ postgres_lookup_template (void *cls,
   }
   else
   {
+    uint32_t pos32 = (uint32_t) td->pos_algorithm;
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_string ("template_description",
                                     &td->template_description),
@@ -7158,6 +7163,10 @@ postgres_lookup_template (void *cls,
         GNUNET_PQ_result_spec_string ("pos_key",
                                       &td->pos_key),
         NULL),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_uint32 ("pos_algorithm",
+                                      &pos32),
+        NULL),
       TALER_PQ_result_spec_json ("template_contract",
                                  &td->template_contract),
       GNUNET_PQ_result_spec_end
@@ -10378,6 +10387,7 @@ postgres_connect (void *cls)
                             "SELECT"
                             " template_description"
                             ",pos_key"
+                            ",pos_algorithm"
                             ",template_contract"
                             " FROM merchant_template"
                             " JOIN merchant_instances"
@@ -10400,6 +10410,7 @@ postgres_connect (void *cls)
                             ",template_id"
                             ",template_description"
                             ",pos_key"
+                            ",pos_algorithm"
                             ",template_contract"
                             ")"
                             " SELECT merchant_serial,"
@@ -10411,7 +10422,8 @@ postgres_connect (void *cls)
                             "UPDATE merchant_template SET"
                             " template_description=$3"
                             ",pos_key=$4"
-                            ",template_contract=$5"
+                            ",pos_algorithm=$5"
+                            ",template_contract=$6"
                             " WHERE merchant_serial="
                             "   (SELECT merchant_serial"
                             "      FROM merchant_instances"
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 09cccc78..7b51138f 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -6878,6 +6878,7 @@ make_template (const char *id,
   template->id = id;
   template->template.template_description = "This is a test template";
   template->template.pos_key = NULL;
+  template->template.pos_algorithm = 0;
   template->template.template_contract = json_array ();
   GNUNET_assert (NULL != template->template.template_contract);
 }
@@ -6912,6 +6913,7 @@ check_templates_equal (const struct 
TALER_MERCHANTDB_TemplateDetails *a,
       ( (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))) ||
+      ( a->pos_algorithm != b->pos_algorithm ) ||
       (1 != json_equal (a->template_contract,
                         b->template_contract)))
     return 1;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]