merchant

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

taler_merchant_testing_lib.h (81997B)


      1 /*
      2   This file is part of TALER
      3   (C) 2018-2023 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify
      6   it under the terms of the GNU General Public License as
      7   published by the Free Software Foundation; either version 3, or
      8   (at your option) any later version.
      9 
     10   TALER is distributed in the hope that it will be useful, but
     11   WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13   GNU General Public License for more details.
     14 
     15   You should have received a copy of the GNU General Public
     16   License along with TALER; see the file COPYING.  If not, see
     17   <http://www.gnu.org/licenses/>
     18 */
     19 
     20 /**
     21  * @file taler_merchant_testing_lib.h
     22  * @brief API for writing an interpreter to test Taler components
     23  * @author Christian Grothoff <christian@grothoff.org>
     24  * @author Marcello Shtanisci
     25  * @author Priscilla HUANG
     26  */
     27 #ifndef TALER_MERCHANT_TESTING_LIB_H
     28 #define TALER_MERCHANT_TESTING_LIB_H
     29 
     30 #include <gnunet/gnunet_time_lib.h>
     31 #include <taler/taler_testing_lib.h>
     32 #include "taler_merchant_service.h"
     33 #ifdef HAVE_DONAU_DONAU_SERVICE_H
     34 #include "donau/donau_service.h"
     35 #endif // HAVE_DONAU_DONAU_SERVICE_H
     36 
     37 /* ********************* Helper functions ********************* */
     38 
     39 
     40 #define MERCHANT_FAIL() \
     41   do {GNUNET_break (0); return NULL; } while (0)
     42 
     43 
     44 /**
     45  * Extract hostname (and port) from merchant base URL.
     46  *
     47  * @param merchant_url full merchant URL (e.g. "http://host:8080/foo/bar/")
     48  * @return just the hostname and port ("hostname:8080")
     49  */
     50 char *
     51 TALER_MERCHANT_TESTING_extract_host (const char *merchant_url);
     52 
     53 
     54 /* ************** Specific interpreter commands ************ */
     55 
     56 
     57 /**
     58  * Define a "config" CMD.
     59  *
     60  * @param label command label.
     61  * @param merchant_url base URL of the merchant serving the
     62  *        "config" request.
     63  * @param http_code expected HTTP response code.
     64  * @return the command.
     65  */
     66 struct TALER_TESTING_Command
     67 TALER_TESTING_cmd_config (const char *label,
     68                           const char *merchant_url,
     69                           unsigned int http_code);
     70 
     71 
     72 /**
     73  * Define a "GET /instances" CMD.
     74  *
     75  * @param label command label.
     76  * @param merchant_url base URL of the merchant serving the
     77  *        GET /instances request.
     78  * @param http_status expected HTTP response code.
     79  * @param ... NULL-terminated list of labels (const char *) of
     80  *        product (commands) we expect to be returned in the list
     81  *        (assuming @a http_code is #MHD_HTTP_OK)
     82  * @return the command.
     83  */
     84 struct TALER_TESTING_Command
     85 TALER_TESTING_cmd_merchant_get_instances (const char *label,
     86                                           const char *merchant_url,
     87                                           unsigned int http_status,
     88                                           ...);
     89 
     90 
     91 /**
     92  * Define a "POST /instances" CMD, simple version
     93  *
     94  * @param label command label.
     95  * @param merchant_url base URL of the merchant serving the
     96  *        POST /instances request.
     97  * @param instance_id the ID of the instance to create
     98  * @param http_status expected HTTP response code.
     99  * @return the command.
    100  */
    101 struct TALER_TESTING_Command
    102 TALER_TESTING_cmd_merchant_post_instances (const char *label,
    103                                            const char *merchant_url,
    104                                            const char *instance_id,
    105                                            unsigned int http_status);
    106 
    107 
    108 /**
    109  * Define a "POST /private/auth" CMD.
    110  *
    111  * @param label command label.
    112  * @param merchant_url base URL of the merchant serving the
    113  *        POST /instances request.
    114  * @param instance_id the ID of the instance, or NULL
    115  * @param auth_token new auth token to use, can be NULL for no auth
    116  * @param http_status expected HTTP response code.
    117  * @return the command.
    118  */
    119 struct TALER_TESTING_Command
    120 TALER_TESTING_cmd_merchant_post_instance_auth (const char *label,
    121                                                const char *merchant_url,
    122                                                const char *instance_id,
    123                                                const char *auth_token,
    124                                                unsigned int http_status);
    125 
    126 
    127 /**
    128  * Define a "POST /private/token" CMD.
    129  *
    130  * @param label command label.
    131  * @param merchant_url base URL of the merchant serving the
    132  *        POST /instances request.
    133  * @param instance_id the ID of the instance, or NULL
    134  * @param scope scope to request, can be NULL
    135  * @param duration requested token validity duration
    136  * @param refreshable should token be refreshable
    137  * @param http_status expected HTTP response code.
    138  * @return the command.
    139  */
    140 struct TALER_TESTING_Command
    141 TALER_TESTING_cmd_merchant_post_instance_token (const char *label,
    142                                                 const char *merchant_url,
    143                                                 const char *instance_id,
    144                                                 const char *scope,
    145                                                 struct GNUNET_TIME_Relative
    146                                                 duration,
    147                                                 bool refreshable,
    148                                                 unsigned int http_status);
    149 
    150 /**
    151  * Set the access token gotten through another CMD
    152  *
    153  * @param label command label.
    154  * @param cmd_job_label the other command exposing the bearer_token trait.
    155  * @return the command.
    156  */
    157 struct TALER_TESTING_Command
    158 TALER_TESTING_cmd_merchant_set_instance_token (const char *label,
    159                                                const char *cmd_job_label);
    160 
    161 /**
    162  * Define a "DELETE /private/token" CMD.
    163  *
    164  * @param label command label.
    165  * @param merchant_url base URL of the merchant serving the
    166  *        POST /instances request.
    167  * @param instance_id the ID of the instance, or NULL
    168  * @param http_status expected HTTP response code.
    169  * @return the command.
    170  */
    171 struct TALER_TESTING_Command
    172 TALER_TESTING_cmd_merchant_delete_instance_token (const char *label,
    173                                                   const char *merchant_url,
    174                                                   const char *instance_id,
    175                                                   unsigned int http_status);
    176 
    177 /**
    178  * Define a "POST /instances" CMD.  Comprehensive version.
    179  *
    180  * @param label command label.
    181  * @param merchant_url base URL of the merchant serving the
    182  *        POST /instances request.
    183  * @param instance_id the ID of the instance to query
    184  * @param name name of the merchant instance
    185  * @param address physical address of the merchant instance
    186  * @param jurisdiction jurisdiction of the merchant instance
    187  * @param use_stefan enable STEFAN curve
    188  * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
    189  * @param default_pay_delay default validity period for offers merchant makes
    190  * @param auth_token authorization token needed to access the instance, can be NULL
    191  * @param http_status expected HTTP response code.
    192  * @return the command.
    193  */
    194 struct TALER_TESTING_Command
    195 TALER_TESTING_cmd_merchant_post_instances2 (
    196   const char *label,
    197   const char *merchant_url,
    198   const char *instance_id,
    199   const char *name,
    200   json_t *address,
    201   json_t *jurisdiction,
    202   bool use_stefan,
    203   struct GNUNET_TIME_Relative default_wire_transfer_delay,
    204   struct GNUNET_TIME_Relative default_pay_delay,
    205   const char *auth_token,
    206   unsigned int http_status);
    207 
    208 
    209 /**
    210  * Define a "POST /account" CMD.
    211  *
    212  * @param label command label.
    213  * @param merchant_url base URL of the merchant serving the
    214  *        POST /instances request.
    215  * @param payto_uri URIs of the bank account to add to the merchant instance
    216  * @param credit_facade_url credit facade URL to configure, can be NULL
    217  * @param credit_facade_credentials credit facade credentials to use, can be NULL
    218  * @param http_status expected HTTP response code.
    219  * @return the command.
    220  */
    221 struct TALER_TESTING_Command
    222 TALER_TESTING_cmd_merchant_post_account (
    223   const char *label,
    224   const char *merchant_url,
    225   struct TALER_FullPayto payto_uri,
    226   const char *credit_facade_url,
    227   const json_t *credit_facade_credentials,
    228   unsigned int http_status);
    229 
    230 
    231 /**
    232  * Define a "PATCH /account" CMD.
    233  *
    234  * @param label command label.
    235  * @param merchant_url base URL of the merchant serving the
    236  *        POST /instances request.
    237  * @param create_account_ref reference to account setup command
    238  * @param credit_facade_url credit facade URL to configure, can be NULL
    239  * @param credit_facade_credentials credit facade credentials to use, can be NULL
    240  * @param http_status expected HTTP response code.
    241  * @return the command.
    242  */
    243 struct TALER_TESTING_Command
    244 TALER_TESTING_cmd_merchant_patch_account (
    245   const char *label,
    246   const char *merchant_url,
    247   const char *create_account_ref,
    248   const char *credit_facade_url,
    249   const json_t *credit_facade_credentials,
    250   unsigned int http_status);
    251 
    252 
    253 /**
    254  * Define a "DELETE /account" CMD.
    255  *
    256  * @param label command label.
    257  * @param create_account_ref reference to account setup command
    258  * @param http_status expected HTTP response code.
    259  * @return the command.
    260  */
    261 struct TALER_TESTING_Command
    262 TALER_TESTING_cmd_merchant_delete_account (
    263   const char *label,
    264   const char *create_account_ref,
    265   unsigned int http_status);
    266 
    267 
    268 /**
    269  * Define a "PATCH /instances/$ID" CMD.
    270  *
    271  * @param label command label.
    272  * @param merchant_url base URL of the merchant serving the
    273  *        PATCH /instance request.
    274  * @param instance_id the ID of the instance to query
    275  * @param name name of the merchant instance
    276  * @param address physical address of the merchant instance
    277  * @param jurisdiction jurisdiction of the merchant instance
    278  * @param use_stefan use STEFAN curve
    279  * @param default_wire_transfer_delay default wire transfer delay merchant will ask for
    280  * @param default_pay_delay default validity period for offers merchant makes
    281  * @param http_status expected HTTP response code.
    282  * @return the command.
    283  */
    284 struct TALER_TESTING_Command
    285 TALER_TESTING_cmd_merchant_patch_instance (
    286   const char *label,
    287   const char *merchant_url,
    288   const char *instance_id,
    289   const char *name,
    290   json_t *address,
    291   json_t *jurisdiction,
    292   bool use_stefan,
    293   struct GNUNET_TIME_Relative default_wire_transfer_delay,
    294   struct GNUNET_TIME_Relative default_pay_delay,
    295   unsigned int http_status);
    296 
    297 
    298 /**
    299  * Define a "GET instance" CMD.
    300  *
    301  * @param label command label.
    302  * @param merchant_url base URL of the merchant serving the
    303  *        GET /instances/$ID request.
    304  * @param instance_id the ID of the instance to query
    305  * @param http_status expected HTTP response code.
    306  * @param instance_reference reference to a "POST /instances" or "PATCH /instances/$ID" CMD
    307  *        that will provide what we expect the backend to return to us
    308  * @return the command.
    309  */
    310 struct TALER_TESTING_Command
    311 TALER_TESTING_cmd_merchant_get_instance (const char *label,
    312                                          const char *merchant_url,
    313                                          const char *instance_id,
    314                                          unsigned int http_status,
    315                                          const char *instance_reference);
    316 
    317 
    318 /**
    319  * Define a "PURGE instance" CMD.
    320  *
    321  * @param label command label.
    322  * @param merchant_url base URL of the merchant serving the
    323  *        PURGE /instances/$ID request.
    324  * @param instance_id the ID of the instance to query
    325  * @param http_status expected HTTP response code.
    326  * @return the command.
    327  */
    328 struct TALER_TESTING_Command
    329 TALER_TESTING_cmd_merchant_purge_instance (const char *label,
    330                                            const char *merchant_url,
    331                                            const char *instance_id,
    332                                            unsigned int http_status);
    333 
    334 
    335 /**
    336  * Define a "DELETE instance" CMD.
    337  *
    338  * @param label command label.
    339  * @param merchant_url base URL of the merchant serving the
    340  *        DELETE /instances/$ID request.
    341  * @param instance_id the ID of the instance to query
    342  * @param http_status expected HTTP response code.
    343  * @return the command.
    344  */
    345 struct TALER_TESTING_Command
    346 TALER_TESTING_cmd_merchant_delete_instance (const char *label,
    347                                             const char *merchant_url,
    348                                             const char *instance_id,
    349                                             unsigned int http_status);
    350 
    351 
    352 /* ******************* /products **************** */
    353 
    354 
    355 /**
    356  * Define a "POST /products" CMD.
    357  *
    358  * @param label command label.
    359  * @param merchant_url base URL of the merchant serving the
    360  *        POST /products request.
    361  * @param product_id the ID of the product to query
    362  * @param description description of the product
    363  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
    364  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
    365  * @param price the price for one @a unit of the product, zero is used to imply that
    366  *              this product is not sold separately or that the price is not fixed and
    367  *              must be supplied by the front-end.  If non-zero, price must include
    368  *              applicable taxes.
    369  * @param image base64-encoded product image
    370  * @param taxes list of taxes paid by the merchant
    371  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
    372  * @param minimum_age minimum age required for buying this product
    373  * @param address where the product is in stock
    374  * @param next_restock when the next restocking is expected to happen, 0 for unknown,
    375  *                     #GNUNET_TIME_UNIT_FOREVER_TS for 'never'.
    376  * @param http_status expected HTTP response code.
    377  * @return the command.
    378  */
    379 struct TALER_TESTING_Command
    380 TALER_TESTING_cmd_merchant_post_products2 (
    381   const char *label,
    382   const char *merchant_url,
    383   const char *product_id,
    384   const char *description,
    385   json_t *description_i18n,
    386   const char *unit,
    387   const char *price,
    388   const char *image,
    389   json_t *taxes,
    390   int64_t total_stock,
    391   uint32_t minimum_age,
    392   json_t *address,
    393   struct GNUNET_TIME_Timestamp next_restock,
    394   unsigned int http_status);
    395 
    396 
    397 struct TALER_TESTING_Command
    398 TALER_TESTING_cmd_merchant_post_products3 (
    399   const char *label,
    400   const char *merchant_url,
    401   const char *product_id,
    402   const char *description,
    403   json_t *description_i18n,
    404   const char *unit,
    405   const char *price,
    406   const char *image,
    407   json_t *taxes,
    408   int64_t total_stock,
    409   uint32_t total_stock_frac,
    410   bool unit_allow_fraction,
    411   uint32_t minimum_age,
    412   json_t *address,
    413   struct GNUNET_TIME_Timestamp next_restock,
    414   unsigned int http_status);
    415 
    416 
    417 /**
    418  * Define a "POST /products" CMD, simple version
    419  *
    420  * @param label command label.
    421  * @param merchant_url base URL of the merchant serving the
    422  *        POST /products request.
    423  * @param product_id the ID of the product to create
    424  * @param description name of the product
    425  * @param price price of the product
    426  * @param http_status expected HTTP response code.
    427  * @return the command.
    428  */
    429 struct TALER_TESTING_Command
    430 TALER_TESTING_cmd_merchant_post_products (const char *label,
    431                                           const char *merchant_url,
    432                                           const char *product_id,
    433                                           const char *description,
    434                                           const char *price,
    435                                           unsigned int http_status);
    436 
    437 
    438 /**
    439  * Define a "PATCH /products/$ID" CMD.
    440  *
    441  * @param label command label.
    442  * @param merchant_url base URL of the merchant serving the
    443  *        PATCH /product request.
    444  * @param product_id the ID of the product to query
    445  * @param description description of the product
    446  * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
    447  * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
    448  * @param price the price for one @a unit of the product, zero is used to imply that
    449  *              this product is not sold separately or that the price is not fixed and
    450  *              must be supplied by the front-end.  If non-zero, price must include
    451  *              applicable taxes.
    452  * @param image base64-encoded product image
    453  * @param taxes list of taxes paid by the merchant
    454  * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
    455  * @param total_lost in @a units, must be larger than previous values, and may
    456  *               not exceed total_stock minus total_sold; if it does, the transaction
    457  *               will fail with a #MHD_HTTP_CONFLICT HTTP status code
    458  * @param address where the product is in stock
    459  * @param next_restock when the next restocking is expected to happen, 0 for unknown,
    460  *                     #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
    461  * @param http_status expected HTTP response code.
    462  * @return the command.
    463  */
    464 struct TALER_TESTING_Command
    465 TALER_TESTING_cmd_merchant_patch_product (
    466   const char *label,
    467   const char *merchant_url,
    468   const char *product_id,
    469   const char *description,
    470   json_t *description_i18n,
    471   const char *unit,
    472   const char *price,
    473   const char *image,
    474   json_t *taxes,
    475   int64_t total_stock,
    476   uint64_t total_lost,
    477   json_t *address,
    478   struct GNUNET_TIME_Timestamp next_restock,
    479   unsigned int http_status);
    480 
    481 
    482 struct TALER_TESTING_Command
    483 TALER_TESTING_cmd_merchant_patch_product2 (
    484   const char *label,
    485   const char *merchant_url,
    486   const char *product_id,
    487   const char *description,
    488   json_t *description_i18n,
    489   const char *unit,
    490   const char *price,
    491   const char *image,
    492   json_t *taxes,
    493   int64_t total_stock,
    494   uint32_t total_stock_frac,
    495   bool unit_allow_fraction,
    496   uint64_t total_lost,
    497   json_t *address,
    498   struct GNUNET_TIME_Timestamp next_restock,
    499   unsigned int http_status);
    500 
    501 
    502 /**
    503  * Define a "GET /products" CMD.
    504  *
    505  * @param label command label.
    506  * @param merchant_url base URL of the merchant serving the
    507  *        GET /products request.
    508  * @param http_status expected HTTP response code.
    509  * @param ... NULL-terminated list of labels (const char *) of
    510  *        product (commands) we expect to be returned in the list
    511  *        (assuming @a http_code is #MHD_HTTP_OK)
    512  * @return the command.
    513  */
    514 struct TALER_TESTING_Command
    515 TALER_TESTING_cmd_merchant_get_products (const char *label,
    516                                          const char *merchant_url,
    517                                          unsigned int http_status,
    518                                          ...);
    519 
    520 /**
    521  * Expectations for fractional unit fields when checking a product.
    522  */
    523 struct TALER_TESTING_ProductUnitExpectations
    524 {
    525   /**
    526    * Whether @e unit_allow_fraction is provided.
    527    */
    528   bool have_unit_allow_fraction;
    529 
    530   /**
    531    * Expected fractional flag.
    532    */
    533   bool unit_allow_fraction;
    534 
    535   /**
    536    * Whether @e unit_precision_level is provided.
    537    */
    538   bool have_unit_precision_level;
    539 
    540   /**
    541    * Expected fractional precision.
    542    */
    543   uint32_t unit_precision_level;
    544 };
    545 
    546 
    547 /**
    548  * Define a "GET product" CMD.
    549  *
    550  * @param label command label.
    551  * @param merchant_url base URL of the merchant serving the
    552  *        GET /products/$ID request.
    553  * @param product_id the ID of the product to query
    554  * @param http_status expected HTTP response code.
    555  * @param product_reference reference to a "POST /products" or "PATCH /products/$ID" CMD
    556  *        that will provide what we expect the backend to return to us
    557  * @param unit_expectations optional explicit expectations for the fractional fields
    558  * @return the command.
    559  */
    560 struct TALER_TESTING_Command
    561 TALER_TESTING_cmd_merchant_get_product2 (
    562   const char *label,
    563   const char *merchant_url,
    564   const char *product_id,
    565   unsigned int http_status,
    566   const char *product_reference,
    567   const struct TALER_TESTING_ProductUnitExpectations *unit_expectations);
    568 
    569 
    570 /**
    571  * Legacy helper kept for compatibility.
    572  */
    573 struct TALER_TESTING_Command
    574 TALER_TESTING_cmd_merchant_get_product (const char *label,
    575                                         const char *merchant_url,
    576                                         const char *product_id,
    577                                         unsigned int http_status,
    578                                         const char *product_reference);
    579 
    580 struct TALER_TESTING_Command
    581 TALER_TESTING_cmd_get_product_image (const char *label,
    582                                      const char *merchant_url,
    583                                      const char *product_reference,
    584                                      const char *image_hash,
    585                                      unsigned int http_status);
    586 
    587 
    588 /**
    589  * Define a "LOCK /products/$ID" CMD.
    590  *
    591  * @param label command label.
    592  * @param merchant_url base URL of the merchant serving the
    593  *        LOCK /product request.
    594  * @param product_id the ID of the product to lock.
    595  * @param duration how long the lock should last.
    596  * @param quantity how money units to lock.
    597  * @param http_status expected HTTP response code.
    598  * @return the command.
    599  */
    600 struct TALER_TESTING_Command
    601 TALER_TESTING_cmd_merchant_lock_product (
    602   const char *label,
    603   const char *merchant_url,
    604   const char *product_id,
    605   struct GNUNET_TIME_Relative duration,
    606   uint32_t quantity,
    607   unsigned int http_status);
    608 
    609 
    610 struct TALER_TESTING_Command
    611 TALER_TESTING_cmd_merchant_lock_product2 (
    612   const char *label,
    613   const char *merchant_url,
    614   const char *product_id,
    615   struct GNUNET_TIME_Relative duration,
    616   uint32_t quantity,
    617   uint32_t quantity_frac,
    618   bool use_fractional_quantity,
    619   unsigned int http_status);
    620 
    621 
    622 /**
    623  * Define a "DELETE product" CMD.
    624  *
    625  * @param label command label.
    626  * @param merchant_url base URL of the merchant serving the
    627  *        DELETE /products/$ID request.
    628  * @param product_id the ID of the product to query
    629  * @param http_status expected HTTP response code.
    630  * @return the command.
    631  */
    632 struct TALER_TESTING_Command
    633 TALER_TESTING_cmd_merchant_delete_product (const char *label,
    634                                            const char *merchant_url,
    635                                            const char *product_id,
    636                                            unsigned int http_status);
    637 
    638 
    639 /* ******************* /orders **************** */
    640 
    641 /**
    642  * Make the "proposal" command.
    643  *
    644  * @param label command label
    645  * @param cfg configuration to use
    646  * @param merchant_url base URL of the merchant serving
    647  *        the proposal request.
    648  * @param http_status expected HTTP status.
    649  * @param order_id the name of the order to add.
    650  * @param refund_deadline the deadline for refunds on this order.
    651  * @param pay_deadline the deadline for payment on this order.
    652  * @param amount the amount this order is for.
    653  * @return the command
    654  */
    655 struct TALER_TESTING_Command
    656 TALER_TESTING_cmd_merchant_post_orders (
    657   const char *label,
    658   const struct GNUNET_CONFIGURATION_Handle *cfg,
    659   const char *merchant_url,
    660   unsigned int http_status,
    661   const char *order_id,
    662   struct GNUNET_TIME_Timestamp refund_deadline,
    663   struct GNUNET_TIME_Timestamp pay_deadline,
    664   const char *amount);
    665 
    666 
    667 /**
    668  * Make the "proposal" command AVOIDING claiming the order.
    669  *
    670  * @param label command label
    671  * @param merchant_url base URL of the merchant serving
    672  *        the proposal request.
    673  * @param http_status expected HTTP status.
    674  * @param order_id the name of the order to add.
    675  * @param refund_deadline the deadline for refunds on this order.
    676  * @param pay_deadline the deadline for payment on this order.
    677  * @param amount the amount this order is for.
    678  * @return the command
    679  */
    680 struct TALER_TESTING_Command
    681 TALER_TESTING_cmd_merchant_post_orders_no_claim (
    682   const char *label,
    683   const char *merchant_url,
    684   unsigned int http_status,
    685   const char *order_id,
    686   struct GNUNET_TIME_Timestamp refund_deadline,
    687   struct GNUNET_TIME_Timestamp pay_deadline,
    688   const char *amount);
    689 
    690 
    691 /**
    692  * Make the "proposal" command.
    693  *
    694  * @param label command label
    695  * @param cfg configuration to use
    696  * @param merchant_url base URL of the merchant serving
    697  *        the proposal request.
    698  * @param http_status expected HTTP status.
    699  * @param order_id the name of the order to add.
    700  * @param refund_deadline the deadline for refunds on this order.
    701  * @param pay_deadline the deadline for payment on this order.
    702  * @param claim_token whether to generate a claim token.
    703  * @param amount the amount this order is for.
    704  * @param payment_target payment target for the order.
    705  * @param products a string indicating the products this order will be
    706  *        purchasing. Should be formatted as
    707  *        "[product_id]/[quantity];...".
    708  * @param locks a string of references to lock product commands that should
    709  *        be formatted as "[lock_1];[lock_2];...".
    710  * @param duplicate_of if not NULL, a reference to a previous order command
    711  *        that should be duplicated and checked for an identical response.
    712  * @return the command
    713  */
    714 struct TALER_TESTING_Command
    715 TALER_TESTING_cmd_merchant_post_orders2 (
    716   const char *label,
    717   const struct GNUNET_CONFIGURATION_Handle *cfg,
    718   const char *merchant_url,
    719   unsigned int http_status,
    720   const char *order_id,
    721   struct GNUNET_TIME_Timestamp refund_deadline,
    722   struct GNUNET_TIME_Timestamp pay_deadline,
    723   bool claim_token,
    724   const char *amount,
    725   const char *payment_target,
    726   const char *products,
    727   const char *locks,
    728   const char *duplicate_of);
    729 
    730 
    731 /**
    732  * Create an order with a specific fulfillment URL.
    733  * Does not claim the order.
    734  *
    735  * @param label command label
    736  * @param cfg configuration to use
    737  * @param merchant_url base URL of the merchant serving
    738  *        the proposal request
    739  * @param http_status expected HTTP status
    740  * @param order_id ID of the order to create
    741  * @param refund_deadline the deadline for refunds on this order
    742  * @param pay_deadline the deadline for payment on this order
    743  * @param fulfillment_url the fulfillment URL to use
    744  * @param amount the amount this order is for
    745  * @return the command
    746  */
    747 struct TALER_TESTING_Command
    748 TALER_TESTING_cmd_merchant_post_orders3 (
    749   const char *label,
    750   const struct GNUNET_CONFIGURATION_Handle *cfg,
    751   const char *merchant_url,
    752   unsigned int http_status,
    753   const char *order_id,
    754   struct GNUNET_TIME_Timestamp refund_deadline,
    755   struct GNUNET_TIME_Timestamp pay_deadline,
    756   const char *fulfillment_url,
    757   const char *amount);
    758 
    759 
    760 /**
    761  * Create an order with a choices array with input and output tokens.
    762  *
    763  * @param label command label
    764  * @param cfg configuration to use
    765  * @param merchant_url base URL of the merchant serving
    766  *        the proposal request.
    767  * @param http_status expected HTTP status.
    768  * @param token_family_slug slug of the token family to use
    769  * @param choice_description description of the choice
    770  * @param choice_description_i18n json of description translations
    771  * @param num_inputs number of input tokens.
    772  * @param num_outputs number of output tokens.
    773  * @param order_id the name of the order to add.
    774  * @param refund_deadline the deadline for refunds on this order.
    775  * @param pay_deadline the deadline for payment on this order.
    776  * @param amount the amount this order is for.
    777  * @return the command
    778  */
    779 
    780 struct TALER_TESTING_Command
    781 TALER_TESTING_cmd_merchant_post_orders_choices (
    782   const char *label,
    783   const struct GNUNET_CONFIGURATION_Handle *cfg,
    784   const char *merchant_url,
    785   unsigned int http_status,
    786   const char *token_family_slug,
    787   const char *choice_description,
    788   json_t *choice_description_i18n,
    789   unsigned int num_inputs,
    790   unsigned int num_outputs,
    791   const char *order_id,
    792   struct GNUNET_TIME_Timestamp refund_deadline,
    793   struct GNUNET_TIME_Timestamp pay_deadline,
    794   const char *amount);
    795 
    796 
    797 /**
    798  * Create an order with a choices array with output choice for donau.
    799  *
    800  * @param label command label
    801  * @param cfg configuration to use
    802  * @param merchant_url base URL of the merchant serving
    803  *        the proposal request.
    804  * @param http_status expected HTTP status.
    805  * @param order_id the name of the order to add.
    806  * @param refund_deadline the deadline for refunds on this order.
    807  * @param pay_deadline the deadline for payment on this order.
    808  * @param amount the amount this order is for.
    809  * @return the command
    810  */
    811 
    812 struct TALER_TESTING_Command
    813 TALER_TESTING_cmd_merchant_post_orders_donau (
    814   const char *label,
    815   const struct GNUNET_CONFIGURATION_Handle *cfg,
    816   const char *merchant_url,
    817   unsigned int http_status,
    818   const char *order_id,
    819   struct GNUNET_TIME_Timestamp refund_deadline,
    820   struct GNUNET_TIME_Timestamp pay_deadline,
    821   const char *amount);
    822 
    823 /**
    824  * Define a "GET /orders" CMD.
    825  *
    826  * @param label command label.
    827  * @param merchant_url base URL of the merchant serving the
    828  *        GET /orders request.
    829  * @param http_status expected HTTP response code.
    830  * @param ... NULL-terminated list of labels (const char *) of
    831  *        order (commands) we expect to be returned in the list
    832  *        (assuming @a http_code is #MHD_HTTP_OK)
    833  * @return the command.
    834  */
    835 struct TALER_TESTING_Command
    836 TALER_TESTING_cmd_merchant_get_orders (const char *label,
    837                                        const char *merchant_url,
    838                                        unsigned int http_status,
    839                                        ...);
    840 
    841 
    842 /**
    843  * Start a long poll for GET /private/orders.
    844  *
    845  * FIXME: needs additional arguments to specify range to long poll for!
    846  *
    847  * @param label the command label
    848  * @param merchant_url base URL of the merchant which will
    849  *        serve the request.
    850  * @param timeout how long to wait for the request to complete
    851  */
    852 struct TALER_TESTING_Command
    853 TALER_TESTING_cmd_poll_orders_start (const char *label,
    854                                      const char *merchant_url,
    855                                      struct GNUNET_TIME_Relative timeout);
    856 
    857 
    858 /**
    859  * Complete a long poll for GET /private/orders.
    860  *
    861  * @param label the command label
    862  * @param http_status expected HTTP response code
    863  * @param poll_start_reference reference to the #TALER_TESTING_cmd_poll_orders_start command
    864  */
    865 struct TALER_TESTING_Command
    866 TALER_TESTING_cmd_poll_orders_conclude (
    867   const char *label,
    868   unsigned int http_status,
    869   const char *poll_start_reference);
    870 
    871 
    872 /**
    873  * Define a GET /orders/$ORDER_ID CMD.
    874  *
    875  * @param label the command label
    876  * @param merchant_url base URL of the merchant which will
    877  *        serve the request.
    878  * @param order_reference reference to a command that created an order.
    879  * @param paid whether the order has been paid for or not.
    880  * @param refunded whether the order has been refunded.
    881  * @param refund_pending whether the order has refunds that haven't been obtained.
    882  * @param http_status expected HTTP response code for the request.
    883  */
    884 struct TALER_TESTING_Command
    885 TALER_TESTING_cmd_wallet_get_order (
    886   const char *label,
    887   const char *merchant_url,
    888   const char *order_reference,
    889   bool paid,
    890   bool refunded,
    891   bool refund_pending,
    892   unsigned int http_status);
    893 
    894 
    895 /**
    896  * Define a GET /orders/$ORDER_ID CMD.
    897  *
    898  * @param label the command label
    899  * @param merchant_url base URL of the merchant which will
    900  *        serve the request.
    901  * @param order_reference reference to a command that created an order.
    902  * @param session_id session ID to check for
    903  * @param paid whether the order has been paid for or not.
    904  * @param refunded whether the order has been refunded.
    905  * @param refund_pending whether the order has refunds that haven't been obtained.
    906  * @param repurchase_order_ref command of a paid equivalent order the merchant should be referring us to, or NULL
    907  * @param http_status expected HTTP response code for the request.
    908  */
    909 struct TALER_TESTING_Command
    910 TALER_TESTING_cmd_wallet_get_order2 (
    911   const char *label,
    912   const char *merchant_url,
    913   const char *order_reference,
    914   const char *session_id,
    915   bool paid,
    916   bool refunded,
    917   bool refund_pending,
    918   const char *repurchase_order_ref,
    919   unsigned int http_status);
    920 
    921 
    922 /**
    923  * Start a long poll for GET /orders/$ORDER_ID.
    924  *
    925  * @param label the command label
    926  * @param merchant_url base URL of the merchant which will
    927  *        serve the request.
    928  * @param order_ref reference to a command that created an order.
    929  * @param timeout how long to wait for the request to complete
    930  * @param await_refund NULL to not wait for refund, amount of value
    931  *         zero to wait for any refund amount, non-zero to poll
    932  *         for refund exceeding the given amount
    933  */
    934 struct TALER_TESTING_Command
    935 TALER_TESTING_cmd_wallet_poll_order_start (
    936   const char *label,
    937   const char *merchant_url,
    938   const char *order_ref,
    939   struct GNUNET_TIME_Relative timeout,
    940   const char *await_refund);
    941 
    942 
    943 /**
    944  * Start a long poll for GET /orders/$ORDER_ID.
    945  *
    946  * @param label the command label
    947  * @param merchant_url base URL of the merchant which will
    948  *        serve the request.
    949  * @param order_ref reference to a command that created an order.
    950  * @param timeout how long to wait for the request to complete
    951  * @param await_refund NULL to not wait for refund, amount of value
    952  *         zero to wait for any refund amount, non-zero to poll
    953  *         for refund exceeding the given amount
    954  * @param session_id which session ID to use
    955  */
    956 struct TALER_TESTING_Command
    957 TALER_TESTING_cmd_wallet_poll_order_start2 (
    958   const char *label,
    959   const char *merchant_url,
    960   const char *order_ref,
    961   struct GNUNET_TIME_Relative timeout,
    962   const char *await_refund,
    963   const char *session_id);
    964 
    965 
    966 /**
    967  * Complete a long poll for GET /orders/$ORDER_ID.
    968  *
    969  * @param label the command label
    970  * @param expected_http_status expected HTTP response code
    971  * @param expected_refund_amount refund expected, NULL for no refund expected
    972  * @param poll_start_reference reference to the #TALER_TESTING_cmd_wallet_poll_order_start command
    973  */
    974 struct TALER_TESTING_Command
    975 TALER_TESTING_cmd_wallet_poll_order_conclude (
    976   const char *label,
    977   unsigned int expected_http_status,
    978   const char *expected_refund_amount,
    979   const char *poll_start_reference);
    980 
    981 
    982 /**
    983  * Complete a long poll for GET /orders/$ORDER_ID.
    984  *
    985  * @param label the command label
    986  * @param expected_http_status expected HTTP response code
    987  * @param expected_refund_amount refund expected, NULL for no refund expected
    988  * @param poll_start_reference reference to the #TALER_TESTING_cmd_wallet_poll_order_start command
    989  * @param already_paid_order_id ID of an already paid order we expect to get returned
    990  */
    991 struct TALER_TESTING_Command
    992 TALER_TESTING_cmd_wallet_poll_order_conclude2 (
    993   const char *label,
    994   unsigned int expected_http_status,
    995   const char *expected_refund_amount,
    996   const char *poll_start_reference,
    997   const char *already_paid_order_id);
    998 
    999 
   1000 /**
   1001  * Define a GET /private/orders/$ORDER_ID CMD.
   1002  *
   1003  * @param label the command label
   1004  * @param merchant_url base URL of the merchant which will
   1005  *        serve the request.
   1006  * @param order_reference reference to a command that created an order.
   1007  * @param osc expected order status
   1008  * @param refunded whether the order has been refunded.
   1009  * @param http_status expected HTTP response code for the request.
   1010  * @param ... NULL-terminated list of labels (const char *) of
   1011  *        refunds (commands) we expect to be aggregated in the transfer
   1012  *        (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
   1013  *        this parameter is ignored.
   1014  */
   1015 struct TALER_TESTING_Command
   1016 TALER_TESTING_cmd_merchant_get_order (
   1017   const char *label,
   1018   const char *merchant_url,
   1019   const char *order_reference,
   1020   enum TALER_MERCHANT_OrderStatusCode osc,
   1021   bool refunded,
   1022   unsigned int http_status,
   1023   ...);
   1024 
   1025 
   1026 /**
   1027  * Define a GET /private/orders/$ORDER_ID CMD.
   1028  *
   1029  * @param label the command label
   1030  * @param merchant_url base URL of the merchant which will
   1031  *        serve the request.
   1032  * @param order_reference reference to a command that created an order.
   1033  * @param osc expected order status
   1034  * @param wired whether the order has been wired or not.
   1035  * @param transfers NULL-terminated list of labels (const char *) of
   1036  *        wire transfers (commands) we expect to be aggregated in the order
   1037  *        (assuming @a http_code is #MHD_HTTP_OK). If @e paid is false, this
   1038  *        parameter is ignored.
   1039  * @param refunded whether the order has been refunded.
   1040  * @param refunds NULL-terminated list of labels (const char *) of
   1041  *        refunds (commands) we expect to be aggregated in the order
   1042  *        (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
   1043  *        this parameter is ignored.
   1044  * @param forgets a NULL-terminated list of references to forget commands
   1045  *        that apply to the order we are querying. If NULL, this is
   1046  *        interpreted as no forgets are expected.
   1047  * @param http_status expected HTTP response code for the request.
   1048  */
   1049 struct TALER_TESTING_Command
   1050 TALER_TESTING_cmd_merchant_get_order2 (
   1051   const char *label,
   1052   const char *merchant_url,
   1053   const char *order_reference,
   1054   enum TALER_MERCHANT_OrderStatusCode osc,
   1055   bool wired,
   1056   const char **transfers,
   1057   bool refunded,
   1058   const char **refunds,
   1059   const char **forgets,
   1060   unsigned int http_status);
   1061 
   1062 
   1063 /**
   1064  * Define a GET /private/orders/$ORDER_ID CMD.
   1065  *
   1066  * @param label the command label
   1067  * @param merchant_url base URL of the merchant which will
   1068  *        serve the request.
   1069  * @param order_reference reference to a command that created an order.
   1070  * @param osc expected order status
   1071  * @param session_id session ID the payment must be bound to
   1072  * @param repurchase_order_ref command of a paid equivalent order the merchant should be referring us to, or NULL
   1073  * @param expected_http_status expected HTTP response code for the request.
   1074  */
   1075 struct TALER_TESTING_Command
   1076 TALER_TESTING_cmd_merchant_get_order3 (
   1077   const char *label,
   1078   const char *merchant_url,
   1079   const char *order_reference,
   1080   enum TALER_MERCHANT_OrderStatusCode osc,
   1081   const char *session_id,
   1082   const char *repurchase_order_ref,
   1083   unsigned int expected_http_status);
   1084 
   1085 
   1086 /**
   1087  * Define a GET /private/orders/$ORDER_ID CMD.
   1088  *
   1089  * @param label the command label
   1090  * @param merchant_url base URL of the merchant which will
   1091  *        serve the request.
   1092  * @param order_reference reference to a command that created an order.
   1093  * @param osc expected order status
   1094  * @param expected_min_age expected minimum age for the contract
   1095  * @param expected_http_status expected HTTP response code for the request.
   1096  */
   1097 struct TALER_TESTING_Command
   1098 TALER_TESTING_cmd_merchant_get_order4 (
   1099   const char *label,
   1100   const char *merchant_url,
   1101   const char *order_reference,
   1102   enum TALER_MERCHANT_OrderStatusCode osc,
   1103   uint32_t expected_min_age,
   1104   unsigned int expected_http_status);
   1105 
   1106 
   1107 /**
   1108  * Start a long poll for GET /private/orders/$ORDER_ID.
   1109  */
   1110 struct TALER_TESTING_Command
   1111 TALER_TESTING_cmd_poll_order_start (const char *label,
   1112                                     const char *merchant_url,
   1113                                     const char *order_id,
   1114                                     struct GNUNET_TIME_Relative timeout);
   1115 
   1116 
   1117 /**
   1118  * Complete a long poll for GET /private/orders/$ORDER_ID.
   1119  */
   1120 struct TALER_TESTING_Command
   1121 TALER_TESTING_cmd_poll_order_conclude (const char *label,
   1122                                        unsigned int http_status,
   1123                                        const char *poll_start_reference);
   1124 
   1125 /**
   1126  * Make a "claim order" command.
   1127  *
   1128  * @param label command label.
   1129  * @param merchant_url base URL of the merchant backend
   1130  *        serving the proposal lookup request.
   1131  * @param http_status expected HTTP response code.
   1132  * @param order_reference reference to a POST order CMD, can be NULL if @a order_id given
   1133  * @param order_id order id to lookup, can be NULL (then we use @a order_reference)
   1134  * @return the command.
   1135  */
   1136 struct TALER_TESTING_Command
   1137 TALER_TESTING_cmd_merchant_claim_order (const char *label,
   1138                                         const char *merchant_url,
   1139                                         unsigned int http_status,
   1140                                         const char *order_reference,
   1141                                         const char *order_id);
   1142 
   1143 
   1144 /**
   1145  * Make a "pay" test command.
   1146  *
   1147  * @param label command label.
   1148  * @param merchant_url merchant base url
   1149  * @param http_status expected HTTP response code.
   1150  * @param proposal_reference the proposal whose payment status
   1151  *        is going to be checked.
   1152  * @param coin_reference reference to any command which is able
   1153  *        to provide coins to use for paying.
   1154  * @param amount_with_fee amount to pay, including the deposit
   1155  *        fee
   1156  * @param amount_without_fee amount to pay, no fees included.
   1157  * @param session_id the session id to use for the payment (can be NULL).
   1158  * @return the command
   1159  */
   1160 struct TALER_TESTING_Command
   1161 TALER_TESTING_cmd_merchant_pay_order (
   1162   const char *label,
   1163   const char *merchant_url,
   1164   unsigned int http_status,
   1165   const char *proposal_reference,
   1166   const char *coin_reference,
   1167   const char *amount_with_fee,
   1168   const char *amount_without_fee,
   1169   const char *session_id);
   1170 
   1171 
   1172 /**
   1173  * Make a "pay" test command for an order with choices.
   1174  *
   1175  * @param label command label.
   1176  * @param merchant_url merchant base url
   1177  * @param http_status expected HTTP response code.
   1178  * @param proposal_reference the proposal whose payment status
   1179  *        is going to be checked.
   1180  * @param coin_reference reference to any command which is able
   1181  *        to provide coins to use for paying.
   1182  * @param amount_with_fee amount to pay, including the deposit
   1183  *        fee
   1184  * @param amount_without_fee amount to pay, no fees included.
   1185  * @param session_id the session id to use for the payment (can be NULL).
   1186  * @param choice_index index of the selected choice for the payment.
   1187  * @param input_reference reference to a previous pay command that issued some
   1188           outputs to be used as inputs to this pay request.
   1189  * @return the command
   1190  */
   1191 struct TALER_TESTING_Command
   1192 TALER_TESTING_cmd_merchant_pay_order_choices (
   1193   const char *label,
   1194   const char *merchant_url,
   1195   unsigned int http_status,
   1196   const char *proposal_reference,
   1197   const char *coin_reference,
   1198   const char *amount_with_fee,
   1199   const char *amount_without_fee,
   1200   const char *session_id,
   1201   int choice_index,
   1202   const char *input_reference);
   1203 
   1204 #ifdef HAVE_DONAU_DONAU_SERVICE_H
   1205 
   1206 /**
   1207  * Make a "pay" test command for an order with choices.
   1208  *
   1209  * @param label command label.
   1210  * @param merchant_url merchant base url
   1211  * @param http_status expected HTTP response code.
   1212  * @param proposal_reference the proposal whose payment status
   1213  *        is going to be checked.
   1214  * @param coin_reference reference to any command which is able
   1215  *        to provide coins to use for paying.
   1216  * @param amount_with_fee amount to pay, including the deposit
   1217  *        fee
   1218  * @param amount_without_fee amount to pay, no fees included.
   1219  * @param amount_donation amount for which the BKPS will be received.
   1220  * @param session_id the session id to use for the payment (can be NULL).
   1221  * @param choice_index index of the selected choice for the payment.
   1222  * @param year year of the donation
   1223  * @param donor_tax_id tax ID of the donor
   1224  * @param salt salt for the donation
   1225  * @return the command
   1226  */
   1227 struct TALER_TESTING_Command
   1228 TALER_TESTING_cmd_merchant_pay_order_donau (
   1229   const char *label,
   1230   const char *merchant_url,
   1231   unsigned int http_status,
   1232   const char *proposal_reference,
   1233   const char *coin_reference,
   1234   const char *amount_with_fee,
   1235   const char *amount_without_fee,
   1236   const char *amount_donation,
   1237   const char *session_id,
   1238   int choice_index,
   1239   const char *charity_reference,
   1240   uint64_t year,
   1241   const char *donor_tax_id,
   1242   const char *salt);
   1243 
   1244 #endif
   1245 
   1246 /**
   1247  * Make an "order paid" test command.
   1248  *
   1249  * @param label command label
   1250  * @param merchant_url merchant base URL
   1251  * @param pay_reference reference to the payment to verify
   1252  * @param session_id the session to use for the verification.
   1253  * @param http_status expected HTTP response code
   1254  * @return the command
   1255  */
   1256 struct TALER_TESTING_Command
   1257 TALER_TESTING_cmd_merchant_post_orders_paid (
   1258   const char *label,
   1259   const char *merchant_url,
   1260   const char *pay_reference,
   1261   const char *session_id,
   1262   unsigned int http_status);
   1263 
   1264 
   1265 /**
   1266  * Make an "abort" test command.
   1267  *
   1268  * @param label command label
   1269  * @param merchant_url merchant base URL
   1270  * @param pay_reference reference to the payment to abort
   1271  * @param http_status expected HTTP response code
   1272  * @return the command
   1273  */
   1274 struct TALER_TESTING_Command
   1275 TALER_TESTING_cmd_merchant_order_abort (
   1276   const char *label,
   1277   const char *merchant_url,
   1278   const char *pay_reference,
   1279   unsigned int http_status);
   1280 
   1281 
   1282 /**
   1283  * Make a "order forget" command.
   1284  *
   1285  * @param label command label.
   1286  * @param merchant_url base URL of the merchant backend
   1287  *        serving the order claim request.
   1288  * @param http_status expected HTTP response code.
   1289  * @param order_reference reference to a POST order CMD, can be NULL if @a order_id given
   1290  * @param order_id order id to forget for, can be NULL (then we use @a order_reference)
   1291  * @param ... NULL-terminated list of paths (const char *) to forget in
   1292  *        the contract terms.
   1293  * @return the command.
   1294  */
   1295 struct TALER_TESTING_Command
   1296 TALER_TESTING_cmd_merchant_forget_order (
   1297   const char *label,
   1298   const char *merchant_url,
   1299   unsigned int http_status,
   1300   const char *order_reference,
   1301   const char *order_id,
   1302   ...);
   1303 
   1304 
   1305 /**
   1306  * Define a "refund" order CMD.
   1307  *
   1308  * @param label command label.
   1309  * @param merchant_url base URL of the backend serving the
   1310  *        "refund increase" request.
   1311  * @param reason refund justification, human-readable.
   1312  * @param order_id order id of the contract to refund.
   1313  * @param refund_amount amount to be refund-increased.
   1314  * @param http_code expected HTTP response code.
   1315  * @return the command.
   1316  */
   1317 struct TALER_TESTING_Command
   1318 TALER_TESTING_cmd_merchant_order_refund (
   1319   const char *label,
   1320   const char *merchant_url,
   1321   const char *reason,
   1322   const char *order_id,
   1323   const char *refund_amount,
   1324   unsigned int http_code);
   1325 
   1326 
   1327 /**
   1328  * Define a "refund order" CMD.
   1329  *
   1330  * @param label command label.
   1331  * @param merchant_url base URL of the backend serving the
   1332  *        "refund increase" request.
   1333  * @param order_ref order id of the contract to refund.
   1334  * @param http_code expected HTTP response code.
   1335  * @param ... NULL-terminated list of labels (const char *) of
   1336  *        refunds (commands) we expect to be aggregated in the transfer
   1337  *        (assuming @a http_code is #MHD_HTTP_OK). If @e refunded is false,
   1338  *        this parameter is ignored.
   1339  * @return the command.
   1340  */
   1341 struct TALER_TESTING_Command
   1342 TALER_TESTING_cmd_wallet_order_refund (
   1343   const char *label,
   1344   const char *merchant_url,
   1345   const char *order_ref,
   1346   unsigned int http_code,
   1347   ...);
   1348 
   1349 
   1350 /**
   1351  * Define a "DELETE order" CMD.
   1352  *
   1353  * @param label command label.
   1354  * @param merchant_url base URL of the merchant serving the
   1355  *        DELETE /instances/$ID request.
   1356  * @param order_id the ID of the instance to query
   1357  * @param http_status expected HTTP response code.
   1358  * @return the command.
   1359  */
   1360 struct TALER_TESTING_Command
   1361 TALER_TESTING_cmd_merchant_delete_order (
   1362   const char *label,
   1363   const char *merchant_url,
   1364   const char *order_id,
   1365   unsigned int http_status);
   1366 
   1367 
   1368 /* ******************* /transfers *************** */
   1369 
   1370 
   1371 /**
   1372  * Define a POST /transfers CMD.  Details like the WTID and
   1373  * other required parameters will be extracted from the bank
   1374  * history, using the latest transfer of the specified
   1375  * @a credit_amount to the @a merchant_url.
   1376  *
   1377  * @param label command label.
   1378  * @param auth credentials to access the exchange's bank account
   1379  * @param payto_uri URL of the exchange's bank account
   1380  * @param merchant_url base URL of the backend serving the
   1381  *        "refund increase" request.
   1382  * @param credit_amount amount credited
   1383  * @param http_code expected HTTP response code
   1384  * @param ... NULL-terminated list of labels (const char *) of
   1385  *        deposit (commands) we expect to be aggregated in the transfer
   1386  *        (assuming @a http_code is #MHD_HTTP_OK)
   1387  * @return the command.
   1388  */
   1389 struct TALER_TESTING_Command
   1390 TALER_TESTING_cmd_merchant_post_transfer (
   1391   const char *label,
   1392   const struct TALER_BANK_AuthenticationData *auth,
   1393   struct TALER_FullPayto payto_uri,
   1394   const char *merchant_url,
   1395   const char *credit_amount,
   1396   unsigned int http_code,
   1397   ...);
   1398 
   1399 
   1400 /**
   1401  * Define a POST /transfers CMD.  Details like the WTID and
   1402  * other required parameters are explicitly provided.
   1403  *
   1404  * @param label command label.
   1405  * @param merchant_url base URL of the backend
   1406  * @param payto_uri URL of the exchange's bank account
   1407  * @param credit_amount amount credited
   1408  * @param wtid wire transfer ID to use, NULL to pick one at random
   1409  * @param exchange_url URL of the exchange to use
   1410  * @param http_code expected HTTP response code
   1411  * @return the command.
   1412  */
   1413 struct TALER_TESTING_Command
   1414 TALER_TESTING_cmd_merchant_post_transfer2 (
   1415   const char *label,
   1416   const char *merchant_url,
   1417   struct TALER_FullPayto payto_uri,
   1418   const char *credit_amount,
   1419   const char *wtid,
   1420   const char *exchange_url,
   1421   unsigned int http_code);
   1422 
   1423 
   1424 /**
   1425  * We have discovered the @a serial for a POST transfer
   1426  * command. Store it (for the bank row trait).
   1427  *
   1428  * @param cmd command to update
   1429  * @param serial serial number to store (identifies the row)
   1430  */
   1431 void
   1432 TALER_TESTING_cmd_merchant_post_transfer_set_serial (
   1433   struct TALER_TESTING_Command *cmd,
   1434   uint64_t serial);
   1435 
   1436 
   1437 /**
   1438  * Define a GET /transfers CMD.
   1439  *
   1440  * @param label command label.
   1441  * @param merchant_url base URL of the backend serving the
   1442  *        "refund increase" request.
   1443  * @param payto_uri payto URI to filter by, NULL for no filter
   1444  * @param http_code expected HTTP response code
   1445  * @param ... NULL-terminated list of labels (const char *) of
   1446  *        transfer (commands) we expect to be returned in the list
   1447  *        (assuming @a http_code is #MHD_HTTP_OK)
   1448  * @return the command.
   1449  */
   1450 struct TALER_TESTING_Command
   1451 TALER_TESTING_cmd_merchant_get_transfers (
   1452   const char *label,
   1453   const char *merchant_url,
   1454   struct TALER_FullPayto payto_uri,
   1455   unsigned int http_code,
   1456   ...);
   1457 
   1458 
   1459 /**
   1460  * Define a "DELETE transfer" CMD.
   1461  *
   1462  * @param label command label.
   1463  * @param merchant_url base URL of the merchant for the
   1464  *        DELETE /transfers/$ID request.
   1465  * @param transfer_ref reference to a command that
   1466  *             yields the transfer ID to delete
   1467  * @param http_status expected HTTP response code.
   1468  * @return the command.
   1469  */
   1470 struct TALER_TESTING_Command
   1471 TALER_TESTING_cmd_merchant_delete_transfer (const char *label,
   1472                                             const char *merchant_url,
   1473                                             const char *transfer_ref,
   1474                                             unsigned int http_status);
   1475 
   1476 
   1477 /**
   1478  * Run a command to fetch the KYC status of a merchant.
   1479  *
   1480  * @param label the command label
   1481  * @param merchant_url base URL of the merchant
   1482  * @param instance_id instance to use, NULL if instance is part of @a merchant_url
   1483  * @param h_wire_ref label of command with a merchant wire hash trait
   1484  *        of the bank account to check KYC for; NULL to check all accounts
   1485  * @param exchange_url base URL of the exchange to check KYC status for
   1486  * @param lpt target for long polling
   1487  * @param expected_http_status expected HTTP status
   1488  * @param expected_kyc_state expected KYC state (only effective if @e expected_http_status is #MHD_HTTP_OK/#MHD_HTTP_ACCEPTED)
   1489  * @return the command
   1490  */
   1491 struct TALER_TESTING_Command
   1492 TALER_TESTING_cmd_merchant_kyc_get (
   1493   const char *label,
   1494   const char *merchant_url,
   1495   const char *instance_id,
   1496   const char *h_wire_ref,
   1497   const char *exchange_url,
   1498   enum TALER_EXCHANGE_KycLongPollTarget lpt,
   1499   unsigned int expected_http_status,
   1500   bool expected_kyc_state);
   1501 
   1502 
   1503 /* ****** OTP devices ******* */
   1504 
   1505 
   1506 /**
   1507  * Define a "POST /otp-devices" CMD.
   1508  *
   1509  * @param label command label.
   1510  * @param merchant_url base URL of the merchant serving the
   1511  *        POST /otps request.
   1512  * @param otp_id the ID of the otp device to modify
   1513  * @param otp_description description of the otp device
   1514  * @param otp_key base32-encoded key to verify the payment
   1515  * @param otp_alg is an option that show the amount of the order. it is linked with the @a otp_key
   1516  * @param otp_ctr counter to use (if in counter mode)
   1517  * @param http_status expected HTTP response code.
   1518  * @return the command.
   1519  */
   1520 struct TALER_TESTING_Command
   1521 TALER_TESTING_cmd_merchant_post_otp_devices (
   1522   const char *label,
   1523   const char *merchant_url,
   1524   const char *otp_id,
   1525   const char *otp_description,
   1526   const char *otp_key,
   1527   enum TALER_MerchantConfirmationAlgorithm otp_alg,
   1528   uint64_t otp_ctr,
   1529   unsigned int http_status);
   1530 
   1531 
   1532 /**
   1533  * Define a "PATCH /otp-devices/$ID" CMD.
   1534  *
   1535  * @param label command label.
   1536  * @param merchant_url base URL of the merchant serving the
   1537  *        PATCH /otp-devices request.
   1538  * @param otp_id the ID of the otp device to modify
   1539  * @param otp_description description of the otp device
   1540  * @param otp_key base32-encoded key to verify the payment
   1541  * @param otp_alg is an option that show the amount of the order. it is linked with the @a otp_key
   1542  * @param otp_ctr counter to use (if in counter mode)
   1543  * @param http_status expected HTTP response code.
   1544  * @return the command.
   1545  */
   1546 struct TALER_TESTING_Command
   1547 TALER_TESTING_cmd_merchant_patch_otp_device (
   1548   const char *label,
   1549   const char *merchant_url,
   1550   const char *otp_id,
   1551   const char *otp_description,
   1552   const char *otp_key,
   1553   enum TALER_MerchantConfirmationAlgorithm otp_alg,
   1554   uint64_t otp_ctr,
   1555   unsigned int http_status);
   1556 
   1557 
   1558 /**
   1559  * Define a "GET /otp-devices" CMD.
   1560  *
   1561  * @param label command label.
   1562  * @param merchant_url base URL of the merchant serving the
   1563  *        GET /otp-devices request.
   1564  * @param http_status expected HTTP response code.
   1565  * @param ... NULL-terminated list of labels (const char *) of
   1566  *        otp (commands) we expect to be returned in the list
   1567  *        (assuming @a http_code is #MHD_HTTP_OK)
   1568  * @return the command.
   1569  */
   1570 struct TALER_TESTING_Command
   1571 TALER_TESTING_cmd_merchant_get_otp_devices (const char *label,
   1572                                             const char *merchant_url,
   1573                                             unsigned int http_status,
   1574                                             ...);
   1575 
   1576 
   1577 /**
   1578  * Define a "GET otp device" CMD.
   1579  *
   1580  * @param label command label.
   1581  * @param merchant_url base URL of the merchant serving the
   1582  *        GET /otp-devices/$ID request.
   1583  * @param otp_id the ID of the otp to query
   1584  * @param http_status expected HTTP response code.
   1585  * @param otp_reference reference to a "POST /otp-devices" or "PATCH /otp-devices/$ID" CMD
   1586  *        that will provide what we expect the backend to return to us
   1587  * @return the command.
   1588  */
   1589 struct TALER_TESTING_Command
   1590 TALER_TESTING_cmd_merchant_get_otp_device (const char *label,
   1591                                            const char *merchant_url,
   1592                                            const char *otp_id,
   1593                                            unsigned int http_status,
   1594                                            const char *otp_reference);
   1595 
   1596 
   1597 /**
   1598  * Define a "DELETE otp device" CMD.
   1599  *
   1600  * @param label command label.
   1601  * @param merchant_url base URL of the merchant serving the
   1602  *        DELETE /otp-devices/$ID request.
   1603  * @param otp_id the ID of the otp to query
   1604  * @param http_status expected HTTP response code.
   1605  * @return the command.
   1606  */
   1607 struct TALER_TESTING_Command
   1608 TALER_TESTING_cmd_merchant_delete_otp_device (const char *label,
   1609                                               const char *merchant_url,
   1610                                               const char *otp_id,
   1611                                               unsigned int http_status);
   1612 
   1613 
   1614 /* ****** Templates ******* */
   1615 
   1616 /**
   1617  * Define a "POST /units" CMD.
   1618  *
   1619  * @param label command label.
   1620  * @param merchant_url base URL of the merchant serving the request.
   1621  * @param unit_id identifier of the unit.
   1622  * @param unit_name_long long label to store.
   1623  * @param unit_name_short short label to store.
   1624  * @param unit_allow_fraction whether fractional quantities are allowed.
   1625  * @param unit_precision_level fractional precision level.
   1626  * @param unit_active whether the unit starts active.
   1627  * @param unit_name_long_i18n optional translations for the long label.
   1628  * @param unit_name_short_i18n optional translations for the short label.
   1629  * @param http_status expected HTTP response code.
   1630  * @return the command.
   1631  */
   1632 struct TALER_TESTING_Command
   1633 TALER_TESTING_cmd_merchant_post_units (const char *label,
   1634                                        const char *merchant_url,
   1635                                        const char *unit_id,
   1636                                        const char *unit_name_long,
   1637                                        const char *unit_name_short,
   1638                                        bool unit_allow_fraction,
   1639                                        uint32_t unit_precision_level,
   1640                                        bool unit_active,
   1641                                        json_t *unit_name_long_i18n,
   1642                                        json_t *unit_name_short_i18n,
   1643                                        unsigned int http_status);
   1644 
   1645 
   1646 /**
   1647  * Define a "PATCH /units/$ID" CMD.
   1648  *
   1649  * @param label command label.
   1650  * @param merchant_url base URL of the merchant serving the request.
   1651  * @param unit_id identifier of the unit to patch.
   1652  * @param unit_name_long optional new long label (NULL to skip).
   1653  * @param unit_name_short optional new short label (NULL to skip).
   1654  * @param unit_name_long_i18n optional new long label translations (NULL to skip).
   1655  * @param unit_name_short_i18n optional new short label translations (NULL to skip).
   1656  * @param unit_allow_fraction optional pointer to new fractional flag (NULL to skip).
   1657  * @param unit_precision_level optional pointer to new precision level (NULL to skip).
   1658  * @param unit_active optional pointer to new active flag (NULL to skip).
   1659  * @param http_status expected HTTP response code.
   1660  * @return the command.
   1661  */
   1662 struct TALER_TESTING_Command
   1663 TALER_TESTING_cmd_merchant_patch_unit (
   1664   const char *label,
   1665   const char *merchant_url,
   1666   const char *unit_id,
   1667   const char *unit_name_long,
   1668   const char *unit_name_short,
   1669   json_t *unit_name_long_i18n,
   1670   json_t *unit_name_short_i18n,
   1671   const bool unit_allow_fraction,
   1672   const uint32_t unit_precision_level,
   1673   const bool unit_active,
   1674   unsigned int http_status);
   1675 
   1676 
   1677 /**
   1678  * Define a "GET /units" CMD.
   1679  *
   1680  * @param label command label.
   1681  * @param merchant_url base URL of the merchant serving the request.
   1682  * @param http_status expected HTTP response code.
   1683  * @param ... NULL-terminated list of labels (const char *) whose units must
   1684  *        appear in the response (verified when @a http_status is #MHD_HTTP_OK).
   1685  * @return the command.
   1686  */
   1687 struct TALER_TESTING_Command
   1688 TALER_TESTING_cmd_merchant_get_units (const char *label,
   1689                                       const char *merchant_url,
   1690                                       unsigned int http_status,
   1691                                       ...);
   1692 
   1693 
   1694 /**
   1695  * Define a "GET /units/$ID" CMD.
   1696  *
   1697  * @param label command label.
   1698  * @param merchant_url base URL of the merchant serving the request.
   1699  * @param unit_id identifier to fetch.
   1700  * @param http_status expected HTTP response code.
   1701  * @param reference optional label of a command providing expected unit traits.
   1702  * @return the command.
   1703  */
   1704 struct TALER_TESTING_Command
   1705 TALER_TESTING_cmd_merchant_get_unit (const char *label,
   1706                                      const char *merchant_url,
   1707                                      const char *unit_id,
   1708                                      unsigned int http_status,
   1709                                      const char *reference);
   1710 
   1711 
   1712 /**
   1713  * Define a "DELETE /units/$ID" CMD.
   1714  *
   1715  * @param label command label.
   1716  * @param merchant_url base URL of the merchant serving the request.
   1717  * @param unit_id identifier to delete.
   1718  * @param http_status expected HTTP response code.
   1719  * @return the command.
   1720  */
   1721 struct TALER_TESTING_Command
   1722 TALER_TESTING_cmd_merchant_delete_unit (const char *label,
   1723                                         const char *merchant_url,
   1724                                         const char *unit_id,
   1725                                         unsigned int http_status);
   1726 
   1727 
   1728 /**
   1729  * Define a "POST /templates" CMD.
   1730  *
   1731  * @param label command label.
   1732  * @param merchant_url base URL of the merchant serving the
   1733  *        POST /templates request.
   1734  * @param template_id the ID of the template to query
   1735  * @param template_description description of the template
   1736  * @param otp_id OTP device ID, NULL for none
   1737  * @param template_contract where the contract of the company is
   1738  * @param http_status expected HTTP response code.
   1739  * @return the command.
   1740  */
   1741 struct TALER_TESTING_Command
   1742 TALER_TESTING_cmd_merchant_post_templates2 (
   1743   const char *label,
   1744   const char *merchant_url,
   1745   const char *template_id,
   1746   const char *template_description,
   1747   const char *otp_id,
   1748   json_t *template_contract,
   1749   unsigned int http_status);
   1750 
   1751 
   1752 /**
   1753  * Define a "POST /templates" CMD, simple version
   1754  *
   1755  * @param label command label.
   1756  * @param merchant_url base URL of the merchant serving the
   1757  *        POST /templates request.
   1758  * @param template_id the ID of the template to create
   1759  * @param template_description description of the template
   1760  * @param http_status expected HTTP response code.
   1761  * @return the command.
   1762  */
   1763 struct TALER_TESTING_Command
   1764 TALER_TESTING_cmd_merchant_post_templates (const char *label,
   1765                                            const char *merchant_url,
   1766                                            const char *template_id,
   1767                                            const char *template_description,
   1768                                            unsigned int http_status);
   1769 
   1770 
   1771 /**
   1772  * Define a "PATCH /templates/$ID" CMD.
   1773  *
   1774  * @param label command label.
   1775  * @param merchant_url base URL of the merchant serving the
   1776  *        PATCH /template request.
   1777  * @param template_id the ID of the template to query
   1778  * @param template_description description of the template
   1779  * @param otp_id OTP device to use
   1780  * @param template_contract contract of the company
   1781  * @param http_status expected HTTP response code.
   1782  * @return the command.
   1783  */
   1784 struct TALER_TESTING_Command
   1785 TALER_TESTING_cmd_merchant_patch_template (
   1786   const char *label,
   1787   const char *merchant_url,
   1788   const char *template_id,
   1789   const char *template_description,
   1790   const char *otp_id,
   1791   json_t *template_contract,
   1792   unsigned int http_status);
   1793 
   1794 
   1795 /**
   1796  * Define a "GET /templates" CMD.
   1797  *
   1798  * @param label command label.
   1799  * @param merchant_url base URL of the merchant serving the
   1800  *        GET /templates request.
   1801  * @param http_status expected HTTP response code.
   1802  * @param ... NULL-terminated list of labels (const char *) of
   1803  *        template (commands) we expect to be returned in the list
   1804  *        (assuming @a http_code is #MHD_HTTP_OK)
   1805  * @return the command.
   1806  */
   1807 struct TALER_TESTING_Command
   1808 TALER_TESTING_cmd_merchant_get_templates (const char *label,
   1809                                           const char *merchant_url,
   1810                                           unsigned int http_status,
   1811                                           ...);
   1812 
   1813 
   1814 /**
   1815  * Define a "GET template" CMD.
   1816  *
   1817  * @param label command label.
   1818  * @param merchant_url base URL of the merchant serving the
   1819  *        GET /templates/$ID request.
   1820  * @param template_id the ID of the template to query
   1821  * @param http_status expected HTTP response code.
   1822  * @param template_reference reference to a "POST /templates" or "PATCH /templates/$ID" CMD
   1823  *        that will provide what we expect the backend to return to us
   1824  * @return the command.
   1825  */
   1826 struct TALER_TESTING_Command
   1827 TALER_TESTING_cmd_merchant_get_template (const char *label,
   1828                                          const char *merchant_url,
   1829                                          const char *template_id,
   1830                                          unsigned int http_status,
   1831                                          const char *template_reference);
   1832 
   1833 
   1834 /**
   1835  * Define a "DELETE template" CMD.
   1836  *
   1837  * @param label command label.
   1838  * @param merchant_url base URL of the merchant serving the
   1839  *        DELETE /templates/$ID request.
   1840  * @param template_id the ID of the template to query
   1841  * @param http_status expected HTTP response code.
   1842  * @return the command.
   1843  */
   1844 struct TALER_TESTING_Command
   1845 TALER_TESTING_cmd_merchant_delete_template (const char *label,
   1846                                             const char *merchant_url,
   1847                                             const char *template_id,
   1848                                             unsigned int http_status);
   1849 
   1850 
   1851 /**
   1852  * Define a "POST /using-templates" CMD, simple version
   1853  *
   1854  * @param label command label.
   1855  * @param template_ref label of command that created the template to use
   1856  * @param otp_ref label of command that created OTP device we use (or NULL for no OTP)
   1857  * @param merchant_url base URL of the merchant serving the
   1858  *        POST /using-templates request.
   1859  * @param using_template_id template ID to use
   1860  * @param summary given by the customer to know what they did pay
   1861  * @param amount given by the customer to pay
   1862  * @param refund_deadline refund deadline to use for the contract
   1863  * @param pay_deadline pay deadline to use for the contract
   1864  * @param http_status expected HTTP response code.
   1865  * @return the command.
   1866  */
   1867 struct TALER_TESTING_Command
   1868 TALER_TESTING_cmd_merchant_post_using_templates (
   1869   const char *label,
   1870   const char *template_ref,
   1871   const char *otp_ref,
   1872   const char *merchant_url,
   1873   const char *using_template_id,
   1874   const char *summary,
   1875   const char *amount,
   1876   struct GNUNET_TIME_Timestamp refund_deadline,
   1877   struct GNUNET_TIME_Timestamp pay_deadline,
   1878   unsigned int http_status);
   1879 
   1880 
   1881 /* ****** Token Families ******* */
   1882 
   1883 
   1884 /**
   1885  * Define a "POST /tokenfamilies" CMD.
   1886  *
   1887  * @param label command label.
   1888  * @param merchant_url base URL of the merchant serving the
   1889  *       POST /tokenfamilies request.
   1890  * @param http_status expected HTTP response code.
   1891  * @param slug slug of the token family.
   1892  * @param name name of the token family.
   1893  * @param description description of the token family.
   1894  * @param description_i18n internationalized description of the token family.
   1895  * @param valid_after start of the validity time of the token family.
   1896  * @param valid_before end of the validity time of the token family.
   1897  * @param duration validity duration of an issued token of the token family.
   1898  * @param rounding to multiples of what duration should start times be rounded
   1899  * @param kind kind of the token family. either "subscription" or "discount".
   1900  * @return the command.
   1901  */
   1902 struct TALER_TESTING_Command
   1903 TALER_TESTING_cmd_merchant_post_tokenfamilies (
   1904   const char *label,
   1905   const char *merchant_url,
   1906   unsigned int http_status,
   1907   const char *slug,
   1908   const char *name,
   1909   const char *description,
   1910   json_t *description_i18n,
   1911   struct GNUNET_TIME_Timestamp valid_after,
   1912   struct GNUNET_TIME_Timestamp valid_before,
   1913   struct GNUNET_TIME_Relative duration,
   1914   struct GNUNET_TIME_Relative rounding,
   1915   const char *kind);
   1916 
   1917 /* ****** Webhooks ******* */
   1918 
   1919 
   1920 /**
   1921  * Define a "POST /webhooks" CMD.
   1922  *
   1923  * @param label command label.
   1924  * @param merchant_url base URL of the merchant serving the
   1925  *        POST /webhooks request.
   1926  * @param webhook_id the ID of the webhook to query
   1927  * @param event_type event of the webhook
   1928  * @param url use by the customer
   1929  * @param http_method use by the merchant
   1930  * @param header_template of the webhook
   1931  * @param body_template of the webhook
   1932  * @param http_status expected HTTP response code.
   1933  * @return the command.
   1934  */
   1935 struct TALER_TESTING_Command
   1936 TALER_TESTING_cmd_merchant_post_webhooks2 (
   1937   const char *label,
   1938   const char *merchant_url,
   1939   const char *webhook_id,
   1940   const char *event_type,
   1941   const char *url,
   1942   const char *http_method,
   1943   const char *header_template,
   1944   const char *body_template,
   1945   unsigned int http_status);
   1946 
   1947 
   1948 /**
   1949  * Define a "POST /webhooks" CMD, simple version
   1950  *
   1951  * @param label command label.
   1952  * @param merchant_url base URL of the merchant serving the
   1953  *        POST /webhooks request.
   1954  * @param webhook_id the ID of the webhook to query
   1955  * @param event_type event of the webhook
   1956  * @param http_status expected HTTP response code.
   1957  * @return the command.
   1958  */
   1959 struct TALER_TESTING_Command
   1960 TALER_TESTING_cmd_merchant_post_webhooks (const char *label,
   1961                                           const char *merchant_url,
   1962                                           const char *webhook_id,
   1963                                           const char *event_type,
   1964                                           unsigned int http_status);
   1965 
   1966 
   1967 /**
   1968  * Define a "PATCH /webhooks/$ID" CMD.
   1969  *
   1970  * @param label command label.
   1971  * @param merchant_url base URL of the merchant serving the
   1972  *        PATCH /webhook request.
   1973  * @param webhook_id the ID of the webhook to query
   1974  * @param event_type event of the webhook
   1975  * @param url use by the customer
   1976  * @param http_method use by the merchant
   1977  * @param header_template of the webhook
   1978  * @param body_template of the webhook
   1979  * @param http_status expected HTTP response code.
   1980  * @return the command.
   1981  */
   1982 struct TALER_TESTING_Command
   1983 TALER_TESTING_cmd_merchant_patch_webhook (
   1984   const char *label,
   1985   const char *merchant_url,
   1986   const char *webhook_id,
   1987   const char *event_type,
   1988   const char *url,
   1989   const char *http_method,
   1990   const char *header_template,
   1991   const char *body_template,
   1992   unsigned int http_status);
   1993 
   1994 
   1995 /**
   1996  * Define a "GET /webhooks" CMD.
   1997  *
   1998  * @param label command label.
   1999  * @param merchant_url base URL of the merchant serving the
   2000  *        GET /webhooks request.
   2001  * @param http_status expected HTTP response code.
   2002  * @param ... NULL-terminated list of labels (const char *) of
   2003  *        webhook (commands) we expect to be returned in the list
   2004  *        (assuming @a http_code is #MHD_HTTP_OK)
   2005  * @return the command.
   2006  */
   2007 struct TALER_TESTING_Command
   2008 TALER_TESTING_cmd_merchant_get_webhooks (const char *label,
   2009                                          const char *merchant_url,
   2010                                          unsigned int http_status,
   2011                                          ...);
   2012 
   2013 
   2014 /**
   2015  * Define a "GET webhook" CMD.
   2016  *
   2017  * @param label command label.
   2018  * @param merchant_url base URL of the merchant serving the
   2019  *        GET /templates/$ID request.
   2020  * @param webhook_id the ID of the webhook to query
   2021  * @param http_status expected HTTP response code.
   2022  * @param webhook_reference reference to a "POST /webhooks" or "PATCH /webhooks/$ID" CMD
   2023  *        that will provide what we expect the backend to return to us
   2024  * @return the command.
   2025  */
   2026 struct TALER_TESTING_Command
   2027 TALER_TESTING_cmd_merchant_get_webhook (const char *label,
   2028                                         const char *merchant_url,
   2029                                         const char *webhook_id,
   2030                                         unsigned int http_status,
   2031                                         const char *webhook_reference);
   2032 
   2033 
   2034 /**
   2035  * Define a "DELETE webhook" CMD.
   2036  *
   2037  * @param label command label.
   2038  * @param merchant_url base URL of the merchant serving the
   2039  *        DELETE /webhooks/$ID request.
   2040  * @param webhook_id the ID of the webhook to query
   2041  * @param http_status expected HTTP response code.
   2042  * @return the command.
   2043  */
   2044 struct TALER_TESTING_Command
   2045 TALER_TESTING_cmd_merchant_delete_webhook (const char *label,
   2046                                            const char *merchant_url,
   2047                                            const char *webhook_id,
   2048                                            unsigned int http_status);
   2049 
   2050 /**
   2051  * Command to run the 'taler-merchant-webhook' program.
   2052  *
   2053  * @param label command label.
   2054  * @param config_filename configuration file used by the webhook.
   2055  */
   2056 struct TALER_TESTING_Command
   2057 TALER_TESTING_cmd_webhook (const char *label,
   2058                            const char *config_filename);
   2059 
   2060 
   2061 /**
   2062  * Command to run the 'taler-merchant-depositcheck' program.
   2063  *
   2064  * @param label command label.
   2065  * @param config_filename configuration file used by the deposit check helper.
   2066  */
   2067 struct TALER_TESTING_Command
   2068 TALER_TESTING_cmd_depositcheck (const char *label,
   2069                                 const char *config_filename);
   2070 
   2071 
   2072 /**
   2073  * Command to run the 'taler-merchant-exchange' program.
   2074  *
   2075  * @param label command label.
   2076  * @param config_filename configuration file used by the webhook.
   2077  */
   2078 struct TALER_TESTING_Command
   2079 TALER_TESTING_cmd_run_tme (const char *label,
   2080                            const char *config_filename);
   2081 
   2082 
   2083 /**
   2084  * This function is used to start the web server.
   2085  *
   2086  * @param label command label
   2087  * @param port is the port of the web server
   2088  */
   2089 struct TALER_TESTING_Command
   2090 TALER_TESTING_cmd_testserver (const char *label,
   2091                               uint16_t port);
   2092 
   2093 
   2094 /**
   2095  * This function is used to check the web server got the
   2096  * expected request from the web hook.
   2097  *
   2098  * @param label command label
   2099  * @param ref_operation reference to command to the previous set server status operation.
   2100  * @param index index to know which web server we check.
   2101  */
   2102 struct TALER_TESTING_Command
   2103 TALER_TESTING_cmd_checkserver (const char *label,
   2104                                const char *ref_operation,
   2105                                unsigned int index);
   2106 
   2107 
   2108 /**
   2109  * This function is used to check that the web server
   2110  * got the expected request from the web hook.
   2111  *
   2112  * @param label command label
   2113  * @param ref_operation reference to command to the previous set server status operation.
   2114  * @param index index to know which web server we check.
   2115  * @param expected_url url of the webhook
   2116  * @param expected_method method of the webhook
   2117  * @param expected_header header of the webhook
   2118  * @param expected_body body of the webhook
   2119  */
   2120 struct TALER_TESTING_Command
   2121 TALER_TESTING_cmd_checkserver2 (const char *label,
   2122                                 const char *ref_operation,
   2123                                 unsigned int index,
   2124                                 const char *expected_url,
   2125                                 const char *expected_method,
   2126                                 const char *expected_header,
   2127                                 const char *expected_body);
   2128 
   2129 
   2130 #ifdef HAVE_DONAU_DONAU_SERVICE_H
   2131 /**
   2132  * This function is the similar to the TALER_TESSTING_cmd_charity_post from DONAU
   2133  * with only difference that it reuses the merchant public key, from the merchant test-suite.
   2134  *
   2135  * @param label command label
   2136  * @param name name of the charity
   2137  * @param url url of the charity
   2138  * @param max_per_year maximum amount of donations per year
   2139  * @param bearer
   2140  * @param merchant_reference reference to fetch the merchant public key
   2141  * @param expected_response_code expected HTTP response code
   2142  * @return
   2143  */
   2144 struct TALER_TESTING_Command
   2145 TALER_TESTING_cmd_charity_post_merchant (
   2146   const char *label,
   2147   const char *name,
   2148   const char *url,
   2149   const char *max_per_year,
   2150   const struct DONAU_BearerToken *bearer,
   2151   const char *merchant_reference,
   2152   unsigned int expected_response_code);
   2153 
   2154 #endif /* HAVE_DONAU_DONAU_SERVICE_H */
   2155 
   2156 /**
   2157  * Define a "GET /donau" CMD.
   2158  *
   2159  * @param label command label.
   2160  * @param url base URL of the Donau we are looking for instances of.
   2161  * @param instance_count number of instances we expect to be returned.
   2162  * @param expected_http_status expected HTTP response code.
   2163  * @param ... NULL-terminated list of labels (const char *) of
   2164  *        donau instances (commands) we expect to be returned in the list
   2165  * @return the command.
   2166  */
   2167 struct TALER_TESTING_Command
   2168 TALER_TESTING_cmd_merchant_get_donau_instances (const char *label,
   2169                                                 const char *url,
   2170                                                 unsigned int instance_count,
   2171                                                 unsigned int
   2172                                                 expected_http_status,
   2173                                                 ...);
   2174 
   2175 
   2176 /**
   2177  * Define a "POST /donau" CMD.
   2178  *
   2179  * @param label command label.
   2180  * @param url base URL of the Donau service serving the
   2181  *        GET /donau_instances request.
   2182  * @param merchant_reference string reference to get the testing traits
   2183  * @param expected_http_status expected HTTP response code.
   2184  * @param ... NULL-terminated list of labels (const char *) of
   2185  *        donau instances (commands) we expect to be returned in the list
   2186  *        (assuming @a expected_http_status is #MHD_HTTP_OK)
   2187  * @return the command.
   2188  */
   2189 struct TALER_TESTING_Command
   2190 TALER_TESTING_cmd_merchant_post_donau_instance (const char *label,
   2191                                                 const char *url,
   2192                                                 const char *merchant_reference,
   2193                                                 unsigned int
   2194                                                 expected_http_status,
   2195                                                 ...);
   2196 
   2197 
   2198 /**
   2199  * Define a "DELETE /donau/$charity_id" CMD.
   2200  *
   2201  * @param label command label.
   2202  * @param url base URL of the Donau service serving the
   2203  *        DELETE /donau/$charity_id request.
   2204  * @param charity_id the ID of the charity to delete.
   2205  * @param expected_http_status expected HTTP response code.
   2206  * @return the command.
   2207  */
   2208 struct TALER_TESTING_Command
   2209 TALER_TESTING_cmd_merchant_delete_donau_instance (const char *label,
   2210                                                   const char *url,
   2211                                                   uint64_t charity_id,
   2212                                                   unsigned int
   2213                                                   expected_http_status);
   2214 
   2215 /**
   2216  * This function is used to check the statistics counter API
   2217  *
   2218  * @param label command label
   2219  * @param merchant_url base URL of the merchant serving the API
   2220  * @param slug base statistics slug
   2221  * @param buckets_length expected length of buckets array
   2222  * @param intervals_length expected length of intervals array
   2223  * @param http_status expected HTTP response code.
   2224  */
   2225 struct TALER_TESTING_Command
   2226 TALER_TESTING_cmd_merchant_get_statisticscounter (const char *label,
   2227                                                   const char *merchant_url,
   2228                                                   const char *slug,
   2229                                                   uint64_t buckets_length,
   2230                                                   uint64_t intervals_length,
   2231                                                   unsigned int http_status);
   2232 
   2233 /**
   2234  * This function is used to check the statistics amount API
   2235  *
   2236  * @param label command label
   2237  * @param merchant_url base URL of the merchant serving the API
   2238  * @param slug base statistics slug
   2239  * @param buckets_length expected length of buckets array
   2240  * @param intervals_length expected length of intervals array
   2241  * @param http_status expected HTTP response code.
   2242  */
   2243 struct TALER_TESTING_Command
   2244 TALER_TESTING_cmd_merchant_get_statisticsamount (const char *label,
   2245                                                  const char *merchant_url,
   2246                                                  const char *slug,
   2247                                                  uint64_t buckets_length,
   2248                                                  uint64_t intervals_length,
   2249                                                  unsigned int http_status);
   2250 
   2251 /* ****** Specific traits supported by this component ******* */
   2252 
   2253 
   2254 /**
   2255  * Call @a op on all simple traits.
   2256  *
   2257  * @param op macro to call
   2258  */
   2259 // FIXME: rename: refund_entry->refund_detail
   2260 #define TALER_MERCHANT_TESTING_SIMPLE_TRAITS(op) \
   2261   op (claim_nonce, const struct GNUNET_CRYPTO_EddsaPublicKey) \
   2262   op (pickup_id, const struct TALER_PickupIdentifierP) \
   2263   op (instance_name, const char) \
   2264   op (instance_id, const char) \
   2265   op (address, const json_t) \
   2266   op (product_description, const char) \
   2267   op (product_image, const char) \
   2268   op (product_stock, const int64_t) \
   2269   op (product_unit_total_stock, const char) \
   2270   op (product_unit_precision_level, const uint32_t) \
   2271   op (product_unit_allow_fraction, const bool) \
   2272   op (product_unit, const char) \
   2273   op (product_id, const char) \
   2274   op (unit_id, const char) \
   2275   op (unit_name_long, const char) \
   2276   op (unit_name_short, const char) \
   2277   op (unit_allow_fraction, const bool) \
   2278   op (unit_precision_level, const uint32_t) \
   2279   op (unit_active, const bool) \
   2280   op (unit_builtin, const bool) \
   2281   op (unit_name_long_i18n, const json_t) \
   2282   op (unit_name_short_i18n, const json_t) \
   2283   op (reason, const char) \
   2284   op (lock_uuid, const char) \
   2285   op (auth_token, const char) \
   2286   op (bearer_token, const char) \
   2287   op (paths_length, const uint32_t) \
   2288   op (payto_length, const uint32_t) \
   2289   op (num_planchets, const uint32_t) \
   2290   op (i18n_description, const json_t) \
   2291   op (taxes, const json_t)      \
   2292   op (fee, const struct TALER_Amount) \
   2293   op (use_stefan, const bool) \
   2294   op (jurisdiction, const json_t) \
   2295   op (wire_delay, const struct GNUNET_TIME_Relative) \
   2296   op (pay_delay, const struct GNUNET_TIME_Relative) \
   2297   op (refund_entry, const struct TALER_MERCHANT_RefundDetail) \
   2298   op (order_terms, const json_t) \
   2299   op (h_contract_terms, const struct TALER_PrivateContractHashP) \
   2300   op (h_wire, const struct TALER_MerchantWireHashP) \
   2301   op (proposal_reference, const char) \
   2302   op (template_description, const char) \
   2303   op (otp_device_description, const char) \
   2304   op (otp_id, const char) \
   2305   op (otp_key, const char) \
   2306   op (otp_alg, const enum TALER_MerchantConfirmationAlgorithm) \
   2307   op (template_id, const char) \
   2308   op (template_contract, const json_t) \
   2309   op (event_type, const char)   \
   2310   op (webhook_id, const char) \
   2311   op (merchant_base_url, const char) \
   2312   op (url, const char) \
   2313   op (http_method, const char)   \
   2314   op (header_template, const char)   \
   2315   op (body_template, const char)   \
   2316   op (summary, const char)   \
   2317   op (token_family_slug, const char)   \
   2318   op (token_family_duration, const struct GNUNET_TIME_Relative)   \
   2319   op (token_family_kind, const char)
   2320 
   2321 
   2322 /**
   2323  * Call @a op on all indexed traits.
   2324  *
   2325  * @param op macro to call
   2326  */
   2327 #define TALER_MERCHANT_TESTING_INDEXED_TRAITS(op) \
   2328   op (coin_reference, const char) \
   2329   op (paths, const char) \
   2330   op (payto_uris, const struct TALER_FullPayto) \
   2331   op (h_wires, const struct TALER_MerchantWireHashP) \
   2332   op (amounts, const struct TALER_Amount)         \
   2333   op (urls, const char) \
   2334   op (http_methods, const char)   \
   2335   op (http_header, const char)   \
   2336   op (http_body, const void)   \
   2337   op (http_body_size, const size_t)   \
   2338   op (planchet_secrets, const struct TALER_PlanchetMasterSecretP)   \
   2339   op (token_priv, const struct TALER_TokenUsePrivateKeyP)   \
   2340   op (token_issue_sig, const struct TALER_TokenIssueSignature)   \
   2341   op (token_issue_pub, const struct TALER_TokenIssuePublicKey)
   2342 
   2343 
   2344 TALER_MERCHANT_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT)
   2345 TALER_MERCHANT_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_DECL_INDEXED_TRAIT)
   2346 
   2347 
   2348 #endif