diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-09-23 18:39:17 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-09-23 18:39:17 +0200 |
commit | 63994abe1e2780d3a43e261090d3261e8d91a854 (patch) | |
tree | 2d2fb235f05d12fcd5d9ea9c34be29c6e37b51c5 /src/lib | |
parent | 7d50af6651ea4e0a15960434e1d574596552ead7 (diff) |
implement instances via one base URL per instance
Previously, instances were addressed in various ways depending on then
request (GET parameter, some instance_id in the POST body). With this
commit, users of the merchant backend don't see the instance, they just
see another base URL.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/merchant_api_check_payment.c | 6 | ||||
-rw-r--r-- | src/lib/merchant_api_history.c | 16 | ||||
-rw-r--r-- | src/lib/merchant_api_pay.c | 11 | ||||
-rw-r--r-- | src/lib/merchant_api_proposal.c | 30 | ||||
-rw-r--r-- | src/lib/merchant_api_refund.c | 19 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_authorize.c | 6 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_pickup.c | 2 | ||||
-rw-r--r-- | src/lib/merchant_api_tip_query.c | 5 | ||||
-rw-r--r-- | src/lib/merchant_api_track_transaction.c | 12 | ||||
-rw-r--r-- | src/lib/merchant_api_track_transfer.c | 5 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 98 | ||||
-rw-r--r-- | src/lib/test_merchant_api_twisted.c | 68 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_history.c | 7 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_proposal.c | 24 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_tip.c | 26 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_track.c | 2 |
18 files changed, 115 insertions, 226 deletions
diff --git a/src/lib/merchant_api_check_payment.c b/src/lib/merchant_api_check_payment.c index 8c057072..8848686d 100644 --- a/src/lib/merchant_api_check_payment.c +++ b/src/lib/merchant_api_check_payment.c @@ -174,7 +174,6 @@ handle_check_payment_finished (void *cls, * * @param ctx execution context * @param backend_url base URL of the merchant backend - * @param instance instance used for the transaction * @param order_id order id to identify the payment * @parem session_id sesion id for the payment (or NULL if the payment is not bound to a session) * @param check_payment_cb callback which will work the response gotten from the backend @@ -184,7 +183,6 @@ handle_check_payment_finished (void *cls, struct TALER_MERCHANT_CheckPaymentOperation * TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, const char *order_id, const char *session_id, TALER_MERCHANT_CheckPaymentCallback check_payment_cb, @@ -194,15 +192,13 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, CURL *eh; GNUNET_assert (NULL != backend_url); - GNUNET_assert (NULL != instance); GNUNET_assert (NULL != order_id); cpo = GNUNET_new (struct TALER_MERCHANT_CheckPaymentOperation); cpo->ctx = ctx; cpo->cb = check_payment_cb; cpo->cb_cls = check_payment_cb_cls; - cpo->url = TALER_url_join (backend_url, "/check-payment", - "instance", instance, + cpo->url = TALER_url_join (backend_url, "check-payment", "order_id", order_id, "session_id", session_id, NULL); diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c index bab8d82a..d1cbfcfa 100644 --- a/src/lib/merchant_api_history.c +++ b/src/lib/merchant_api_history.c @@ -153,7 +153,6 @@ history_raw_cb (void *cls, * * @param ctx execution context * @param backend_url base URL of the merchant backend - * @param instance which merchant instance is performing this call * @param start return `delta` records starting from position `start`. * If given as zero, then no initial skip of `start` records is done. * @param use_default_start do NOT include the 'start' argument in URL. @@ -166,7 +165,6 @@ history_raw_cb (void *cls, static struct TALER_MERCHANT_HistoryOperation * TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, unsigned long long start, int use_default_start, long long delta, @@ -184,21 +182,19 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx, ho->cb = history_cb; ho->cb_cls = history_cb_cls; seconds = date.abs_value_us / 1000LL / 1000LL; - base = TALER_url_join (backend_url, "/history", NULL); + base = TALER_url_join (backend_url, "history", NULL); if (GNUNET_YES == use_default_start) GNUNET_asprintf (&ho->url, - "%s?date=%llu&instance=%s&delta=%lld", + "%s?date=%llu&delta=%lld", base, seconds, - instance, delta); else GNUNET_asprintf (&ho->url, - "%s?date=%llu&instance=%s&delta=%lld&start=%llu", + "%s?date=%llu&delta=%lld&start=%llu", base, seconds, - instance, delta, start); @@ -232,7 +228,6 @@ TALER_MERCHANT_history2 (struct GNUNET_CURL_Context *ctx, * * @param ctx execution context * @param backend_url base URL of the merchant backend - * @param instance which merchant instance is performing this call * @param start return `delta` records starting from position * `start`. If given as zero, then no initial skip of * `start` records is done. @@ -249,7 +244,6 @@ struct TALER_MERCHANT_HistoryOperation * TALER_MERCHANT_history_default_start (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, long long delta, struct GNUNET_TIME_Absolute date, TALER_MERCHANT_HistoryOperationCallback history_cb, @@ -257,7 +251,6 @@ TALER_MERCHANT_history_default_start { return TALER_MERCHANT_history2 (ctx, backend_url, - instance, /* fake 'start' argument: will NOT be used */ -1, /* Specifies "no start argument" in final URL */ @@ -274,7 +267,6 @@ TALER_MERCHANT_history_default_start * * @param ctx execution context * @param backend_url base URL of the merchant backend - * @param instance which merchant instance is performing this call * @param start return `delta` records starting from position * `start`. If given as zero, then no initial skip of * `start` records is done. @@ -291,7 +283,6 @@ struct TALER_MERCHANT_HistoryOperation * TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, unsigned long long start, long long delta, struct GNUNET_TIME_Absolute date, @@ -300,7 +291,6 @@ TALER_MERCHANT_history { return TALER_MERCHANT_history2 (ctx, backend_url, - instance, start, GNUNET_NO, delta, diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c index 0505e950..c7919a04 100644 --- a/src/lib/merchant_api_pay.c +++ b/src/lib/merchant_api_pay.c @@ -598,7 +598,7 @@ request_pay_generic ph->abort_cb_cls = abort_cb_cls; ph->pay_cb = pay_cb; ph->pay_cb_cls = pay_cb_cls; - ph->url = TALER_url_join (merchant_url, "/public/pay", NULL); + ph->url = TALER_url_join (merchant_url, "public/pay", NULL); ph->num_coins = num_coins; ph->coins = GNUNET_new_array (num_coins, struct TALER_MERCHANT_PaidCoin); @@ -639,8 +639,6 @@ request_pay_generic * * @param ctx the execution loop context * @param merchant_url base URL of the merchant's backend - * @param instance which merchant instance will receive this - * payment * @param h_contract_terms hashcode of the proposal being paid * @param amount total value of the contract to be paid to the * merchant @@ -668,7 +666,6 @@ request_pay_generic static struct TALER_MERCHANT_Pay * prepare_pay_generic (struct GNUNET_CURL_Context *ctx, const char *merchant_url, - const char *instance, const struct GNUNET_HashCode *h_contract_terms, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -774,7 +771,6 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx, * * @param ctx the execution loop context * @param merchant_url base URL of the merchant's backend - * @param instance which merchant instance will receive this payment * @param h_contract_terms hashcode of the proposal being paid * @param amount total value of the contract to be paid to the merchant * @param max_fee maximum fee covered by the merchant (according to the contract) @@ -794,7 +790,6 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx, struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, const char *merchant_url, - const char *instance, const struct GNUNET_HashCode *h_contract_terms, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -812,7 +807,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, { return prepare_pay_generic (ctx, merchant_url, - instance, h_contract_terms, amount, max_fee, @@ -839,7 +833,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, * * @param ctx execution context * @param merchant_url base URL of the merchant - * @param instance which merchant instance will receive this payment * @param h_wire hash of the merchant’s account details * @param h_contract hash of the contact of the merchant with the customer * @param transaction_id transaction id for the transaction between merchant and customer @@ -860,7 +853,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, struct TALER_MERCHANT_Pay * TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx, const char *merchant_url, - const char *instance, const struct GNUNET_HashCode *h_contract, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, @@ -880,7 +872,6 @@ TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx, ph = prepare_pay_generic (ctx, merchant_url, - instance, h_contract, amount, max_fee, diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c index 25552bc0..83371eda 100644 --- a/src/lib/merchant_api_proposal.c +++ b/src/lib/merchant_api_proposal.c @@ -229,7 +229,7 @@ TALER_MERCHANT_order_put po->ctx = ctx; po->cb = proposal_cb; po->cb_cls = proposal_cb_cls; - po->url = TALER_url_join (backend_url, "/order", NULL); + po->url = TALER_url_join (backend_url, "order", NULL); req = json_pack ("{s:O}", "order", (json_t *) order); eh = curl_easy_init (); @@ -366,7 +366,6 @@ struct TALER_MERCHANT_ProposalLookupOperation * TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, - const char *instance, const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, TALER_MERCHANT_ProposalLookupOperationCallback @@ -375,38 +374,25 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx, { struct TALER_MERCHANT_ProposalLookupOperation *plo; CURL *eh; - char *base; + char *nonce_str = NULL; plo = GNUNET_new (struct TALER_MERCHANT_ProposalLookupOperation); plo->ctx = ctx; plo->cb = plo_cb; plo->cb_cls = plo_cb_cls; - base = TALER_url_join (backend_url, "/public/proposal", NULL); if (NULL != nonce) { - char *nonce_str; plo->has_nonce = GNUNET_YES; plo->nonce = *nonce; nonce_str = GNUNET_STRINGS_data_to_string_alloc (nonce, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); - GNUNET_assert (NULL != nonce_str); - GNUNET_asprintf (&plo->url, - "%s?order_id=%s&instance=%s&nonce=%s", - base, - order_id, - instance, - nonce_str); - GNUNET_free (nonce_str); } - else - { - GNUNET_asprintf (&plo->url, - "%s?order_id=%s&instance=%s", - base, - order_id, - instance); - } - GNUNET_free (base); + plo->url = TALER_url_join (backend_url, "public/proposal", + "order_id", + order_id, + "nonce", + nonce_str, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "looking up proposal from %s\n", plo->url); diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c index 76a01e5d..3f888099 100644 --- a/src/lib/merchant_api_refund.c +++ b/src/lib/merchant_api_refund.c @@ -190,7 +190,6 @@ TALER_MERCHANT_refund_increase_cancel (struct TALER_MERCHANT_RefundIncreaseOpera * @param order_id id of the order whose refund is to be increased * @param refund amount to which increase the refund * @param reason human-readable reason justifying the refund - * @param instance id of the merchant instance issuing the request * @param cb callback processing the response from /refund * @param cb_cls closure for cb */ @@ -200,7 +199,6 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx, const char *order_id, const struct TALER_Amount *refund, const char *reason, - const char *instance, TALER_MERCHANT_RefundIncreaseCallback cb, void *cb_cls) { @@ -212,12 +210,11 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context *ctx, rio->ctx = ctx; rio->cb = cb; rio->cb_cls = cb_cls; - rio->url = TALER_url_join (backend_url, "/refund", NULL); - req = json_pack ("{s:o, s:s, s:s, s:s}", + rio->url = TALER_url_join (backend_url, "refund", NULL); + req = json_pack ("{s:o, s:s, s:s}", "refund", TALER_JSON_from_amount (refund), "order_id", order_id, - "reason", reason, - "instance", instance); + "reason", reason); eh = curl_easy_init (); if (GNUNET_OK != TALER_curl_easy_post (&rio->post_ctx, @@ -333,26 +330,18 @@ struct TALER_MERCHANT_RefundLookupOperation * TALER_MERCHANT_refund_lookup (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, - const char *instance, TALER_MERCHANT_RefundLookupCallback cb, void *cb_cls) { struct TALER_MERCHANT_RefundLookupOperation *rlo; CURL *eh; - char *base; rlo = GNUNET_new (struct TALER_MERCHANT_RefundLookupOperation); rlo->ctx = ctx; rlo->cb = cb; rlo->cb_cls = cb_cls; - base = TALER_url_join (backend_url, "/public/refund", NULL); - GNUNET_asprintf (&rlo->url, - "%s?instance=%s&order_id=%s", - base, - instance, - order_id); - GNUNET_free (base); + rlo->url = TALER_url_join (backend_url, "public/refund", "order_id", order_id, NULL); eh = curl_easy_init (); if (CURLE_OK != curl_easy_setopt (eh, CURLOPT_URL, diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c index f79064a6..582c9a4e 100644 --- a/src/lib/merchant_api_tip_authorize.c +++ b/src/lib/merchant_api_tip_authorize.c @@ -179,7 +179,6 @@ handle_tip_authorize_finished (void *cls, * @param pickup_url frontend URL for where the tip can be picked up * @param next_url where the browser should proceed after picking up the tip * @param amount amount to be handed out as a tip - * @param instance which backend instance should create the tip (identifies the reserve and exchange) * @param justification which justification should be stored (human-readable reason for the tip) * @param authorize_cb callback which will work the response gotten from the backend * @param authorize_cb_cls closure to pass to @a authorize_cb @@ -191,7 +190,6 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx, const char *pickup_url, const char *next_url, const struct TALER_Amount *amount, - const char *instance, const char *justification, TALER_MERCHANT_TipAuthorizeCallback authorize_cb, void *authorize_cb_cls) @@ -204,16 +202,14 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx, tao->ctx = ctx; tao->cb = authorize_cb; tao->cb_cls = authorize_cb_cls; - tao->url = TALER_url_join (backend_url, "/tip-authorize", NULL); + tao->url = TALER_url_join (backend_url, "tip-authorize", NULL); te_obj = json_pack ("{" " s:o," /* amount */ - " s:s," /* instance */ " s:s," /* justification */ " s:s," /* pickup_url */ " s:s," /* next_url */ "}", "amount", TALER_JSON_from_amount (amount), - "instance", instance, "justification", justification, "pickup_url", pickup_url, "next_url", next_url); diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c index e49151bc..116b994c 100644 --- a/src/lib/merchant_api_tip_pickup.c +++ b/src/lib/merchant_api_tip_pickup.c @@ -288,7 +288,7 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx, tpo->cb_cls = pickup_cb_cls; tpo->url = TALER_url_join (backend_url, - "/public/tip-pickup", + "public/tip-pickup", NULL); eh = curl_easy_init (); if (GNUNET_OK != TALER_curl_easy_post (&tpo->post_ctx, diff --git a/src/lib/merchant_api_tip_query.c b/src/lib/merchant_api_tip_query.c index d02de8b1..3887390b 100644 --- a/src/lib/merchant_api_tip_query.c +++ b/src/lib/merchant_api_tip_query.c @@ -187,13 +187,11 @@ handle_tip_query_finished (void *cls, * * @param ctx execution context * @param backend_url base URL of the merchant backend - * @param instance instance to query * @return handle for this operation, NULL upon errors */ struct TALER_MERCHANT_TipQueryOperation * TALER_MERCHANT_tip_query (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, TALER_MERCHANT_TipQueryCallback query_cb, void *query_cb_cls) { @@ -204,8 +202,7 @@ TALER_MERCHANT_tip_query (struct GNUNET_CURL_Context *ctx, tqo->ctx = ctx; tqo->cb = query_cb; tqo->cb_cls = query_cb_cls; - tqo->url = TALER_url_join (backend_url, "/tip-query", - "instance", instance, + tqo->url = TALER_url_join (backend_url, "tip-query", NULL); GNUNET_log (GNUNET_ERROR_TYPE_INFO, diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c index 32393ece..e5cac2bb 100644 --- a/src/lib/merchant_api_track_transaction.c +++ b/src/lib/merchant_api_track_transaction.c @@ -134,7 +134,6 @@ handle_track_transaction_finished (void *cls, * * @param ctx execution context * @param backend_url base URL of the backend - * @param instance which merchant instance is going to be tracked * @param order_id order id pointing to the transaction being tracked * @param track_transaction_cb the callback to call when a reply for this request is available * @param track_transaction_cb_cls closure for @a track_transaction_cb @@ -143,26 +142,19 @@ handle_track_transaction_finished (void *cls, struct TALER_MERCHANT_TrackTransactionHandle * TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, const char *order_id, TALER_MERCHANT_TrackTransactionCallback track_transaction_cb, void *track_transaction_cb_cls) { struct TALER_MERCHANT_TrackTransactionHandle *tdo; CURL *eh; - char *base; tdo = GNUNET_new (struct TALER_MERCHANT_TrackTransactionHandle); tdo->ctx = ctx; tdo->cb = track_transaction_cb; tdo->cb_cls = track_transaction_cb_cls; - base = TALER_url_join (backend_url, "/track/transaction", NULL); - GNUNET_asprintf (&tdo->url, - "%s?order_id=%s&instance=%s", - base, - order_id, - instance); - GNUNET_free (base); + tdo->url = TALER_url_join (backend_url, "track/transaction", + "order_id", order_id, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting URL '%s'\n", tdo->url); diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c index b5105c54..df303b1b 100644 --- a/src/lib/merchant_api_track_transfer.c +++ b/src/lib/merchant_api_track_transfer.c @@ -219,7 +219,6 @@ handle_track_transfer_finished (void *cls, * * @param ctx execution context * @param backend_url base URL of the backend - * @param instance which merchant instance is going to be tracked * @param wire_method wire method used for the wire transfer * @param wtid base32 string indicating a wtid * @param exchange_url base URL of the exchange in charge of returning the wanted information @@ -230,7 +229,6 @@ handle_track_transfer_finished (void *cls, struct TALER_MERCHANT_TrackTransferHandle * TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *instance, const char *wire_method, const struct TALER_WireTransferIdentifierRawP *wtid, @@ -250,10 +248,9 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx, tdo->ctx = ctx; tdo->cb = track_transfer_cb; // very last to be called tdo->cb_cls = track_transfer_cb_cls; - tdo->url = TALER_url_join (backend_url, "/track/transfer", + tdo->url = TALER_url_join (backend_url, "track/transfer", "wtid", wtid_str, "exchange", exchange_url, - "instance", instance, "wire_method", wire_method, NULL); GNUNET_free (wtid_str); diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 67df2b93..fa7a385d 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -62,6 +62,26 @@ static char *fakebank_url; static char *merchant_url; /** + * Merchant base URL for the tipping instance. + */ +static char *merchant_tip_instance_url; + +/** + * Merchant base URL for the tipping instance. + */ +static char *merchant_tip_instance_2_url; + +/** + * Merchant base URL for the tipping instance. + */ +static char *merchant_tip_instance_nulltip_url; + +/** + * Merchant base URL for a non-existent instance. + */ +static char *merchant_tip_unknown_instance_url; + +/** * Merchant process. */ static struct GNUNET_OS_Process *merchantd; @@ -212,8 +232,7 @@ run (void *cls, \"summary\": \"merchant-lib testcase\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), TALER_TESTING_cmd_check_payment ("check-payment-1", merchant_url, @@ -287,8 +306,7 @@ run (void *cls, \"summary\": \"useful product\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), TALER_TESTING_cmd_proposal_lookup ("fetch-proposal-2", merchant_url, @@ -485,8 +503,7 @@ run (void *cls, \"summary\": \"useful product\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), /* Try to increase a non paid proposal. */ TALER_TESTING_cmd_refund_increase @@ -551,8 +568,7 @@ run (void *cls, \"summary\": \"merchant-lib testcase\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), TALER_TESTING_cmd_pay ("pay-unincreased-proposal", merchant_url, @@ -613,18 +629,16 @@ run (void *cls, "EUR:20.04", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO), TALER_TESTING_cmd_tip_authorize ("authorize-tip-1", - merchant_url, + merchant_tip_instance_url, exchange_url, MHD_HTTP_OK, - "tip", "tip 1", "EUR:5.01"), TALER_TESTING_cmd_tip_authorize ("authorize-tip-2", - merchant_url, + merchant_tip_instance_url, exchange_url, MHD_HTTP_OK, - "tip", "tip 2", "EUR:5.01"), @@ -635,51 +649,46 @@ run (void *cls, * actually create a reserve. */ TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-null", - merchant_url, + merchant_tip_instance_nulltip_url, exchange_url, MHD_HTTP_NOT_FOUND, - "nulltip", "tip 2", "EUR:5.01", TALER_EC_RESERVE_STATUS_UNKNOWN), TALER_TESTING_cmd_tip_query ("query-tip-1", - merchant_url, - MHD_HTTP_OK, - "tip"), + merchant_tip_instance_url, + MHD_HTTP_OK), TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-2", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, - "tip", "EUR:0.0", // picked "EUR:10.02", // auth "EUR:20.04"),// ava TALER_TESTING_cmd_tip_pickup ("pickup-tip-1", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, "authorize-tip-1", pickup_amounts_1), TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-3", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, - "tip", "EUR:5.01", // picked NULL, // auth "EUR:15.03"),// ava TALER_TESTING_cmd_tip_pickup ("pickup-tip-2", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, "authorize-tip-2", pickup_amounts_1), TALER_TESTING_cmd_tip_query_with_amounts ("query-tip-4", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, - "tip", "EUR:10.02", // pick "EUR:10.02", // auth "EUR:10.02"), // ava @@ -708,20 +717,18 @@ run (void *cls, TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-3-insufficient-funds", - merchant_url, + merchant_tip_instance_2_url, exchange_url, MHD_HTTP_PRECONDITION_FAILED, - "dtip", "tip 3", "EUR:2.02", TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS), TALER_TESTING_cmd_tip_authorize_with_ec ("authorize-tip-4-unknown-instance", - merchant_url, + merchant_tip_unknown_instance_url, exchange_url, MHD_HTTP_NOT_FOUND, - "unknown", "tip 4", "EUR:5.01", TALER_EC_TIP_AUTHORIZE_INSTANCE_UNKNOWN), @@ -731,14 +738,13 @@ run (void *cls, merchant_url, exchange_url, MHD_HTTP_NOT_FOUND, - "default", "tip 5", "EUR:5.01", TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP), TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-tip-3-too-much", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_CONFLICT, "authorize-tip-1", pickup_amounts_1, @@ -749,7 +755,7 @@ run (void *cls, TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-non-existent-id", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_NOT_FOUND, "fake-tip-authorization", pickup_amounts_1, @@ -757,7 +763,7 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-tip-1", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, "{\"max_fee\":\ {\"currency\":\"EUR\",\ @@ -773,11 +779,10 @@ run (void *cls, \"summary\": \"useful product\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), TALER_TESTING_cmd_pay ("deposit-tip-simple", - merchant_url, + merchant_tip_instance_url, MHD_HTTP_OK, "create-proposal-tip-1", "pickup-tip-1", @@ -849,8 +854,7 @@ run (void *cls, \"summary\": \"merchant-lib testcase\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:10}\"} ] }", - NULL), + \"value\":\"{EUR:10}\"} ] }"), TALER_TESTING_cmd_pay ("pay-fail-partial-double-10", merchant_url, @@ -929,8 +933,7 @@ run (void *cls, \"summary\": \"merchant-lib testcase\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:10}\"} ] }", - NULL), + \"value\":\"{EUR:10}\"} ] }"), TALER_TESTING_cmd_pay ("pay-fail-partial-double-11-good", merchant_url, @@ -1008,7 +1011,7 @@ run (void *cls, merchant_url, MHD_HTTP_OK, GNUNET_TIME_UNIT_ZERO_ABS, - 5, /* Expected number of records */ + 4, /* Expected number of records */ -100), /* Delta */ /** * End the suite. Fixme: better to have a label for this @@ -1043,6 +1046,19 @@ main (int argc, (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE))) return 77; + merchant_tip_instance_url = TALER_url_join (merchant_url, + "instances/tip/", + NULL); + merchant_tip_instance_2_url = TALER_url_join (merchant_url, + "instances/dtip/", + NULL); + merchant_tip_instance_nulltip_url = TALER_url_join (merchant_url, + "instances/nulltip/", + NULL); + merchant_tip_unknown_instance_url = TALER_url_join (merchant_url, + "instances/foo/", + NULL); + TALER_TESTING_cleanup_files (CONFIG_FILE); switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, diff --git a/src/lib/test_merchant_api_twisted.c b/src/lib/test_merchant_api_twisted.c index 43f3ef6f..901823f4 100644 --- a/src/lib/test_merchant_api_twisted.c +++ b/src/lib/test_merchant_api_twisted.c @@ -75,6 +75,16 @@ static char *twister_exchange_url; static char *twister_merchant_url; /** + * Twister URL that proxies the merchant. + */ +static char *twister_merchant_url_instance_nonexistent; + +/** + * Twister URL that proxies the merchant. + */ +static char *twister_merchant_url_instance_tor; + +/** * URL of the fakebank. Obtained from CONFIG_FILE's * "exchange-wire-test:BANK_URI" option. */ @@ -238,8 +248,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"triggering bug 5719\",\ - \"value\":\"{EUR:1}\"} ] }", - NULL), + \"value\":\"{EUR:1}\"} ] }"), /** * Instruct the Twister to malform the response given by @@ -285,8 +294,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:3}\"} ] }", - NULL), + \"value\":\"{EUR:3}\"} ] }"), /* Need any response code != 200. */ TALER_TESTING_cmd_hack_response_code @@ -344,8 +352,7 @@ run (void *cls, MHD_HTTP_BAD_REQUEST, /* giving a valid JSON to not make it fail before * data reaches the merchant. */ - "{\"not\": \"used\"}", - NULL), + "{\"not\": \"used\"}"), TALER_TESTING_cmd_hack_response_code ("proposal-500", @@ -360,8 +367,7 @@ run (void *cls, MHD_HTTP_INTERNAL_SERVER_ERROR, /* giving a valid JSON to not make it fail before * data reaches the merchant. */ - "{\"not\": \"used\"}", - NULL), + "{\"not\": \"used\"}"), /** * Cause the PUT /proposal callback to be called @@ -390,8 +396,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), /** * Cause proposal to be invalid: this is achieved * by deleting the "order_id" field of it. @@ -417,20 +422,18 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), /** * Cause a 404 Not Found response code, * due to a non existing merchant instance. */ TALER_TESTING_cmd_proposal ("create-proposal-4", - twister_merchant_url, + twister_merchant_url_instance_nonexistent, MHD_HTTP_NOT_FOUND, "{\"amount\":\"EUR:5\",\ \"fulfillment_url\": \"https://example.com/\",\ - \"summary\": \"merchant-lib testcase\"}", - "non-existent-instance"), + \"summary\": \"merchant-lib testcase\"}"), /* Cause a 404 Not Found from /proposal/lookup, * due to a non existing order id being queried. */ @@ -476,8 +479,7 @@ run (void *cls, \"fulfillment_url\": \"https://example.com/\",\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:5}\"} ] }", - NULL), + \"value\":\"{EUR:5}\"} ] }"), /* Remove expected field. */ TALER_TESTING_cmd_delete_object ("remove-contract-terms", @@ -569,7 +571,11 @@ run (void *cls, TALER_TESTING_cmd_proposal ("create-proposal-unaggregation", - twister_merchant_url, + /* Need a fresh instance in order to associate this + * proposal with a fresh h_wire; this way, this proposal + * won't get hooked by the aggregator gathering same-H_wire'd + * transactions. */ + twister_merchant_url_instance_tor, MHD_HTTP_OK, "{\"max_fee\":\ {\"currency\":\"EUR\",\ @@ -578,7 +584,6 @@ run (void *cls, \"refund_deadline\":\"\\/Date(2)\\/\",\ \"pay_deadline\":\"\\/Date(1)\\/\",\ \"wire_transfer_delay\":\"\\/Delay(30000)\\/\",\ - \"instance\":\"tor\",\ \"amount\":\ {\"currency\":\"EUR\",\ \"value\":5,\ @@ -586,12 +591,7 @@ run (void *cls, \"summary\": \"unaggregated product\",\ \"fulfillment_url\": \"https://example.com/\",\ \"products\": [ {\"description\":\"unaggregated cream\",\ - \"value\":\"{EUR:5}\"} ] }", - /* Need a fresh instance in order to associate this - * proposal with a fresh h_wire; this way, this proposal - * won't get hooked by the aggregator gathering same-H_wire'd - * transactions. */ - "tor"), + \"value\":\"{EUR:5}\"} ] }"), TALER_TESTING_cmd_pay ("pay-unaggregation", @@ -652,8 +652,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:2}\"} ] }", - NULL), + \"value\":\"{EUR:2}\"} ] }"), TALER_TESTING_cmd_pay ("deposit-simple-5383", twister_merchant_url, MHD_HTTP_OK, @@ -744,8 +743,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:3}\"} ] }", - NULL), + \"value\":\"{EUR:3}\"} ] }"), TALER_TESTING_cmd_check_payment ("check-payment-1", twister_merchant_url, @@ -862,8 +860,7 @@ run (void *cls, \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ \"products\": [ {\"description\":\"ice cream\",\ - \"value\":\"{EUR:3}\"} ] }", - NULL), + \"value\":\"{EUR:3}\"} ] }"), /* Will only pay _half_ the supposed price, * so we'll then have the right to abort. */ @@ -948,8 +945,7 @@ run (void *cls, \"value\":1,\ \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ - \"products\": [ {\"description\": \"will succeed\"}] }", - NULL), + \"products\": [ {\"description\": \"will succeed\"}] }"), TALER_TESTING_cmd_proposal ("create-proposal-double-spend-1", @@ -968,8 +964,7 @@ run (void *cls, \"value\":1,\ \"fraction\":0},\ \"summary\": \"merchant-lib testcase\",\ - \"products\": [ {\"description\": \"will fail\"}] }", - NULL), + \"products\": [ {\"description\": \"will fail\"}] }"), TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-double-spend", @@ -1087,6 +1082,9 @@ main (int argc, (PROXY_MERCHANT_CONFIG_FILE))) return 77; + twister_merchant_url_instance_nonexistent = TALER_url_join (twister_exchange_url, "instances/foo/", NULL); + twister_merchant_url_instance_tor = TALER_url_join (twister_exchange_url, "instances/tor/", NULL); + TALER_TESTING_cleanup_files (CONFIG_FILE); switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c index c9792680..6704fb93 100644 --- a/src/lib/testing_api_cmd_history.c +++ b/src/lib/testing_api_cmd_history.c @@ -43,11 +43,6 @@ struct HistoryState unsigned int http_status; /** - * The merchant instance executing this CMD. - */ - const char *instance; - - /** * URL of the merchant backend serving the /history request. */ const char *merchant_url; @@ -272,7 +267,6 @@ history_run (void *cls, hs->ho = TALER_MERCHANT_history_default_start (is->ctx, hs->merchant_url, - "default", hs->nrows, hs->time, &history_cb, @@ -282,7 +276,6 @@ history_run (void *cls, case GNUNET_NO: hs->ho = TALER_MERCHANT_history (is->ctx, hs->merchant_url, - "default", hs->start, hs->nrows, hs->time, diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index 7f1c82a7..3be5d8dd 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -386,7 +386,6 @@ check_payment_run (void *cls, cps->cpo = TALER_MERCHANT_check_payment (is->ctx, cps->merchant_url, - "default", // only default instance for now. order_id, NULL, check_payment_cb, @@ -854,7 +853,6 @@ _pay_run (const char *merchant_url, ret = api_func (is->ctx, merchant_url, - "default", // instance h_proposal, &total_amount, &max_fee, diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c index f095f38f..f5e282c9 100644 --- a/src/lib/testing_api_cmd_proposal.c +++ b/src/lib/testing_api_cmd_proposal.c @@ -79,11 +79,6 @@ struct ProposalState struct GNUNET_CRYPTO_EddsaPublicKey nonce; /** - * The merchant instance. - */ - const char *instance; - - /** * URL of the merchant backend. */ const char *merchant_url; @@ -318,7 +313,6 @@ proposal_cb (void *cls, (ps->is->ctx, ps->merchant_url, ps->order_id, - ps->instance, &ps->nonce, &proposal_lookup_initial_cb, ps))) @@ -376,18 +370,6 @@ proposal_run (void *cls, (GNUNET_CRYPTO_QUALITY_WEAK, &ps->nonce, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); - if (NULL != ps->instance) - { - json_t *merchant; - - merchant = json_object (); - json_object_set_new (merchant, - "instance", - json_string (ps->instance)); - json_object_set_new (order, - "merchant", - merchant); - } ps->po = TALER_MERCHANT_order_put (is->ctx, ps->merchant_url, @@ -468,7 +450,6 @@ proposal_lookup_cleanup (void *cls, * the proposal request. * @param http_status expected HTTP status. * @param order the order to PUT to the merchant. - * @param instance merchant instance performing the operation. * * @return the command */ @@ -476,8 +457,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_proposal (const char *label, const char *merchant_url, unsigned int http_status, - const char *order, - const char *instance) + const char *order) { struct ProposalState *ps; @@ -485,7 +465,6 @@ TALER_TESTING_cmd_proposal (const char *label, ps->order = order; ps->http_status = http_status; ps->merchant_url = merchant_url; - ps->instance = (NULL == instance) ? "default" : instance; struct TALER_TESTING_Command cmd = { .cls = ps, @@ -580,7 +559,6 @@ proposal_lookup_run (void *cls, pls->plo = TALER_MERCHANT_proposal_lookup (is->ctx, pls->merchant_url, order_id, - "default", nonce, &proposal_lookup_cb, pls); diff --git a/src/lib/testing_api_cmd_refund.c b/src/lib/testing_api_cmd_refund.c index abe68f8e..f0ee31b5 100644 --- a/src/lib/testing_api_cmd_refund.c +++ b/src/lib/testing_api_cmd_refund.c @@ -221,7 +221,6 @@ refund_increase_run (void *cls, ris->order_id, &refund_amount, ris->reason, - "default", &refund_increase_cb, ris); GNUNET_assert (NULL != ris->rio); @@ -450,7 +449,6 @@ refund_lookup_run (void *cls, rls->rlo = TALER_MERCHANT_refund_lookup (is->ctx, rls->merchant_url, rls->order_id, - "default", &refund_lookup_cb, rls); GNUNET_assert (NULL != rls->rlo); diff --git a/src/lib/testing_api_cmd_tip.c b/src/lib/testing_api_cmd_tip.c index 652bd95d..a5bbf2a1 100644 --- a/src/lib/testing_api_cmd_tip.c +++ b/src/lib/testing_api_cmd_tip.c @@ -139,11 +139,6 @@ struct TipQueryState unsigned int http_status; /** - * Which merchant instance is running this CMD. - */ - const char *instance; - - /** * The handle to the current /tip-query request. */ struct TALER_MERCHANT_TipQueryOperation *tqo; @@ -188,11 +183,6 @@ struct TipAuthorizeState unsigned int http_status; /** - * Merchant instance running this CMD. - */ - const char *instance; - - /** * Human-readable justification for the * tip authorization carried on by this CMD. */ @@ -345,7 +335,6 @@ tip_authorize_run (void *cls, "http://merchant.com/pickup", "http://merchant.com/continue", &amount, - tas->instance, tas->justification, tip_authorize_cb, tas); @@ -411,7 +400,6 @@ tip_authorize_cleanup (void *cls, * the reserve from which the tip is going to be gotten. * @param http_status the HTTP response code which is expected * for this operation. - * @param instance which merchant instance is running this CMD. * @param justification human-readable justification for this * tip authorization. * @param amount the amount to authorize for tipping. @@ -423,7 +411,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec const char *merchant_url, const char *exchange_url, unsigned int http_status, - const char *instance, const char *justification, const char *amount, enum TALER_ErrorCode ec) @@ -432,7 +419,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec tas = GNUNET_new (struct TipAuthorizeState); tas->merchant_url = merchant_url; - tas->instance = instance; tas->justification = justification; tas->amount = amount; tas->http_status = http_status; @@ -461,7 +447,6 @@ TALER_TESTING_cmd_tip_authorize_with_ec * the reserve from which the tip is going to be gotten. * @param http_status the HTTP response code which is expected * for this operation. - * @param instance which merchant instance is running this CMD. * @param justification human-readable justification for this * tip authorization. * @param amount the amount to authorize for tipping. @@ -471,7 +456,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label, const char *merchant_url, const char *exchange_url, unsigned int http_status, - const char *instance, const char *justification, const char *amount) { @@ -479,7 +463,6 @@ TALER_TESTING_cmd_tip_authorize (const char *label, tas = GNUNET_new (struct TipAuthorizeState); tas->merchant_url = merchant_url; - tas->instance = instance; tas->justification = justification; tas->amount = amount; tas->http_status = http_status; @@ -631,7 +614,6 @@ tip_query_run (void *cls, tqs->is = is; tqs->tqo = TALER_MERCHANT_tip_query (is->ctx, tqs->merchant_url, - tqs->instance, &tip_query_cb, tqs); GNUNET_assert (NULL != tqs->tqo); @@ -646,7 +628,6 @@ tip_query_run (void *cls, * server the /tip-query request. * @param http_status expected HTTP response code for the * /tip-query request. - * @param instance the merchant instance running this CMD. * @param expected_amount_picked_up expected amount already * picked up. * @param expected_amount_authorized expected amount that was @@ -660,7 +641,6 @@ TALER_TESTING_cmd_tip_query_with_amounts (const char *label, const char *merchant_url, unsigned int http_status, - const char *instance, const char *expected_amount_picked_up, const char *expected_amount_authorized, const char *expected_amount_available) @@ -669,7 +649,6 @@ TALER_TESTING_cmd_tip_query_with_amounts tqs = GNUNET_new (struct TipQueryState); tqs->merchant_url = merchant_url; - tqs->instance = instance; tqs->http_status = http_status; tqs->expected_amount_picked_up = expected_amount_picked_up; tqs->expected_amount_authorized = expected_amount_authorized; @@ -694,19 +673,16 @@ TALER_TESTING_cmd_tip_query_with_amounts * server the /tip-query request. * @param http_status expected HTTP response code for the * /tip-query request. - * @param instance the merchant instance running this CMD. */ struct TALER_TESTING_Command TALER_TESTING_cmd_tip_query (const char *label, const char *merchant_url, - unsigned int http_status, - const char *instance) + unsigned int http_status) { struct TipQueryState *tqs; tqs = GNUNET_new (struct TipQueryState); tqs->merchant_url = merchant_url; - tqs->instance = instance; tqs->http_status = http_status; struct TALER_TESTING_Command cmd = { diff --git a/src/lib/testing_api_cmd_track.c b/src/lib/testing_api_cmd_track.c index 9cd4803b..1f1596a4 100644 --- a/src/lib/testing_api_cmd_track.c +++ b/src/lib/testing_api_cmd_track.c @@ -373,7 +373,6 @@ track_transfer_run (void *cls, TALER_TESTING_FAIL (is); tts->tth = TALER_MERCHANT_track_transfer (is->ctx, tts->merchant_url, - "default", "x-taler-bank", wtid, exchange_url, @@ -412,7 +411,6 @@ track_transaction_run (void *cls, tts->tth = TALER_MERCHANT_track_transaction (is->ctx, tts->merchant_url, - "default", order_id, &track_transaction_cb, tts); |