diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-18 21:59:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-18 21:59:01 +0200 |
commit | 02b21f6612f5150a686b6df0120fe3dd0722b58f (patch) | |
tree | 4aa8d9a8aaf513f9b3e1659f043b4213a3ba57da /src/testing | |
parent | 619c04ec68893ac285460ad3154a7c144c4f91e6 (diff) | |
download | merchant-02b21f6612f5150a686b6df0120fe3dd0722b58f.tar.gz merchant-02b21f6612f5150a686b6df0120fe3dd0722b58f.tar.bz2 merchant-02b21f6612f5150a686b6df0120fe3dd0722b58f.zip |
return merchant signature as part of payment callback (for #5210)
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_pay_order.c | 69 |
1 files changed, 11 insertions, 58 deletions
diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index 62105b4c..dca44377 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -82,6 +82,10 @@ struct PayState */ struct TALER_MERCHANT_OrderPayHandle *oph; + /** + * Signature from the merchant, set on success. + */ + struct TALER_MerchantSignatureP merchant_sig; }; @@ -203,16 +207,15 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, * * @param cls closure with the interpreter state * @param hr HTTP response + * @param merchant_sig signature affirming payment, + * NULL on errors */ static void pay_cb (void *cls, - const struct TALER_MERCHANT_HttpResponse *hr) + const struct TALER_MERCHANT_HttpResponse *hr, + const struct TALER_MerchantSignatureP *merchant_sig) { struct PayState *ps = cls; - struct GNUNET_CRYPTO_EddsaSignature sig; - const char *error_name; - unsigned int error_line; - const struct TALER_MerchantPublicKeyP *merchant_pub; ps->oph = NULL; if (ps->http_status != hr->http_status) @@ -226,60 +229,8 @@ pay_cb (void *cls, } if (MHD_HTTP_OK == hr->http_status) { - /* Check signature */ - struct PaymentResponsePS mr; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("sig", - &sig), - GNUNET_JSON_spec_end () - }; - const struct TALER_TESTING_Command *proposal_cmd; - - if (GNUNET_OK != - GNUNET_JSON_parse (hr->reply, - spec, - &error_name, - &error_line)) - { - char *js; - - js = json_dumps (hr->reply, - JSON_INDENT (1)); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Parser failed on %s:%u for input `%s'\n", - error_name, - error_line, - js); - free (js); - TALER_TESTING_FAIL (ps->is); - } - mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK); - mr.purpose.size = htonl (sizeof (mr)); - mr.h_contract_terms = ps->h_contract_terms; - - /* proposal reference was used at least once, at this point */ - GNUNET_assert (NULL != - (proposal_cmd = - TALER_TESTING_interpreter_lookup_command (ps->is, - ps-> - proposal_reference))); - if (GNUNET_OK != - TALER_TESTING_get_trait_merchant_pub (proposal_cmd, - 0, - &merchant_pub)) - TALER_TESTING_FAIL (ps->is); - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK, - &mr, - &sig, - &merchant_pub->eddsa_pub)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Merchant signature given in response to /pay invalid\n"); - TALER_TESTING_FAIL (ps->is); - } + ps->merchant_sig = *merchant_sig; } - TALER_TESTING_interpreter_next (ps->is); } @@ -508,6 +459,8 @@ pay_traits (void *cls, order_id), TALER_TESTING_make_trait_merchant_pub (0, merchant_pub), + TALER_TESTING_make_trait_merchant_sig (0, + &ps->merchant_sig), TALER_TESTING_make_trait_string (0, ps->amount_with_fee), TALER_TESTING_trait_end () |