merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 0a164d09483349ff3f4a60d16b763593fdcdb178
parent 20c364adc4f246a06a07b859c647f4e705dc3e42
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Tue, 10 Dec 2024 16:11:36 +0100

Merge branch 'master' into dev/bohdan-potuzhnyi/donau-integration

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 2+-
Msrc/backend/taler-merchant-httpd_contract.h | 2+-
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 8++++----
Msrc/backend/taler-merchant-httpd_private-get-transfers.c | 2+-
Msrc/backend/taler-merchant-httpd_private-post-orders.c | 72++++++++++++++++++++++++++++++++++++++++--------------------------------
Msrc/backenddb/merchant-0002.sql | 2+-
Msrc/backenddb/merchant-0013.sql | 7+++++++
Msrc/backenddb/pg_insert_issued_token.c | 2+-
Msrc/backenddb/pg_insert_issued_token.h | 2+-
Msrc/backenddb/pg_insert_spent_token.c | 2+-
Msrc/backenddb/pg_insert_spent_token.h | 2+-
Msrc/backenddb/pg_insert_token_family_key.c | 23++++++++++++++++-------
Msrc/backenddb/pg_insert_token_family_key.h | 17+++++++++++------
Msrc/backenddb/pg_lookup_spent_tokens_by_order.c | 2+-
Msrc/backenddb/pg_lookup_token_family_key.c | 4++--
Msrc/include/taler_merchant_service.h | 16++++++++--------
Msrc/include/taler_merchant_testing_lib.h | 4++--
Msrc/include/taler_merchantdb_plugin.h | 18++++++++++--------
Msrc/testing/Makefile.am | 5+++++
Msrc/testing/test_kyc_api.c | 1+
Msrc/testing/test_merchant_api.c | 1+
Msrc/testing/test_merchant_api_twisted.c | 1+
Msrc/testing/test_merchant_instance_auth.sh | 24++++++++++++++++++++----
Msrc/testing/test_merchant_kyc.sh | 6+++++-
Msrc/testing/test_merchant_order_autocleanup.sh | 1+
Msrc/testing/test_merchant_order_creation.sh | 1+
Msrc/testing/test_merchant_order_refund.sh | 5+++--
Msrc/testing/test_merchant_product_creation.sh | 1+
Msrc/testing/test_merchant_transfer_tracking.sh | 1+
Msrc/testing/test_merchant_wirewatch.sh | 1+
Msrc/testing/testing_api_cmd_pay_order.c | 6+++---
Msrc/util/os_installation.c | 2+-
32 files changed, 154 insertions(+), 89 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -2345,7 +2345,7 @@ run (void *cls, "FORCE_AUDIT")) TMH_force_audit = GNUNET_YES; if (GNUNET_OK != - TALER_TEMPLATING_init (TALER_EXCHANGE_project_data ())) + TALER_TEMPLATING_init (TALER_MERCHANT_project_data ())) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to setup templates\n"); diff --git a/src/backend/taler-merchant-httpd_contract.h b/src/backend/taler-merchant-httpd_contract.h @@ -261,7 +261,7 @@ struct TALER_MerchantContractTokenFamilyKey /** * Public key. */ - struct TALER_TokenIssuePublicKeyP pub; + struct TALER_TokenIssuePublicKey pub; /** * Tokens signed by this key will be valid after this time. diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -258,7 +258,7 @@ struct TokenUseConfirmation /** * Unblinded signature on the token use public key done by the merchant. */ - struct TALER_TokenIssueSignatureP unblinded_sig; + struct TALER_TokenIssueSignature unblinded_sig; /** * Hash of the token issue public key associated with this token. @@ -297,7 +297,7 @@ struct SignedOutputToken /** * Blinded token use public keys waiting to be signed. */ - struct TALER_TokenIssueBlindSignatureP sig; + struct TALER_BlindedTokenIssueSignature sig; /** * Hash of token issue public key. @@ -2553,7 +2553,7 @@ find_valid_input_tokens (struct PayContext *pc, static enum GNUNET_GenericReturnValue sign_token_envelopes (struct PayContext *pc, struct TALER_MerchantContractTokenFamilyKey *key, - struct TALER_TokenIssuePrivateKeyP *priv, + struct TALER_TokenIssuePrivateKey *priv, bool critical, unsigned int index, unsigned int expected_num) @@ -2874,7 +2874,7 @@ input_tokens_paid_check ( const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig) + const struct TALER_TokenIssueSignature *issue_sig) { struct PayContext *pc = cls; diff --git a/src/backend/taler-merchant-httpd_private-get-transfers.c b/src/backend/taler-merchant-httpd_private-get-transfers.c @@ -116,7 +116,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, { payto_uri.full_payto = GNUNET_strdup (esc_payto); - MHD_http_unescape (payto_uri.full_payto); + (void) MHD_http_unescape (payto_uri.full_payto); } } { diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -898,14 +898,11 @@ execute_transaction (struct OrderContext *oc) oc->hc->instance->settings.id) ); GNUNET_assert (NULL != jhook); - wqs = TMH_trigger_webhook (oc->hc->instance->settings.id, "order_created", jhook); - json_decref (jhook); - - if (0 < wqs) + if (0 > wqs) { TMH_db->rollback (TMH_db->cls); if (GNUNET_DB_STATUS_SOFT_ERROR == wqs) @@ -1321,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, @@ -1343,17 +1341,16 @@ set_token_family (struct OrderContext *oc, break; } } - if (NULL != family) { for (unsigned int i = 0; i<family->keys_len; i++) { 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; @@ -1368,6 +1365,8 @@ set_token_family (struct OrderContext *oc, min_valid_after, max_valid_after, &key_details); + /* slug is not needed */ + GNUNET_free (key_details.token_family.slug); if (qs <= 0) { @@ -1377,16 +1376,19 @@ set_token_family (struct OrderContext *oc, switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; ec = TALER_EC_GENERIC_DB_FETCH_FAILED; break; case GNUNET_DB_STATUS_SOFT_ERROR: + GNUNET_break (0); http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; 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; @@ -1394,11 +1396,10 @@ set_token_family (struct OrderContext *oc, /* case listed to make compilers happy */ GNUNET_assert (0); } - GNUNET_break (0); reply_with_error (oc, http_status, ec, - "token_family_slug"); + slug); return GNUNET_SYSERR; } @@ -1406,27 +1407,26 @@ set_token_family (struct OrderContext *oc, struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get (); /* Verify that the token family is valid right now. */ - if (GNUNET_TIME_timestamp_cmp (key_details.token_family.valid_after, >, now) - || - GNUNET_TIME_timestamp_cmp (key_details.token_family.valid_before, <=, - now) - ) + if (GNUNET_TIME_timestamp_cmp (key_details.token_family.valid_after, + >, + now) || + GNUNET_TIME_timestamp_cmp (key_details.token_family.valid_before, + <=, + now)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Token family expired or not yet valid\n"); + "Token family %s expired or not yet valid\n", + slug); reply_with_error (oc, /* TODO: HTTP Status Code GONE would be more elegant, but that is already used to indicate that a product is out of stock. */ MHD_HTTP_CONFLICT, TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_NOT_VALID, - key_details.token_family.slug); + slug); return GNUNET_SYSERR; } } - /* slug is not needed */ - GNUNET_free (key_details.token_family.slug); - { struct TALER_MerchantContractTokenFamilyKey key; @@ -1501,21 +1501,25 @@ set_token_family (struct OrderContext *oc, GNUNET_CRYPTO_BSA_RSA, 4096); { - struct TALER_TokenIssuePublicKeyP token_pub = { + struct TALER_TokenIssuePublicKey token_pub = { .public_key = pub, }; - struct TALER_TokenIssuePrivateKeyP token_priv = { + struct TALER_TokenIssuePrivateKey token_priv = { .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, min_valid_after, valid_before); GNUNET_CRYPTO_blind_sign_priv_decref (priv); - if (iqs <= 0) { enum TALER_ErrorCode ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; @@ -1524,20 +1528,24 @@ set_token_family (struct OrderContext *oc, switch (iqs) { case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; ec = TALER_EC_GENERIC_DB_STORE_FAILED; break; case GNUNET_DB_STATUS_SOFT_ERROR: - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + GNUNET_break (0); http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + GNUNET_break (0); + http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; + ec = TALER_EC_GENERIC_DB_STORE_FAILED; + break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: /* case listed to make compilers happy */ GNUNET_assert (0); } - - GNUNET_break (0); reply_with_error (oc, http_status, ec, diff --git 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 @@ -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_issued_token.c b/src/backenddb/pg_insert_issued_token.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_insert_issued_token (void *cls, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenIssueBlindSignatureP *blind_sig) + const struct TALER_BlindedTokenIssueSignature *blind_sig) { struct PostgresClosure *pg = cls; diff --git a/src/backenddb/pg_insert_issued_token.h b/src/backenddb/pg_insert_issued_token.h @@ -37,6 +37,6 @@ enum GNUNET_DB_QueryStatus TMH_PG_insert_issued_token (void *cls, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenIssueBlindSignatureP *blind_sig); + const struct TALER_BlindedTokenIssueSignature *blind_sig); #endif diff --git a/src/backenddb/pg_insert_spent_token.c b/src/backenddb/pg_insert_spent_token.c @@ -33,7 +33,7 @@ TMH_PG_insert_spent_token ( const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig) + const struct TALER_TokenIssueSignature *issue_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { diff --git a/src/backenddb/pg_insert_spent_token.h b/src/backenddb/pg_insert_spent_token.h @@ -42,6 +42,6 @@ TMH_PG_insert_spent_token ( const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig); + const struct TALER_TokenIssueSignature *issue_sig); #endif diff --git 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_TokenIssuePublicKey *pub, + const struct TALER_TokenIssuePrivateKey *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 @@ -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_TokenIssuePublicKey *pub, + const struct TALER_TokenIssuePrivateKey *priv, + const struct GNUNET_TIME_Timestamp valid_after, + const struct GNUNET_TIME_Timestamp valid_before); #endif diff --git a/src/backenddb/pg_lookup_spent_tokens_by_order.c b/src/backenddb/pg_lookup_spent_tokens_by_order.c @@ -76,7 +76,7 @@ lookup_spent_tokens_by_order_cb (void *cls, struct TALER_TokenIssuePublicKeyHashP h_issue_pub; struct TALER_TokenUsePublicKeyP use_pub; struct TALER_TokenUseSignatureP use_sig; - struct TALER_TokenIssueSignatureP issue_sig; + struct TALER_TokenIssueSignature issue_sig; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("spent_token_serial", &spent_token_serial), diff --git 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_merchant_service.h b/src/include/taler_merchant_service.h @@ -3167,17 +3167,17 @@ struct TALER_MERCHANT_PrivateTokenDetails /** * Token issue public key. */ - struct TALER_TokenIssuePublicKeyP issue_pub; + struct TALER_TokenIssuePublicKey issue_pub; /** * Unblinded token issue signature made by the merchant. */ - struct TALER_TokenIssueSignatureP issue_sig; + struct TALER_TokenIssueSignature issue_sig; /** * Blinded token issue signature made by the merchant. */ - struct TALER_TokenIssueBlindSignatureP blinded_sig; + struct TALER_BlindedTokenIssueSignature blinded_sig; }; @@ -3343,12 +3343,12 @@ struct TALER_MERCHANT_UsedToken /** * Unblinded signature made by the token issue public key of the merchant. */ - struct TALER_TokenIssueSignatureP ub_sig; + struct TALER_TokenIssueSignature ub_sig; /** * Token issue public key associated with this token. */ - struct TALER_TokenIssuePublicKeyP issue_pub; + struct TALER_TokenIssuePublicKey issue_pub; }; @@ -3369,7 +3369,7 @@ struct TALER_MERCHANT_OutputToken /** * Blinded issue signature made by the merchant. */ - struct TALER_TokenIssueBlindSignatureP blinded_sig; + struct TALER_BlindedTokenIssueSignature blinded_sig; }; @@ -3475,12 +3475,12 @@ struct TALER_MERCHANT_UseToken /** * Unblinded signature made by the token issue public key of the merchant. */ - struct TALER_TokenIssueSignatureP ub_sig; + struct TALER_TokenIssueSignature ub_sig; /** * Token issue public key associated with this token. */ - struct TALER_TokenIssuePublicKeyP issue_pub; + struct TALER_TokenIssuePublicKey issue_pub; }; diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -1886,8 +1886,8 @@ TALER_TESTING_cmd_merchant_get_donau_instances(const char *label, op (http_body_size, const size_t) \ op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ op (token_priv, const struct TALER_TokenUsePrivateKeyP) \ - op (token_issue_sig, const struct TALER_TokenIssueSignatureP) \ - op (token_issue_pub, const struct TALER_TokenIssuePublicKeyP) + op (token_issue_sig, const struct TALER_TokenIssueSignature) \ + op (token_issue_pub, const struct TALER_TokenIssuePublicKey) TALER_MERCHANT_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT) diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -1269,12 +1269,12 @@ struct TALER_MERCHANTDB_TokenFamilyKeyDetails /** * Token family public key. */ - struct TALER_TokenIssuePublicKeyP pub; + struct TALER_TokenIssuePublicKey pub; /** * Token family private key. */ - struct TALER_TokenIssuePrivateKeyP priv; + struct TALER_TokenIssuePrivateKey priv; /** * Details about the token family this key belongs to. @@ -1300,7 +1300,7 @@ struct TALER_MERCHANTDB_SpentTokenDetails /** * Blind signature for the spent token to prove validity of it. */ - struct TALER_TokenIssueBlindSignatureP blind_sig; + struct TALER_BlindedTokenIssueSignature blind_sig; }; @@ -1323,7 +1323,7 @@ typedef void const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig); + const struct TALER_TokenIssueSignature *issue_sig); /** * Handle to interact with the database. @@ -2727,7 +2727,7 @@ struct TALER_MERCHANTDB_Plugin const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, const struct TALER_TokenUsePublicKeyP *use_pub, const struct TALER_TokenUseSignatureP *use_sig, - const struct TALER_TokenIssueSignatureP *issue_sig); + const struct TALER_TokenIssueSignature *issue_sig); /** @@ -2744,7 +2744,7 @@ struct TALER_MERCHANTDB_Plugin void *cls, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_TokenIssuePublicKeyHashP *h_issue_pub, - const struct TALER_TokenIssueBlindSignatureP *blind_sig); + const struct TALER_BlindedTokenIssueSignature *blind_sig); /** @@ -3764,6 +3764,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 @@ -3774,9 +3775,10 @@ 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, + const struct TALER_TokenIssuePublicKey *pub, + const struct TALER_TokenIssuePrivateKey *priv, struct GNUNET_TIME_Timestamp valid_after, struct GNUNET_TIME_Timestamp valid_before); diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am @@ -124,6 +124,7 @@ test_merchant_api_twisted_cs_SOURCES = \ test_merchant_api_twisted_cs_LDADD = \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(LIBGCRYPT_LIBS) \ -ltalertesting \ -ltalermerchanttesting \ @@ -145,6 +146,7 @@ test_merchant_api_twisted_rsa_SOURCES = \ test_merchant_api_twisted_rsa_LDADD = \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(LIBGCRYPT_LIBS) \ -ltalertesting \ -ltalermerchanttesting \ @@ -167,6 +169,7 @@ test_merchant_api_cs_LDADD = \ libtalermerchanttesting.la \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(LIBGCRYPT_LIBS) \ -ltalertesting \ -ltalerfakebank \ @@ -184,6 +187,7 @@ test_merchant_api_rsa_SOURCES = \ test_merchant_api.c test_merchant_api_rsa_LDADD = \ libtalermerchanttesting.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ $(LIBGCRYPT_LIBS) \ @@ -203,6 +207,7 @@ test_kyc_api_SOURCES = \ test_kyc_api.c test_kyc_api_LDADD = \ libtalermerchanttesting.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ $(LIBGCRYPT_LIBS) \ diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c @@ -502,6 +502,7 @@ run (void *cls, CONFIG_FILE, "-ema", "-u", "exchange-account-exchange", + "-r", "merchant-exchange-test", NULL), TALER_TESTING_cmd_get_exchange ( "get-exchange", diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -1833,6 +1833,7 @@ run (void *cls, config_file, "-ema", "-u", "exchange-account-exchange", + "-r", "merchant-exchange-test", NULL), TALER_TESTING_cmd_get_exchange ( "get-exchange", diff --git a/src/testing/test_merchant_api_twisted.c b/src/testing/test_merchant_api_twisted.c @@ -324,6 +324,7 @@ run (void *cls, config_file, "-ema", "-u", "exchange-account-exchange", + "-r", "merchant-exchange-test", NULL), TALER_TESTING_cmd_get_exchange ("get-exchange", cred.cfg, diff --git a/src/testing/test_merchant_instance_auth.sh b/src/testing/test_merchant_instance_auth.sh @@ -68,12 +68,22 @@ kill -TERM "$SETUP_PID" wait unset SETUP_PID -setup -c test_template.conf -ef -u "exchange-account-2" +setup -c test_template.conf \ + -ef \ + -u "exchange-account-2" \ + -r "merchant-exchange-default" NEW_SECRET=secret-token:different_value -taler-merchant-exchangekeyupdate -c "${CONF}" -L DEBUG 2> taler-merchant-exchangekeyupdate.log & -taler-merchant-httpd -a "${NEW_SECRET}" -c "${CONF}" -L DEBUG 2> taler-merchant-httpd.log & +taler-merchant-exchangekeyupdate \ + -c "${CONF}" \ + -L DEBUG \ + 2> taler-merchant-exchangekeyupdate2.log & +taler-merchant-httpd \ + -a "${NEW_SECRET}" \ + -c "${CONF}" \ + -L DEBUG \ + 2> taler-merchant-httpd2.log & # Install cleanup handler (except for kill -9) trap my_cleanup EXIT @@ -85,7 +95,12 @@ do sleep 0.1 OK=0 # merchant - wget --waitretry=0 --timeout=1 http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue + wget --waitretry=0 \ + --timeout=1 \ + http://localhost:9966/ \ + -o /dev/null \ + -O /dev/null \ + >/dev/null || continue OK=1 break done @@ -95,6 +110,7 @@ then exit_fail "Failed to (re)start merchant backend" fi + echo -n "Creating order to test auth is ok..." >&2 STATUS=$(curl -H "Content-Type: application/json" -X POST \ 'http://localhost:9966/private/orders' \ diff --git a/src/testing/test_merchant_kyc.sh b/src/testing/test_merchant_kyc.sh @@ -22,7 +22,11 @@ set -eu # Launch system. -setup -c "test_template.conf" -mef -u "exchange-account-2" +setup \ + -c "test_template.conf" \ + -mef \ + -r "merchant-exchange-default" \ + -u "exchange-account-2" LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) echo -n "Configuring a merchant default instance ..." diff --git a/src/testing/test_merchant_order_autocleanup.sh b/src/testing/test_merchant_order_autocleanup.sh @@ -31,6 +31,7 @@ echo " FOUND" # Launch exchange, merchant and bank. setup -c "test_template.conf" \ + -r "merchant-exchange-default" \ -em \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh @@ -34,6 +34,7 @@ echo " FOUND" # Launch exchange, merchant and bank. setup -c "test_template.conf" \ + -r "merchant-exchange-default" \ -em \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) diff --git a/src/testing/test_merchant_order_refund.sh b/src/testing/test_merchant_order_refund.sh @@ -36,6 +36,7 @@ echo " FOUND" # Launch exchange, merchant and bank. setup -c "test_template.conf" \ -em \ + -r "merchant-exchange-default" \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) CONF="test_template.conf.edited" @@ -192,7 +193,7 @@ echo Sending refund for TESTKUDOS:1 STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}/refund" \ -d '{"refund":"TESTKUDOS:1","reason":"duplicated"}' \ -w "%{http_code}" -s -o "$LAST_RESPONSE") - + if [ "$STATUS" != "200" ] then jq . < "$LAST_RESPONSE" @@ -214,7 +215,7 @@ echo Increasing refund for TESTKUDOS:3 STATUS=$(curl "http://localhost:9966/private/orders/${ORDER_ID}/refund" \ -d '{"refund":"TESTKUDOS:5","reason":"duplicated"}' \ -w "%{http_code}" -s -o "$LAST_RESPONSE") - + if [ "$STATUS" != "200" ] then jq . < "$LAST_RESPONSE" diff --git a/src/testing/test_merchant_product_creation.sh b/src/testing/test_merchant_product_creation.sh @@ -48,6 +48,7 @@ echo " FOUND" # Launch system. setup -c "test_template.conf" \ + -r "merchant-exchange-default" \ -em \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) diff --git a/src/testing/test_merchant_transfer_tracking.sh b/src/testing/test_merchant_transfer_tracking.sh @@ -47,6 +47,7 @@ echo " FOUND" # Launch system. setup -c "test_template.conf" \ + -r "merchant-exchange-default" \ -em \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) diff --git a/src/testing/test_merchant_wirewatch.sh b/src/testing/test_merchant_wirewatch.sh @@ -53,6 +53,7 @@ fi # Launch exchange, merchant and bank. setup -c "test_template.conf" \ -em \ + -r "merchant-exchange-default" \ $BANK_FLAGS LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX) CONF="test_template.conf.edited" diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -152,7 +152,7 @@ static enum GNUNET_GenericReturnValue find_token_public_key (const json_t *token_families, const char *slug, struct GNUNET_TIME_Timestamp valid_after, - struct TALER_TokenIssuePublicKeyP *pub) + struct TALER_TokenIssuePublicKey *pub) { const json_t *tf = json_object_get (token_families, slug); const json_t *keys; @@ -443,8 +443,8 @@ build_tokens (struct TALER_MERCHANT_UseToken **tokens, { const struct TALER_TokenUsePrivateKeyP *token_priv; - const struct TALER_TokenIssueSignatureP *issue_sig; - const struct TALER_TokenIssuePublicKeyP *issue_pub; + const struct TALER_TokenIssueSignature *issue_sig; + const struct TALER_TokenIssuePublicKey *issue_pub; GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_token_priv (pay_cmd, diff --git a/src/util/os_installation.c b/src/util/os_installation.c @@ -36,7 +36,7 @@ static const struct GNUNET_OS_ProjectData merchant_pd = { .libname = "libtalermerchantutil", .project_dirname = "taler-merchant", .binary_name = "taler-merchant-httpd", - .env_varname = "TALER_PREFIX", + .env_varname = "TALER_MERCHANT_PREFIX", .base_config_varname = "TALER_BASE_CONFIG", .bug_email = "taler@lists.gnu.org", .homepage = "http://www.gnu.org/s/taler/",