[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: more fixes on tests
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: more fixes on tests |
Date: |
Sun, 08 Dec 2024 23:04:01 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 9e348baf more fixes on tests
9e348baf is described below
commit 9e348baffc2a7953014e53e8e3afc9598825922f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Dec 8 23:03:58 2024 +0100
more fixes on tests
---
.../taler-merchant-httpd_private-post-orders.c | 25 ++++++++++++++--------
src/backenddb/merchant-0002.sql | 2 +-
src/backenddb/merchant-0013.sql | 7 ++++++
src/backenddb/pg_insert_token_family_key.c | 23 ++++++++++++++------
src/backenddb/pg_insert_token_family_key.h | 17 +++++++++------
src/backenddb/pg_lookup_token_family_key.c | 4 ++--
src/include/taler_merchantdb_plugin.h | 2 ++
src/testing/test_merchant_instance_auth.sh | 2 +-
8 files changed, 56 insertions(+), 26 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 99a240af..e9abf9db 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1318,10 +1318,11 @@ set_token_family (struct OrderContext *oc,
struct GNUNET_TIME_Timestamp min_valid_after;
struct GNUNET_TIME_Timestamp max_valid_after;
- if (GNUNET_OK != get_rounded_time_interval (precision,
- *valid_after,
- &min_valid_after,
- &max_valid_after))
+ if (GNUNET_OK !=
+ get_rounded_time_interval (precision,
+ *valid_after,
+ &min_valid_after,
+ &max_valid_after))
{
GNUNET_break (0);
reply_with_error (oc,
@@ -1347,10 +1348,10 @@ set_token_family (struct OrderContext *oc,
{
if (GNUNET_TIME_timestamp_cmp (family->keys[i].valid_after,
>=,
- min_valid_after)
- && GNUNET_TIME_timestamp_cmp (family->keys[i].valid_after,
- <,
- max_valid_after))
+ min_valid_after) &&
+ GNUNET_TIME_timestamp_cmp (family->keys[i].valid_after,
+ <,
+ max_valid_after))
{
/* The token family and a matching key is already added. */
*valid_after = family->keys[i].valid_after;
@@ -1383,7 +1384,8 @@ set_token_family (struct OrderContext *oc,
break;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Token family slug unknown\n");
+ "Token family slug %s unknown\n",
+ slug);
http_status = MHD_HTTP_NOT_FOUND;
ec = TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_SLUG_UNKNOWN;
break;
@@ -1505,7 +1507,12 @@ set_token_family (struct OrderContext *oc,
.private_key = priv,
};
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Storing new key for slug %s of %s\n",
+ slug,
+ oc->hc->instance->settings.id);
iqs = TMH_db->insert_token_family_key (TMH_db->cls,
+ oc->hc->instance->settings.id,
slug,
&token_pub,
&token_priv,
diff --git a/src/backenddb/merchant-0002.sql b/src/backenddb/merchant-0002.sql
index 00053cf3..446ebf28 100644
--- a/src/backenddb/merchant-0002.sql
+++ b/src/backenddb/merchant-0002.sql
@@ -76,7 +76,7 @@ CREATE INDEX IF NOT EXISTS
merchant_deposits_by_deposit_confirmation_serial
CREATE TABLE IF NOT EXISTS merchant_token_families
(token_family_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
,merchant_serial BIGINT NOT NULL REFERENCES merchant_instances
(merchant_serial) ON DELETE CASCADE
- ,slug TEXT NOT NULL UNIQUE
+ ,slug TEXT NOT NULL UNIQUE -- Constraint fixed in merchant-0013!
,name TEXT NOT NULL
,description TEXT
,description_i18n BYTEA NOT NULL
diff --git a/src/backenddb/merchant-0013.sql b/src/backenddb/merchant-0013.sql
index 29cbb1e2..1e43de92 100644
--- a/src/backenddb/merchant-0013.sql
+++ b/src/backenddb/merchant-0013.sql
@@ -27,6 +27,13 @@ SELECT _v.register_patch('merchant-0013', NULL, NULL);
SET search_path TO merchant;
+-- Slug was incorrectly set to be globally unique, is only
+-- unique per instance!
+ALTER TABLE merchant_token_families
+ DROP CONSTRAINT merchant_token_families_slug_key,
+ ADD UNIQUE (merchant_serial,slug);
+
+
-- Function to replace placeholders in a string with a given value
CREATE OR REPLACE FUNCTION replace_placeholder(
template TEXT,
diff --git a/src/backenddb/pg_insert_token_family_key.c
b/src/backenddb/pg_insert_token_family_key.c
index 2fcbf026..f862a120 100644
--- a/src/backenddb/pg_insert_token_family_key.c
+++ b/src/backenddb/pg_insert_token_family_key.c
@@ -27,13 +27,16 @@
#include "pg_insert_token_family_key.h"
#include "pg_helper.h"
+
enum GNUNET_DB_QueryStatus
-TMH_PG_insert_token_family_key (void *cls,
- const char *token_family_slug,
- const struct TALER_TokenIssuePublicKeyP *pub,
- const struct TALER_TokenIssuePrivateKeyP *priv,
- const struct GNUNET_TIME_Timestamp valid_after,
- const struct GNUNET_TIME_Timestamp
valid_before)
+TMH_PG_insert_token_family_key (
+ void *cls,
+ const char *merchant_id,
+ const char *token_family_slug,
+ const struct TALER_TokenIssuePublicKeyP *pub,
+ const struct TALER_TokenIssuePrivateKeyP *priv,
+ const struct GNUNET_TIME_Timestamp valid_after,
+ const struct GNUNET_TIME_Timestamp valid_before)
{
struct PostgresClosure *pg = cls;
const char *cipher = NULL;
@@ -53,6 +56,7 @@ TMH_PG_insert_token_family_key (void *cls,
&pub_hash);
break;
case GNUNET_CRYPTO_BSA_INVALID:
+ GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
GNUNET_assert (pub->public_key->cipher ==
@@ -77,7 +81,11 @@ TMH_PG_insert_token_family_key (void *cls,
",cipher)"
" SELECT token_family_serial, $2, $3, $4, $5, $6, $7"
" FROM merchant_token_families"
- " WHERE slug = $1");
+ " WHERE (slug = $1)"
+ " AND merchant_serial="
+ " (SELECT merchant_serial"
+ " FROM merchant_instances"
+ " WHERE merchant_id=$8)");
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (token_family_slug),
@@ -87,6 +95,7 @@ TMH_PG_insert_token_family_key (void *cls,
GNUNET_PQ_query_param_timestamp (&valid_after),
GNUNET_PQ_query_param_timestamp (&valid_before),
GNUNET_PQ_query_param_string (cipher),
+ GNUNET_PQ_query_param_string (merchant_id),
GNUNET_PQ_query_param_end
};
diff --git a/src/backenddb/pg_insert_token_family_key.h
b/src/backenddb/pg_insert_token_family_key.h
index 38e35e0b..cedbf81b 100644
--- a/src/backenddb/pg_insert_token_family_key.h
+++ b/src/backenddb/pg_insert_token_family_key.h
@@ -27,7 +27,10 @@
/**
+ * Insert new key pair for a token family.
+ *
* @param cls closure
+ * @param merchant_id instance name
* @param token_family_slug slug of the token family to insert the key for
* @param pub public key to insert
* @param priv private key to insert
@@ -36,11 +39,13 @@
* @return database result code
*/
enum GNUNET_DB_QueryStatus
-TMH_PG_insert_token_family_key (void *cls,
- const char *token_family_slug,
- const struct TALER_TokenIssuePublicKeyP *pub,
- const struct TALER_TokenIssuePrivateKeyP *priv,
- const struct GNUNET_TIME_Timestamp valid_after,
- const struct GNUNET_TIME_Timestamp
valid_before);
+TMH_PG_insert_token_family_key (
+ void *cls,
+ const char *merchant_id,
+ const char *token_family_slug,
+ const struct TALER_TokenIssuePublicKeyP *pub,
+ const struct TALER_TokenIssuePrivateKeyP *priv,
+ const struct GNUNET_TIME_Timestamp valid_after,
+ const struct GNUNET_TIME_Timestamp valid_before);
#endif
diff --git a/src/backenddb/pg_lookup_token_family_key.c
b/src/backenddb/pg_lookup_token_family_key.c
index 40e592cf..61ae93fb 100644
--- a/src/backenddb/pg_lookup_token_family_key.c
+++ b/src/backenddb/pg_lookup_token_family_key.c
@@ -55,8 +55,8 @@ TMH_PG_lookup_token_family_key (
",pub"
",priv"
",cipher"
- ",merchant_token_family_keys.valid_after as key_valid_after"
- ",merchant_token_family_keys.valid_before as key_valid_before"
+ ",merchant_token_family_keys.valid_after AS key_valid_after"
+ ",merchant_token_family_keys.valid_before AS key_valid_before"
",slug"
",name"
",description"
diff --git a/src/include/taler_merchantdb_plugin.h
b/src/include/taler_merchantdb_plugin.h
index 84ced310..3c3d6cb3 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -3759,6 +3759,7 @@ struct TALER_MERCHANTDB_Plugin
* Insert details a key pair for a token family.
*
* @param cls closure
+ * @param merchant_id instance name
* @param token_family_slug slug of token family to insert the key pair for
* @param pub token family public key
* @param priv token family private key
@@ -3769,6 +3770,7 @@ struct TALER_MERCHANTDB_Plugin
enum GNUNET_DB_QueryStatus
(*insert_token_family_key)(
void *cls,
+ const char *merchant_id,
const char *token_family_slug,
const struct TALER_TokenIssuePublicKeyP *pub,
const struct TALER_TokenIssuePrivateKeyP *priv,
diff --git a/src/testing/test_merchant_instance_auth.sh
b/src/testing/test_merchant_instance_auth.sh
index f0b6adf9..f0ae0c3d 100755
--- a/src/testing/test_merchant_instance_auth.sh
+++ b/src/testing/test_merchant_instance_auth.sh
@@ -71,7 +71,7 @@ unset SETUP_PID
setup -c test_template.conf \
-ef \
-u "exchange-account-2" \
- -m "merchant-exchange-default"
+ -r "merchant-exchange-default"
NEW_SECRET=secret-token:different_value
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: more fixes on tests,
gnunet <=