merchant

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

taler_merchant_testing_lib.h (87954B)


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