merchant

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

test_merchant_api.c (140036B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014-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  * @file test_merchant_api.c
     21  * @brief testcase to test exchange's HTTP API interface
     22  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
     23  * @author Christian Grothoff
     24  * @author Marcello Stanisci
     25  */
     26 #include "taler/platform.h"
     27 #include <gnunet/gnunet_time_lib.h>
     28 #include <taler/taler_util.h>
     29 #include <taler/taler_signatures.h>
     30 #include <taler/taler_exchange_service.h>
     31 #include <taler/taler_json_lib.h>
     32 #include <gnunet/gnunet_util_lib.h>
     33 #include <gnunet/gnunet_testing_lib.h>
     34 #include <microhttpd.h>
     35 #include <taler/taler_bank_service.h>
     36 #include <taler/taler_fakebank_lib.h>
     37 #include <taler/taler_testing_lib.h>
     38 #include <taler/taler_error_codes.h>
     39 #include "taler/taler_merchant_util.h"
     40 #include "taler/taler_merchant_testing_lib.h"
     41 #include <donau/donau_testing_lib.h>
     42 
     43 
     44 /**
     45  * The 'poll-orders-conclude-1' and other 'conclude'
     46  * commands should NOT wait for this timeout!
     47  */
     48 #define POLL_ORDER_TIMEOUT \
     49         GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
     50 
     51 /**
     52  * The 'poll-orders-conclude-1x' and other 'conclude'
     53  * commands that should (!) wait for this timeout! Hence,
     54  * here we use a short value!
     55  */
     56 #define POLL_ORDER_SHORT_TIMEOUT \
     57         GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
     58 
     59 /**
     60  * Configuration file we use.  One (big) configuration is used
     61  * for the various components for this test.
     62  */
     63 static char *config_file;
     64 
     65 /**
     66  * Exchange base URL.  Could also be taken from config.
     67  */
     68 #define EXCHANGE_URL "http://localhost:8081/"
     69 
     70 /**
     71  * Payto URI of the customer (payer).
     72  */
     73 static struct TALER_FullPayto payer_payto;
     74 
     75 /**
     76  * Payto URI of the exchange (escrow account).
     77  */
     78 static struct TALER_FullPayto exchange_payto;
     79 
     80 /**
     81  * Payto URI of the merchant (receiver).
     82  */
     83 static struct TALER_FullPayto merchant_payto;
     84 
     85 /**
     86  * Credentials for the test.
     87  */
     88 static struct TALER_TESTING_Credentials cred;
     89 
     90 /**
     91  * Merchant base URL.
     92  */
     93 static const char *merchant_url;
     94 
     95 /**
     96  * Merchant instance "i1a" base URL.
     97  */
     98 static char *merchant_url_i1a;
     99 
    100 /**
    101  * Account number of the exchange at the bank.
    102  */
    103 #define EXCHANGE_ACCOUNT_NAME "2"
    104 
    105 /**
    106  * Account number of some user.
    107  */
    108 #define USER_ACCOUNT_NAME "62"
    109 
    110 /**
    111  * Account number of some other user.
    112  */
    113 #define USER_ACCOUNT_NAME2 "63"
    114 
    115 /**
    116  * Account number used by the merchant
    117  */
    118 #define MERCHANT_ACCOUNT_NAME "3"
    119 
    120 static const char *order_1_transfers[] = {
    121   "post-transfer-1",
    122   NULL
    123 };
    124 
    125 static const char *order_1_forgets_1[] = {
    126   "forget-1",
    127   NULL
    128 };
    129 
    130 static const char *order_1_forgets_2[] = {
    131   "forget-1",
    132   "forget-order-array-elem",
    133   NULL
    134 };
    135 
    136 static const char *order_1_forgets_3[] = {
    137   "forget-1",
    138   "forget-order-array-elem",
    139   "forget-order-array-wc",
    140   NULL
    141 };
    142 
    143 static const struct TALER_TESTING_ProductUnitExpectations
    144   expect_unicorn_defaults = {
    145   .have_unit_allow_fraction = true,
    146   .unit_allow_fraction = true,
    147   .have_unit_precision_level = true,
    148   .unit_precision_level = 1
    149 };
    150 
    151 static const struct TALER_TESTING_ProductUnitExpectations
    152   expect_unicorn_patched = {
    153   .have_unit_allow_fraction = true,
    154   .unit_allow_fraction = false,
    155   .have_unit_precision_level = true,
    156   .unit_precision_level = 0
    157 };
    158 
    159 /**
    160  * Build an array of selected product IDs.
    161  *
    162  * @param first first product id
    163  * @param second second product id or NULL
    164  * @return JSON array of product ids
    165  */
    166 static json_t *
    167 make_selected_products (const char *first,
    168                         const char *second)
    169 {
    170   json_t *arr;
    171 
    172   arr = json_array ();
    173   GNUNET_assert (NULL != arr);
    174   if (NULL != first)
    175     GNUNET_assert (0 ==
    176                    json_array_append_new (arr,
    177                                           json_string (first)));
    178   if (NULL != second)
    179     GNUNET_assert (0 ==
    180                    json_array_append_new (arr,
    181                                           json_string (second)));
    182   return arr;
    183 }
    184 
    185 
    186 /**
    187  * Build an array of selected category IDs.
    188  *
    189  * @param first first category id
    190  * @param second second category id or 0
    191  * @return JSON array of category ids
    192  */
    193 static json_t *
    194 make_selected_categories (uint64_t first,
    195                           uint64_t second)
    196 {
    197   json_t *arr;
    198 
    199   arr = json_array ();
    200   GNUNET_assert (NULL != arr);
    201   if (0 != first)
    202     GNUNET_assert (0 ==
    203                    json_array_append_new (arr,
    204                                           json_integer (first)));
    205   if (0 != second)
    206     GNUNET_assert (0 ==
    207                    json_array_append_new (arr,
    208                                           json_integer (second)));
    209   return arr;
    210 }
    211 
    212 
    213 /**
    214  * Build an inventory selection array.
    215  *
    216  * @param first_id first product id
    217  * @param first_qty first quantity
    218  * @param second_id second product id or NULL
    219  * @param second_qty second quantity or NULL
    220  * @return JSON array of inventory selections
    221  */
    222 static json_t *
    223 make_inventory_selection (const char *first_id,
    224                           const char *first_qty,
    225                           const char *second_id,
    226                           const char *second_qty)
    227 {
    228   json_t *arr;
    229 
    230   arr = json_array ();
    231   GNUNET_assert (NULL != arr);
    232   if (NULL != first_id)
    233     GNUNET_assert (0 ==
    234                    json_array_append_new (
    235                      arr,
    236                      GNUNET_JSON_PACK (
    237                        GNUNET_JSON_pack_string ("product_id",
    238                                                 first_id),
    239                        GNUNET_JSON_pack_string ("quantity",
    240                                                 first_qty))));
    241   if (NULL != second_id)
    242     GNUNET_assert (0 ==
    243                    json_array_append_new (
    244                      arr,
    245                      GNUNET_JSON_PACK (
    246                        GNUNET_JSON_pack_string ("product_id",
    247                                                 second_id),
    248                        GNUNET_JSON_pack_string ("quantity",
    249                                                 second_qty))));
    250   return arr;
    251 }
    252 
    253 
    254 /**
    255  * Execute the taler-merchant-webhook command with
    256  * our configuration file.
    257  *
    258  * @param label label to use for the command.
    259  */
    260 static struct TALER_TESTING_Command
    261 cmd_webhook (const char *label)
    262 {
    263   return TALER_TESTING_cmd_webhook (label, config_file);
    264 }
    265 
    266 
    267 /**
    268  * Execute the taler-exchange-wirewatch command with
    269  * our configuration file.
    270  *
    271  * @param label label to use for the command.
    272  */
    273 static struct TALER_TESTING_Command
    274 cmd_exec_wirewatch (const char *label)
    275 {
    276   return TALER_TESTING_cmd_exec_wirewatch (label,
    277                                            config_file);
    278 }
    279 
    280 
    281 /**
    282  * Execute the taler-exchange-aggregator, closer and transfer commands with
    283  * our configuration file.
    284  *
    285  * @param label label to use for the command.
    286  */
    287 #define CMD_EXEC_AGGREGATOR(label) \
    288         TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
    289         TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
    290 
    291 
    292 /**
    293  * Run wire transfer of funds from some user's account to the
    294  * exchange.
    295  *
    296  * @param label label to use for the command.
    297  * @param amount amount to transfer, i.e. "EUR:1"
    298  * @param url exchange_url
    299  */
    300 static struct TALER_TESTING_Command
    301 cmd_transfer_to_exchange (const char *label,
    302                           const char *amount)
    303 {
    304   return TALER_TESTING_cmd_admin_add_incoming (label,
    305                                                amount,
    306                                                &cred.ba,
    307                                                payer_payto);
    308 }
    309 
    310 
    311 /**
    312  * Main function that will tell the interpreter what commands to
    313  * run.
    314  *
    315  * @param cls closure
    316  */
    317 static void
    318 run (void *cls,
    319      struct TALER_TESTING_Interpreter *is)
    320 {
    321   struct TALER_TESTING_Command get_private_order_id[] = {
    322     TALER_TESTING_cmd_merchant_post_instances (
    323       "instance-create-admin",
    324       merchant_url,
    325       "admin",
    326       MHD_HTTP_NO_CONTENT),
    327     TALER_TESTING_cmd_merchant_kyc_get (
    328       "instance-create-kyc-no-accounts",
    329       merchant_url,
    330       NULL,
    331       NULL,
    332       EXCHANGE_URL,
    333       TALER_EXCHANGE_KLPT_NONE,
    334       MHD_HTTP_NO_CONTENT,
    335       false),
    336     TALER_TESTING_cmd_merchant_post_account (
    337       "instance-create-default-account",
    338       merchant_url,
    339       merchant_payto,
    340       NULL, NULL,
    341       MHD_HTTP_OK),
    342     TALER_TESTING_cmd_merchant_kyc_get (
    343       "instance-create-kyc-0",
    344       merchant_url,
    345       NULL,
    346       NULL,
    347       EXCHANGE_URL,
    348       TALER_EXCHANGE_KLPT_NONE,
    349       MHD_HTTP_OK,
    350       true),
    351     TALER_TESTING_cmd_merchant_post_orders_no_claim (
    352       "create-proposal-bad-currency",
    353       merchant_url,
    354       MHD_HTTP_CONFLICT,
    355       "4",
    356       GNUNET_TIME_UNIT_ZERO_TS,
    357       GNUNET_TIME_UNIT_FOREVER_TS,
    358       "XXX:5.0"),
    359     TALER_TESTING_cmd_merchant_post_orders_no_claim (
    360       "create-proposal-4",
    361       merchant_url,
    362       MHD_HTTP_OK,
    363       "4",
    364       GNUNET_TIME_UNIT_ZERO_TS,
    365       GNUNET_TIME_UNIT_FOREVER_TS,
    366       "EUR:5.0"),
    367     TALER_TESTING_cmd_merchant_get_order (
    368       "get-order-4",
    369       merchant_url,
    370       "create-proposal-4",
    371       TALER_MERCHANT_OSC_UNPAID,
    372       false,
    373       MHD_HTTP_OK,
    374       NULL),
    375     TALER_TESTING_cmd_merchant_delete_order (
    376       "delete-order-4",
    377       merchant_url,
    378       "4",
    379       MHD_HTTP_NO_CONTENT),
    380     TALER_TESTING_cmd_merchant_purge_instance (
    381       "purge-admin",
    382       merchant_url,
    383       "admin",
    384       MHD_HTTP_NO_CONTENT),
    385     TALER_TESTING_cmd_end ()
    386   };
    387 
    388   struct TALER_TESTING_Command pay[] = {
    389     /**
    390      * Move money to the exchange's bank account.
    391      */
    392     cmd_transfer_to_exchange ("create-reserve-1",
    393                               "EUR:10.02"),
    394     /**
    395      * Make a reserve exist, according to the previous transfer.
    396      */
    397     cmd_exec_wirewatch ("wirewatch-1"),
    398     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2",
    399                                                  "EUR:10.02",
    400                                                  payer_payto,
    401                                                  exchange_payto,
    402                                                  "create-reserve-1"),
    403     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
    404                                        "create-reserve-1",
    405                                        "EUR:5",
    406                                        0,
    407                                        MHD_HTTP_OK),
    408     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
    409                                        "create-reserve-1",
    410                                        "EUR:5",
    411                                        0,
    412                                        MHD_HTTP_OK),
    413     TALER_TESTING_cmd_merchant_get_orders ("get-orders-empty",
    414                                            merchant_url,
    415                                            MHD_HTTP_OK,
    416                                            NULL),
    417     /**
    418      * Check the reserve is depleted.
    419      */
    420     TALER_TESTING_cmd_status ("withdraw-status-1",
    421                               "create-reserve-1",
    422                               "EUR:0",
    423                               MHD_HTTP_OK),
    424     TALER_TESTING_cmd_merchant_delete_order ("delete-order-nx",
    425                                              merchant_url,
    426                                              "1",
    427                                              MHD_HTTP_NOT_FOUND),
    428     TALER_TESTING_cmd_poll_orders_start ("poll-orders-1-start",
    429                                          merchant_url,
    430                                          POLL_ORDER_TIMEOUT),
    431     TALER_TESTING_cmd_merchant_claim_order ("claim-order-nx",
    432                                             merchant_url,
    433                                             MHD_HTTP_NOT_FOUND,
    434                                             NULL,
    435                                             "1"),
    436     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1",
    437                                              cred.cfg,
    438                                              merchant_url,
    439                                              MHD_HTTP_OK,
    440                                              "1",
    441                                              GNUNET_TIME_UNIT_ZERO_TS,
    442                                              GNUNET_TIME_UNIT_FOREVER_TS,
    443                                              true,
    444                                              "EUR:5.0",
    445                                              "x-taler-bank",
    446                                              "",
    447                                              "",
    448                                              NULL),
    449     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-pay-w1",
    450                                               merchant_url,
    451                                               "webhook-pay-1",
    452                                               "pay",
    453                                               MHD_HTTP_NO_CONTENT),
    454     TALER_TESTING_cmd_merchant_post_webhooks2 ("post-webhooks-settled-w1",
    455                                                merchant_url,
    456                                                "webhook-settled-1",
    457                                                "order_settled",
    458                                                "http://localhost:12345/",
    459                                                "POST",
    460                                                "Taler-test-header: settled",
    461                                                "order-settled",
    462                                                MHD_HTTP_NO_CONTENT),
    463     TALER_TESTING_cmd_testserver ("launch-http-server-for-webhooks",
    464                                   12345),
    465     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1-idem",
    466                                              cred.cfg,
    467                                              merchant_url,
    468                                              MHD_HTTP_OK,
    469                                              "1",
    470                                              GNUNET_TIME_UNIT_ZERO_TS,
    471                                              GNUNET_TIME_UNIT_FOREVER_TS,
    472                                              true,
    473                                              "EUR:5.0",
    474                                              "x-taler-bank",
    475                                              "",
    476                                              "",
    477                                              "create-proposal-1"),
    478     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1x",
    479                                              cred.cfg,
    480                                              merchant_url,
    481                                              MHD_HTTP_OK,
    482                                              "1x",
    483                                              GNUNET_TIME_UNIT_ZERO_TS,
    484                                              GNUNET_TIME_UNIT_FOREVER_TS,
    485                                              true,
    486                                              "EUR:5.0",
    487                                              "x-taler-bank",
    488                                              "",
    489                                              "",
    490                                              NULL),
    491     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1",
    492                                             merchant_url,
    493                                             MHD_HTTP_OK,
    494                                             "create-proposal-1",
    495                                             NULL),
    496     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1-bad-nonce",
    497                                             merchant_url,
    498                                             MHD_HTTP_CONFLICT,
    499                                             NULL,
    500                                             "1"),
    501     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1x",
    502                                             merchant_url,
    503                                             MHD_HTTP_OK,
    504                                             "create-proposal-1x",
    505                                             NULL),
    506     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1-pre-exists",
    507                                             cred.cfg,
    508                                             merchant_url,
    509                                             MHD_HTTP_CONFLICT,
    510                                             "1",
    511                                             GNUNET_TIME_UNIT_ZERO_TS,
    512                                             GNUNET_TIME_UNIT_FOREVER_TS,
    513                                             "EUR:5.0"),
    514     TALER_TESTING_cmd_poll_orders_conclude ("poll-orders-1-conclude",
    515                                             MHD_HTTP_OK,
    516                                             "poll-orders-1-start"),
    517     TALER_TESTING_cmd_merchant_get_orders ("get-orders-1",
    518                                            merchant_url,
    519                                            MHD_HTTP_OK,
    520                                            "create-proposal-1x",
    521                                            "create-proposal-1",
    522                                            NULL),
    523     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1",
    524                                         merchant_url,
    525                                         "create-proposal-1",
    526                                         false,
    527                                         false,
    528                                         false,
    529                                         MHD_HTTP_PAYMENT_REQUIRED),
    530     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1",
    531                                           merchant_url,
    532                                           "create-proposal-1",
    533                                           TALER_MERCHANT_OSC_CLAIMED,
    534                                           false,
    535                                           MHD_HTTP_OK,
    536                                           NULL),
    537     TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-start-1",
    538                                                merchant_url,
    539                                                "create-proposal-1",
    540                                                POLL_ORDER_TIMEOUT,
    541                                                NULL),
    542     TALER_TESTING_cmd_wallet_poll_order_start2 ("poll-order-wallet-start-1x",
    543                                                 merchant_url,
    544                                                 "create-proposal-1x",
    545                                                 POLL_ORDER_SHORT_TIMEOUT,
    546                                                 NULL, /* no refund */
    547                                                 "session-0"),
    548     TALER_TESTING_cmd_poll_order_start ("poll-order-merchant-1-start",
    549                                         merchant_url,
    550                                         "1",
    551                                         POLL_ORDER_TIMEOUT),
    552     TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
    553                                           merchant_url,
    554                                           MHD_HTTP_OK,
    555                                           "create-proposal-1",
    556                                           "withdraw-coin-1",
    557                                           "EUR:5",
    558                                           "EUR:4.99",
    559                                           "session-0"),
    560     TALER_TESTING_cmd_poll_order_conclude ("poll-order-merchant-1-conclude",
    561                                            MHD_HTTP_OK,
    562                                            "poll-order-merchant-1-start"),
    563     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude",
    564                                                   MHD_HTTP_OK,
    565                                                   NULL,
    566                                                   "poll-order-wallet-start-1"),
    567     /* Check for webhook */
    568     cmd_webhook ("pending-webhooks-pay-w1"),
    569     /* Check webhook did anything: have a command that inspects traits of the testserver
    570        and check if the traits have the right values set! */
    571     TALER_TESTING_cmd_checkserver ("check-http-server-for-webhooks",
    572                                    "launch-http-server-for-webhooks",
    573                                    0),
    574     /* Here we expect to run into a timeout, as we do not pay this one */
    575     TALER_TESTING_cmd_wallet_poll_order_conclude2 ("poll-order-1x-conclude",
    576                                                    MHD_HTTP_PAYMENT_REQUIRED,
    577                                                    NULL,
    578                                                    "poll-order-wallet-start-1x",
    579                                                    "1"),
    580     TALER_TESTING_cmd_merchant_post_orders_paid ("verify-order-1-paid",
    581                                                  merchant_url,
    582                                                  "deposit-simple",
    583                                                  "session-1",
    584                                                  MHD_HTTP_OK),
    585     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1-2",
    586                                         merchant_url,
    587                                         "create-proposal-1",
    588                                         true,
    589                                         false,
    590                                         false,
    591                                         MHD_HTTP_OK),
    592     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1-2a",
    593                                           merchant_url,
    594                                           "create-proposal-1",
    595                                           TALER_MERCHANT_OSC_PAID,
    596                                           false,
    597                                           MHD_HTTP_OK,
    598                                           NULL),
    599     TALER_TESTING_cmd_merchant_get_orders ("get-orders-1-paid",
    600                                            merchant_url,
    601                                            MHD_HTTP_OK,
    602                                            "create-proposal-1x",
    603                                            "create-proposal-1",
    604                                            NULL),
    605     TALER_TESTING_cmd_merchant_pay_order ("replay-simple",
    606                                           merchant_url,
    607                                           MHD_HTTP_OK,
    608                                           "create-proposal-1",
    609                                           "withdraw-coin-1",
    610                                           "EUR:5",
    611                                           "EUR:4.99",
    612                                           "session-0"),
    613     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"),
    614     TALER_TESTING_cmd_sleep (
    615       "Wait for wire transfer deadline",
    616       3),
    617     CMD_EXEC_AGGREGATOR ("run-aggregator"),
    618     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-498c",
    619                                            EXCHANGE_URL,
    620                                            "EUR:4.98",
    621                                            exchange_payto,
    622                                            merchant_payto),
    623     TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1",
    624                                               &cred.ba,
    625                                               merchant_payto,
    626                                               merchant_url,
    627                                               "EUR:4.98",
    628                                               MHD_HTTP_NO_CONTENT,
    629                                               "deposit-simple",
    630                                               NULL),
    631     TALER_TESTING_cmd_depositcheck ("run taler-merchant-depositcheck-1",
    632                                     config_file),
    633     TALER_TESTING_cmd_run_tme ("run taler-merchant-reconciliation-1",
    634                                config_file),
    635     /* Check for settled webhook after reconciliation */
    636     cmd_webhook ("pending-webhooks-settled-w1"),
    637     TALER_TESTING_cmd_checkserver2 ("check-http-server-for-settled-webhook",
    638                                     "launch-http-server-for-webhooks",
    639                                     1,
    640                                     "/",
    641                                     "POST",
    642                                     "settled",
    643                                     "order-settled"),
    644     TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad",
    645                                                merchant_url,
    646                                                merchant_payto,
    647                                                "EUR:4.98",
    648                                                NULL,
    649                                                /*non-routable IP address
    650                                                so we are sure to not get
    651                                                any reply*/
    652                                                "http://192.0.2.1/404/",
    653                                                MHD_HTTP_NO_CONTENT),
    654     TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1",
    655                                               merchant_url,
    656                                               merchant_payto,
    657                                               MHD_HTTP_OK,
    658                                               "post-transfer-1",
    659                                               "post-transfer-bad",
    660                                               NULL),
    661     TALER_TESTING_cmd_merchant_delete_transfer ("delete-transfer-1",
    662                                                 merchant_url,
    663                                                 "post-transfer-bad",
    664                                                 MHD_HTTP_NO_CONTENT),
    665     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2b",
    666                                            merchant_url,
    667                                            "create-proposal-1",
    668                                            TALER_MERCHANT_OSC_PAID,
    669                                            true,
    670                                            order_1_transfers, /* "post-transfer-1" */
    671                                            false,
    672                                            NULL,
    673                                            NULL,
    674                                            MHD_HTTP_OK),
    675     TALER_TESTING_cmd_merchant_forget_order ("forget-1",
    676                                              merchant_url,
    677                                              MHD_HTTP_NO_CONTENT,
    678                                              "create-proposal-1",
    679                                              NULL,
    680                                              "$.dummy_obj",
    681                                              NULL),
    682     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-1",
    683                                            merchant_url,
    684                                            "create-proposal-1",
    685                                            TALER_MERCHANT_OSC_PAID,
    686                                            true,
    687                                            order_1_transfers,
    688                                            false,
    689                                            NULL,
    690                                            order_1_forgets_1,
    691                                            MHD_HTTP_OK),
    692     TALER_TESTING_cmd_merchant_forget_order ("forget-unforgettable",
    693                                              merchant_url,
    694                                              MHD_HTTP_CONFLICT,
    695                                              "create-proposal-1",
    696                                              NULL,
    697                                              "$.amount",
    698                                              NULL),
    699     TALER_TESTING_cmd_merchant_forget_order ("forget-order-nx",
    700                                              merchant_url,
    701                                              MHD_HTTP_NOT_FOUND,
    702                                              NULL,
    703                                              "nx-order",
    704                                              "$.dummy_obj",
    705                                              NULL),
    706     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-elem",
    707                                              merchant_url,
    708                                              MHD_HTTP_NO_CONTENT,
    709                                              "create-proposal-1",
    710                                              NULL,
    711                                              "$.dummy_array[0].item",
    712                                              NULL),
    713     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-2",
    714                                            merchant_url,
    715                                            "create-proposal-1",
    716                                            TALER_MERCHANT_OSC_PAID,
    717                                            true,
    718                                            order_1_transfers,
    719                                            false,
    720                                            NULL,
    721                                            order_1_forgets_2,
    722                                            MHD_HTTP_OK),
    723     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-wc",
    724                                              merchant_url,
    725                                              MHD_HTTP_NO_CONTENT,
    726                                              "create-proposal-1",
    727                                              NULL,
    728                                              "$.dummy_array[*].item",
    729                                              NULL),
    730     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-3",
    731                                            merchant_url,
    732                                            "create-proposal-1",
    733                                            TALER_MERCHANT_OSC_PAID,
    734                                            true,
    735                                            order_1_transfers,
    736                                            false,
    737                                            NULL,
    738                                            order_1_forgets_3,
    739                                            MHD_HTTP_OK),
    740     TALER_TESTING_cmd_merchant_forget_order ("forget-order-malformed",
    741                                              merchant_url,
    742                                              MHD_HTTP_BAD_REQUEST,
    743                                              "create-proposal-1",
    744                                              NULL,
    745                                              "$.dummy_array[abc].item",
    746                                              NULL),
    747     TALER_TESTING_cmd_merchant_post_products ("post-products-p3",
    748                                               merchant_url,
    749                                               "product-3",
    750                                               "a product",
    751                                               "EUR:1",
    752                                               MHD_HTTP_NO_CONTENT),
    753     TALER_TESTING_cmd_merchant_post_products_with_unit_prices (
    754       "post-products-dup-currency",
    755       merchant_url,
    756       "product-dup-currency",
    757       "duplicate currency product",
    758       "test-unit",
    759       (const char *[]) { "EUR:1", "EUR:2" },
    760       2,
    761       MHD_HTTP_BAD_REQUEST),
    762     TALER_TESTING_cmd_merchant_post_products2 ("post-products-p4",
    763                                                merchant_url,
    764                                                "product-4age",
    765                                                "an age-restricted product",
    766                                                NULL,
    767                                                "unit",
    768                                                "EUR:1",
    769                                                "", /* image */
    770                                                NULL,
    771                                                4,
    772                                                16 /* minimum age */,
    773                                                NULL,
    774                                                GNUNET_TIME_UNIT_FOREVER_TS,
    775                                                MHD_HTTP_NO_CONTENT),
    776     TALER_TESTING_cmd_merchant_post_products3 ("post-products-frac",
    777                                                merchant_url,
    778                                                "product-frac",
    779                                                "fractional product",
    780                                                json_pack ("{s:s}",
    781                                                           "en",
    782                                                           "fractional product"),
    783                                                "kg",
    784                                                "EUR:1.5",
    785                                                "",
    786                                                json_array (),
    787                                                1,
    788                                                (TALER_MERCHANT_UNIT_FRAC_BASE
    789                                                 * 3)
    790                                                / 4,
    791                                                true,
    792                                                0,
    793                                                NULL,
    794                                                GNUNET_TIME_UNIT_ZERO_TS,
    795                                                MHD_HTTP_NO_CONTENT),
    796     TALER_TESTING_cmd_merchant_get_product ("get-product-frac-post",
    797                                             merchant_url,
    798                                             "product-frac",
    799                                             MHD_HTTP_OK,
    800                                             "post-products-frac"),
    801     TALER_TESTING_cmd_merchant_patch_product_with_unit_prices (
    802       "patch-products-dup-currency",
    803       merchant_url,
    804       "product-3",
    805       "a product",
    806       "can",
    807       (const char *[]) { "EUR:1", "EUR:2" },
    808       2,
    809       MHD_HTTP_BAD_REQUEST),
    810     TALER_TESTING_cmd_merchant_patch_product ("patch-products-p3",
    811                                               merchant_url,
    812                                               "product-3",
    813                                               "a product",
    814                                               json_object (),
    815                                               "can",
    816                                               "EUR:1",
    817                                               "data:image/jpeg;base64,RAWDATA",
    818                                               json_array (),
    819                                               5,
    820                                               0,
    821                                               json_object (),
    822                                               GNUNET_TIME_relative_to_timestamp
    823                                               (
    824                                                 GNUNET_TIME_UNIT_MINUTES),
    825                                               MHD_HTTP_NO_CONTENT),
    826     TALER_TESTING_cmd_merchant_patch_product2 ("patch-product-frac",
    827                                                merchant_url,
    828                                                "product-frac",
    829                                                "fractional product patched",
    830                                                json_pack ("{s:s}",
    831                                                           "en",
    832                                                           "fractional product patched"),
    833                                                "kg",
    834                                                "EUR:1.6",
    835                                                "",
    836                                                json_array (),
    837                                                2,
    838                                                TALER_MERCHANT_UNIT_FRAC_BASE / 4
    839                                                ,
    840                                                true,
    841                                                0,
    842                                                json_object (),
    843                                                GNUNET_TIME_relative_to_timestamp
    844                                                (
    845                                                  GNUNET_TIME_UNIT_MINUTES),
    846                                                MHD_HTTP_NO_CONTENT),
    847     TALER_TESTING_cmd_merchant_get_product ("get-product-frac-patched",
    848                                             merchant_url,
    849                                             "product-frac",
    850                                             MHD_HTTP_OK,
    851                                             "patch-product-frac"),
    852     TALER_TESTING_cmd_merchant_delete_unit ("delete-unit-piece-denied",
    853                                             merchant_url,
    854                                             "Piece",
    855                                             MHD_HTTP_CONFLICT),
    856     TALER_TESTING_cmd_merchant_post_units ("post-unit-piece-conflict",
    857                                            merchant_url,
    858                                            "Piece",
    859                                            "piece",
    860                                            "pc",
    861                                            false,
    862                                            0,
    863                                            true,
    864                                            NULL,
    865                                            NULL,
    866                                            MHD_HTTP_CONFLICT),
    867     TALER_TESTING_cmd_merchant_post_units ("post-unit-bucket",
    868                                            merchant_url,
    869                                            "BucketCustomUnit",
    870                                            "bucket",
    871                                            "bkt",
    872                                            false,
    873                                            0,
    874                                            true,
    875                                            json_pack ("{s:s}", "en", "bucket"),
    876                                            json_pack ("{s:s}", "en", "bkt"),
    877                                            MHD_HTTP_NO_CONTENT),
    878     TALER_TESTING_cmd_merchant_get_unit ("get-unit-bucket",
    879                                          merchant_url,
    880                                          "BucketCustomUnit",
    881                                          MHD_HTTP_OK,
    882                                          "post-unit-bucket"),
    883     TALER_TESTING_cmd_merchant_get_units ("get-units-bucket-list",
    884                                           merchant_url,
    885                                           MHD_HTTP_OK,
    886                                           "post-unit-bucket",
    887                                           NULL),
    888     TALER_TESTING_cmd_merchant_patch_unit ("patch-unit-bucket",
    889                                            merchant_url,
    890                                            "BucketCustomUnit",
    891                                            "bucket-updated",
    892                                            "bkt-upd",
    893                                            json_pack ("{s:s}", "en",
    894                                                       "bucket-updated"),
    895                                            json_pack ("{s:s}", "en", "bkt-upd"),
    896                                            true,
    897                                            0,
    898                                            false,
    899                                            MHD_HTTP_NO_CONTENT),
    900     TALER_TESTING_cmd_merchant_get_unit ("get-unit-bucket-patched",
    901                                          merchant_url,
    902                                          "BucketCustomUnit",
    903                                          MHD_HTTP_OK,
    904                                          "patch-unit-bucket"),
    905     TALER_TESTING_cmd_merchant_get_units ("get-units-bucket-updated",
    906                                           merchant_url,
    907                                           MHD_HTTP_OK,
    908                                           "patch-unit-bucket",
    909                                           NULL),
    910     TALER_TESTING_cmd_merchant_delete_unit ("delete-unit-bucket",
    911                                             merchant_url,
    912                                             "BucketCustomUnit",
    913                                             MHD_HTTP_NO_CONTENT),
    914     TALER_TESTING_cmd_merchant_get_unit ("get-unit-bucket-deleted",
    915                                          merchant_url,
    916                                          "BucketCustomUnit",
    917                                          MHD_HTTP_NOT_FOUND,
    918                                          NULL),
    919     TALER_TESTING_cmd_merchant_post_units ("post-unit-unicorn",
    920                                            merchant_url,
    921                                            "UnitUnicorn",
    922                                            "unicorn",
    923                                            "uni",
    924                                            true,
    925                                            1,
    926                                            true,
    927                                            json_pack ("{s:s}", "en", "unicorn"),
    928                                            json_pack ("{s:s}", "en", "uni"),
    929                                            MHD_HTTP_NO_CONTENT),
    930     TALER_TESTING_cmd_merchant_post_products2 ("post-product-unicorn",
    931                                                merchant_url,
    932                                                "product-unicorn",
    933                                                "a unicorn snack",
    934                                                json_pack ("{s:s}",
    935                                                           "en",
    936                                                           "a unicorn snack"),
    937                                                "UnitUnicorn",
    938                                                "EUR:3.5",
    939                                                "",
    940                                                json_array (),
    941                                                7,
    942                                                0,
    943                                                json_object (),
    944                                                GNUNET_TIME_UNIT_ZERO_TS,
    945                                                MHD_HTTP_NO_CONTENT),
    946     TALER_TESTING_cmd_merchant_get_product2 ("get-product-unicorn-default",
    947                                              merchant_url,
    948                                              "product-unicorn",
    949                                              MHD_HTTP_OK,
    950                                              "post-product-unicorn",
    951                                              &expect_unicorn_defaults),
    952     TALER_TESTING_cmd_merchant_patch_unit ("patch-unit-unicorn",
    953                                            merchant_url,
    954                                            "UnitUnicorn",
    955                                            NULL,
    956                                            NULL,
    957                                            NULL,
    958                                            NULL,
    959                                            false,
    960                                            0,
    961                                            true,
    962                                            MHD_HTTP_NO_CONTENT),
    963     TALER_TESTING_cmd_merchant_get_product2 ("get-product-unicorn-patched",
    964                                              merchant_url,
    965                                              "product-unicorn",
    966                                              MHD_HTTP_OK,
    967                                              "post-product-unicorn",
    968                                              &expect_unicorn_patched),
    969     TALER_TESTING_cmd_merchant_delete_product ("delete-product-unicorn",
    970                                                merchant_url,
    971                                                "product-unicorn",
    972                                                MHD_HTTP_NO_CONTENT),
    973     TALER_TESTING_cmd_merchant_delete_unit ("delete-unit-unicorn",
    974                                             merchant_url,
    975                                             "UnitUnicorn",
    976                                             MHD_HTTP_NO_CONTENT),
    977     TALER_TESTING_cmd_merchant_lock_product ("lock-product-p3",
    978                                              merchant_url,
    979                                              "product-3",
    980                                              GNUNET_TIME_UNIT_MINUTES,
    981                                              2,
    982                                              MHD_HTTP_NO_CONTENT),
    983     TALER_TESTING_cmd_merchant_lock_product2 (
    984       "lock-product-p3-float-denied",
    985       merchant_url,
    986       "product-3",
    987       GNUNET_TIME_UNIT_MINUTES,
    988       1,
    989       TALER_MERCHANT_UNIT_FRAC_BASE / 2,
    990       true,
    991       MHD_HTTP_BAD_REQUEST),
    992     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-float-denied",
    993                                              cred.cfg,
    994                                              merchant_url,
    995                                              MHD_HTTP_BAD_REQUEST,
    996                                              "order-p3-float-denied",
    997                                              GNUNET_TIME_UNIT_ZERO_TS,
    998                                              GNUNET_TIME_UNIT_FOREVER_TS,
    999                                              true,
   1000                                              "EUR:5.0",
   1001                                              "x-taler-bank",
   1002                                              "product-3/1.5",
   1003                                              "",
   1004                                              NULL),
   1005     TALER_TESTING_cmd_merchant_patch_product2 (
   1006       "patch-product-3-allow-float",
   1007       merchant_url,
   1008       "product-3",
   1009       "a product allow fractional",
   1010       json_pack ("{s:s}",
   1011                  "en",
   1012                  "a product allow fractional"),
   1013       "can",
   1014       "EUR:1",
   1015       "data:image/jpeg;base64,RAWDATA",
   1016       json_array (),
   1017       5,
   1018       0,
   1019       true,
   1020       0,
   1021       json_object (),
   1022       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
   1023       MHD_HTTP_NO_CONTENT),
   1024     cmd_transfer_to_exchange ("create-reserve-p3-float",
   1025                               "EUR:5.01"),
   1026     cmd_exec_wirewatch ("wirewatch-p3-float"),
   1027     TALER_TESTING_cmd_check_bank_admin_transfer (
   1028       "check_bank_transfer-p3-float",
   1029       "EUR:5.01",
   1030       payer_payto,
   1031       exchange_payto,
   1032       "create-reserve-p3-float"),
   1033     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-p3-float",
   1034                                        "create-reserve-p3-float",
   1035                                        "EUR:5",
   1036                                        0,
   1037                                        MHD_HTTP_OK),
   1038     TALER_TESTING_cmd_merchant_lock_product2 (
   1039       "lock-product-p3-float",
   1040       merchant_url,
   1041       "product-3",
   1042       GNUNET_TIME_UNIT_MINUTES,
   1043       1,
   1044       TALER_MERCHANT_UNIT_FRAC_BASE / 2,
   1045       true,
   1046       MHD_HTTP_NO_CONTENT),
   1047     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-float",
   1048                                              cred.cfg,
   1049                                              merchant_url,
   1050                                              MHD_HTTP_OK,
   1051                                              "order-p3-float",
   1052                                              GNUNET_TIME_UNIT_ZERO_TS,
   1053                                              GNUNET_TIME_UNIT_FOREVER_TS,
   1054                                              true,
   1055                                              "EUR:5.0",
   1056                                              "x-taler-bank",
   1057                                              "product-3/1.5",
   1058                                              "",
   1059                                              NULL),
   1060     TALER_TESTING_cmd_merchant_claim_order ("claim-order-p3-float",
   1061                                             merchant_url,
   1062                                             MHD_HTTP_OK,
   1063                                             "create-proposal-p3-float",
   1064                                             NULL),
   1065     TALER_TESTING_cmd_merchant_pay_order ("pay-order-p3-float",
   1066                                           merchant_url,
   1067                                           MHD_HTTP_OK,
   1068                                           "create-proposal-p3-float",
   1069                                           "withdraw-coin-p3-float",
   1070                                           "EUR:5",
   1071                                           "EUR:4.99",
   1072                                           "session-p3-float"),
   1073     TALER_TESTING_cmd_sleep (
   1074       "Wait for wire transfer deadline-p3-float",
   1075       3),
   1076     CMD_EXEC_AGGREGATOR ("run-aggregator-p3-float"),
   1077     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-p3-float",
   1078                                            EXCHANGE_URL,
   1079                                            "EUR:4.98",
   1080                                            exchange_payto,
   1081                                            merchant_payto),
   1082     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-p3-float-paid",
   1083                                           merchant_url,
   1084                                           "create-proposal-p3-float",
   1085                                           TALER_MERCHANT_OSC_PAID,
   1086                                           false,
   1087                                           MHD_HTTP_OK,
   1088                                           NULL),
   1089     TALER_TESTING_cmd_merchant_patch_product2 (
   1090       "patch-product-3-restore",
   1091       merchant_url,
   1092       "product-3",
   1093       "a product",
   1094       json_pack ("{s:s}",
   1095                  "en",
   1096                  "a product"),
   1097       "can",
   1098       "EUR:1",
   1099       "data:image/jpeg;base64,RAWDATA",
   1100       json_array (),
   1101       5,
   1102       0,
   1103       false,
   1104       0,
   1105       json_object (),
   1106       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
   1107       MHD_HTTP_NO_CONTENT),
   1108     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-wm-nx",
   1109                                              cred.cfg,
   1110                                              merchant_url,
   1111                                              MHD_HTTP_NOT_FOUND,
   1112                                              "order-p3",
   1113                                              GNUNET_TIME_UNIT_ZERO_TS,
   1114                                              GNUNET_TIME_UNIT_FOREVER_TS,
   1115                                              true,
   1116                                              "EUR:5.0",
   1117                                              "unsupported-wire-method",
   1118                                              "product-3/2",
   1119                                              "", /* locks */
   1120                                              NULL),
   1121     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx",
   1122                                              cred.cfg,
   1123                                              merchant_url,
   1124                                              MHD_HTTP_NOT_FOUND,
   1125                                              "order-p3",
   1126                                              GNUNET_TIME_UNIT_ZERO_TS,
   1127                                              GNUNET_TIME_UNIT_FOREVER_TS,
   1128                                              true,
   1129                                              "EUR:5.0",
   1130                                              "x-taler-bank",
   1131                                              "unknown-product/2",
   1132                                              "",
   1133                                              NULL),
   1134     TALER_TESTING_cmd_merchant_post_orders2 (
   1135       "create-proposal-p3-not-enough-stock",
   1136       cred.cfg,
   1137       merchant_url,
   1138       MHD_HTTP_GONE,
   1139       "order-p3",
   1140       GNUNET_TIME_UNIT_ZERO_TS,
   1141       GNUNET_TIME_UNIT_FOREVER_TS,
   1142       true,
   1143       "EUR:5.0",
   1144       "x-taler-bank",
   1145       "product-3/24",
   1146       "",
   1147       NULL),
   1148     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3",
   1149                                              cred.cfg,
   1150                                              merchant_url,
   1151                                              MHD_HTTP_OK,
   1152                                              "order-p3",
   1153                                              GNUNET_TIME_UNIT_ZERO_TS,
   1154                                              GNUNET_TIME_UNIT_FOREVER_TS,
   1155                                              false,
   1156                                              "EUR:5.0",
   1157                                              "x-taler-bank",
   1158                                              "product-3/3",
   1159                                              "lock-product-p3",
   1160                                              NULL),
   1161     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p4-age",
   1162                                              cred.cfg,
   1163                                              merchant_url,
   1164                                              MHD_HTTP_OK,
   1165                                              "order-p4-age",
   1166                                              GNUNET_TIME_UNIT_ZERO_TS,
   1167                                              GNUNET_TIME_UNIT_FOREVER_TS,
   1168                                              false,
   1169                                              "EUR:5.0",
   1170                                              "x-taler-bank",
   1171                                              "product-4age",
   1172                                              "", /* locks */
   1173                                              NULL),
   1174     TALER_TESTING_cmd_merchant_get_order4 ("get-order-merchant-p4-age",
   1175                                            merchant_url,
   1176                                            "create-proposal-p4-age",
   1177                                            TALER_MERCHANT_OSC_CLAIMED,
   1178                                            16,
   1179                                            MHD_HTTP_OK),
   1180     TALER_TESTING_cmd_merchant_delete_order ("delete-order-paid",
   1181                                              merchant_url,
   1182                                              "1",
   1183                                              MHD_HTTP_CONFLICT),
   1184     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-no-id",
   1185                                             cred.cfg,
   1186                                             merchant_url,
   1187                                             MHD_HTTP_OK,
   1188                                             NULL,
   1189                                             GNUNET_TIME_UNIT_ZERO_TS,
   1190                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1191                                             "EUR:5.0"),
   1192     TALER_TESTING_cmd_merchant_delete_webhook ("post-webhooks-pay-w1",
   1193                                                merchant_url,
   1194                                                "webhook-pay-1",
   1195                                                MHD_HTTP_NO_CONTENT),
   1196     TALER_TESTING_cmd_merchant_delete_webhook ("post-webhooks-settled-w1",
   1197                                                merchant_url,
   1198                                                "webhook-settled-1",
   1199                                                MHD_HTTP_NO_CONTENT),
   1200     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
   1201     TALER_TESTING_cmd_end ()
   1202   };
   1203   struct TALER_TESTING_Command double_spending[] = {
   1204     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
   1205                                             cred.cfg,
   1206                                             merchant_url,
   1207                                             MHD_HTTP_OK,
   1208                                             "2",
   1209                                             GNUNET_TIME_UNIT_ZERO_TS,
   1210                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1211                                             "EUR:5.0"),
   1212     TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
   1213                                             merchant_url,
   1214                                             MHD_HTTP_OK,
   1215                                             "create-proposal-2",
   1216                                             NULL),
   1217     TALER_TESTING_cmd_merchant_pay_order ("deposit-double-2",
   1218                                           merchant_url,
   1219                                           MHD_HTTP_CONFLICT,
   1220                                           "create-proposal-2",
   1221                                           "withdraw-coin-1",
   1222                                           "EUR:5",
   1223                                           "EUR:4.99",
   1224                                           NULL),
   1225     TALER_TESTING_cmd_end ()
   1226   };
   1227 
   1228   const char *order_1r_refunds[] = {
   1229     "refund-increase-1r",
   1230     "refund-increase-1r-2",
   1231     NULL
   1232   };
   1233   struct TALER_TESTING_Command refund[] = {
   1234     cmd_transfer_to_exchange ("create-reserve-1r",
   1235                               "EUR:10.02"),
   1236     /**
   1237      * Make a reserve exist, according to the previous transfer.
   1238      */
   1239     cmd_exec_wirewatch ("wirewatch-1r"),
   1240     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2r",
   1241                                                  "EUR:10.02",
   1242                                                  payer_payto,
   1243                                                  exchange_payto,
   1244                                                  "create-reserve-1r"),
   1245     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1r",
   1246                                        "create-reserve-1r",
   1247                                        "EUR:5",
   1248                                        0,
   1249                                        MHD_HTTP_OK),
   1250     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2r",
   1251                                        "create-reserve-1r",
   1252                                        "EUR:5",
   1253                                        0,
   1254                                        MHD_HTTP_OK),
   1255     /**
   1256      * Check the reserve is depleted.
   1257      */
   1258     TALER_TESTING_cmd_status ("withdraw-status-1r",
   1259                               "create-reserve-1r",
   1260                               "EUR:0",
   1261                               MHD_HTTP_OK),
   1262     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1r",
   1263                                             cred.cfg,
   1264                                             merchant_url,
   1265                                             MHD_HTTP_OK,
   1266                                             "1r",
   1267                                             GNUNET_TIME_UNIT_ZERO_TS,
   1268                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1269                                             "EUR:5.0"),
   1270     TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-refund-1-low",
   1271                                                merchant_url,
   1272                                                "create-proposal-1r",
   1273                                                POLL_ORDER_TIMEOUT,
   1274                                                "EUR:0.01"),
   1275     TALER_TESTING_cmd_wallet_poll_order_start (
   1276       "poll-order-wallet-refund-1-high",
   1277       merchant_url,
   1278       "create-proposal-1r",
   1279       POLL_ORDER_TIMEOUT,
   1280       "EUR:0.2"),
   1281     TALER_TESTING_cmd_merchant_pay_order ("pay-for-refund-1r",
   1282                                           merchant_url,
   1283                                           MHD_HTTP_OK,
   1284                                           "create-proposal-1r",
   1285                                           "withdraw-coin-1r",
   1286                                           "EUR:5",
   1287                                           "EUR:4.99",
   1288                                           NULL),
   1289     TALER_TESTING_cmd_poll_order_start ("poll-payment-refund-1",
   1290                                         merchant_url,
   1291                                         "1r", /* proposal name, not cmd ref! */
   1292                                         POLL_ORDER_TIMEOUT),
   1293     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r",
   1294                                              merchant_url,
   1295                                              "refund test",
   1296                                              "1r", /* order ID */
   1297                                              "EUR:0.1",
   1298                                              MHD_HTTP_OK),
   1299     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-low",
   1300                                                   MHD_HTTP_OK,
   1301                                                   "EUR:0.1",
   1302                                                   "poll-order-wallet-refund-1-low"),
   1303     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r",
   1304                                         merchant_url,
   1305                                         "create-proposal-1r",
   1306                                         true,
   1307                                         true,
   1308                                         true,
   1309                                         MHD_HTTP_OK),
   1310     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r-2",
   1311                                              merchant_url,
   1312                                              "refund test 2",
   1313                                              "1r", /* order ID */
   1314                                              "EUR:1.0",
   1315                                              MHD_HTTP_OK),
   1316     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-high",
   1317                                                   MHD_HTTP_OK,
   1318                                                   "EUR:1.0",
   1319                                                   "poll-order-wallet-refund-1-high"),
   1320     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-2",
   1321                                         merchant_url,
   1322                                         "create-proposal-1r",
   1323                                         true,
   1324                                         true,
   1325                                         true,
   1326                                         MHD_HTTP_OK),
   1327     TALER_TESTING_cmd_wallet_order_refund ("obtain-refund-1r",
   1328                                            merchant_url,
   1329                                            "create-proposal-1r",
   1330                                            MHD_HTTP_OK,
   1331                                            "refund-increase-1r",
   1332                                            "refund-increase-1r-2",
   1333                                            NULL),
   1334     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-3",
   1335                                         merchant_url,
   1336                                         "create-proposal-1r",
   1337                                         true,
   1338                                         true,
   1339                                         false,
   1340                                         MHD_HTTP_OK),
   1341     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1r",
   1342                                           merchant_url,
   1343                                           "create-proposal-1r",
   1344                                           TALER_MERCHANT_OSC_PAID,
   1345                                           true,
   1346                                           MHD_HTTP_OK,
   1347                                           "refund-increase-1r",
   1348                                           "refund-increase-1r-2",
   1349                                           NULL),
   1350     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1r-2",
   1351                                            merchant_url,
   1352                                            "create-proposal-1r",
   1353                                            TALER_MERCHANT_OSC_PAID,
   1354                                            false,
   1355                                            NULL,
   1356                                            true,
   1357                                            order_1r_refunds,
   1358                                            NULL,
   1359                                            MHD_HTTP_OK),
   1360     TALER_TESTING_cmd_poll_order_conclude ("poll-payment-refund-conclude-1",
   1361                                            MHD_HTTP_OK,
   1362                                            "poll-payment-refund-1"),
   1363 
   1364     /* Test /refund on a contract that was never paid.  */
   1365     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-not-to-be-paid",
   1366                                             cred.cfg,
   1367                                             merchant_url,
   1368                                             MHD_HTTP_OK,
   1369                                             "1-unpaid",
   1370                                             GNUNET_TIME_UNIT_ZERO_TS,
   1371                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1372                                             "EUR:5.0"),
   1373     /* Try to increase an unpaid proposal.  */
   1374     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-unpaid-proposal",
   1375                                              merchant_url,
   1376                                              "refund test",
   1377                                              "1-unpaid",
   1378                                              "EUR:0.1",
   1379                                              MHD_HTTP_CONFLICT),
   1380     /* Try to increase a non existent proposal.  */
   1381     TALER_TESTING_cmd_merchant_order_refund (
   1382       "refund-increase-nonexistent-proposal",
   1383       merchant_url,
   1384       "refund test",
   1385       "non-existent-id",
   1386       "EUR:0.1",
   1387       MHD_HTTP_NOT_FOUND),
   1388     /*
   1389        The following block will (1) create a new
   1390        reserve, then (2) a proposal, then (3) pay for
   1391        it, and finally (4) attempt to pick up a refund
   1392        from it without any increasing taking place
   1393        in the first place.
   1394     */
   1395     cmd_transfer_to_exchange ("create-reserve-unincreased-refund",
   1396                               "EUR:5.01"),
   1397     cmd_exec_wirewatch ("wirewatch-unincreased-refund"),
   1398     TALER_TESTING_cmd_check_bank_admin_transfer (
   1399       "check_bank_transfer-unincreased-refund",
   1400       "EUR:5.01",
   1401       payer_payto,
   1402       exchange_payto,
   1403       "create-reserve-unincreased-refund"),
   1404     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unincreased-refund",
   1405                                        "create-reserve-unincreased-refund",
   1406                                        "EUR:5",
   1407                                        0,
   1408                                        MHD_HTTP_OK),
   1409     TALER_TESTING_cmd_merchant_post_orders (
   1410       "create-proposal-unincreased-refund",
   1411       cred.cfg,
   1412       merchant_url,
   1413       MHD_HTTP_OK,
   1414       "unincreased-proposal",
   1415       GNUNET_TIME_UNIT_ZERO_TS,
   1416       GNUNET_TIME_UNIT_FOREVER_TS,
   1417       "EUR:5.0"),
   1418     TALER_TESTING_cmd_merchant_pay_order ("pay-unincreased-proposal",
   1419                                           merchant_url,
   1420                                           MHD_HTTP_OK,
   1421                                           "create-proposal-unincreased-refund",
   1422                                           "withdraw-coin-unincreased-refund",
   1423                                           "EUR:5",
   1424                                           "EUR:4.99",
   1425                                           NULL),
   1426     TALER_TESTING_cmd_sleep (
   1427       "Wait for wire transfer deadline",
   1428       3),
   1429     CMD_EXEC_AGGREGATOR ("run-aggregator-unincreased-refund"),
   1430     TALER_TESTING_cmd_check_bank_transfer (
   1431       "check_bank_transfer-paid-unincreased-refund",
   1432       EXCHANGE_URL,
   1433       "EUR:8.97", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r'
   1434                      and MINUS 0.1 MINUS 0.9 from
   1435                      'refund-increase-1r' and 'refund-increase-1r-2' */
   1436       exchange_payto,
   1437       merchant_payto),
   1438     TALER_TESTING_cmd_end ()
   1439   };
   1440 
   1441   struct TALER_TESTING_Command auth[] = {
   1442     TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1a",
   1443                                                merchant_url,
   1444                                                "i1a",
   1445                                                MHD_HTTP_NO_CONTENT),
   1446     TALER_TESTING_cmd_merchant_post_account (
   1447       "instance-create-i1a-account",
   1448       merchant_url_i1a,
   1449       merchant_payto,
   1450       NULL, NULL,
   1451       MHD_HTTP_OK),
   1452     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1",
   1453                                             merchant_url_i1a,
   1454                                             "nx-product",
   1455                                             MHD_HTTP_NOT_FOUND,
   1456                                             NULL),
   1457     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-1",
   1458                                              merchant_url_i1a,
   1459                                              MHD_HTTP_OK,
   1460                                              NULL),
   1461     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-2",
   1462                                             merchant_url_i1a,
   1463                                             "nx-product",
   1464                                             MHD_HTTP_NOT_FOUND,
   1465                                             NULL),
   1466     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-2",
   1467                                              merchant_url_i1a,
   1468                                              MHD_HTTP_OK,
   1469                                              NULL),
   1470     TALER_TESTING_cmd_merchant_post_instance_auth (
   1471       "instance-create-i1a-auth-ok",
   1472       merchant_url,
   1473       "i1a",
   1474       "my-secret",
   1475       MHD_HTTP_NO_CONTENT),
   1476     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-3",
   1477                                             merchant_url_i1a,
   1478                                             "nx-product",
   1479                                             MHD_HTTP_UNAUTHORIZED,
   1480                                             NULL),
   1481     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-3",
   1482                                              merchant_url_i1a,
   1483                                              MHD_HTTP_UNAUTHORIZED,
   1484                                              NULL),
   1485     TALER_TESTING_cmd_set_authorization ("set-auth-valid",
   1486                                          "Basic aTFhOm15LXNlY3JldA=="),
   1487     TALER_TESTING_cmd_merchant_post_instance_token (
   1488       "instance-create-i1a-token-ok",
   1489       merchant_url,
   1490       "i1a",
   1491       "write", /* scope */
   1492       GNUNET_TIME_UNIT_DAYS, /* duration */
   1493       GNUNET_YES, /* refreshable */
   1494       MHD_HTTP_OK),
   1495     TALER_TESTING_cmd_set_authorization ("unset-auth-valid",
   1496                                          NULL), // Unset header
   1497     TALER_TESTING_cmd_merchant_set_instance_token (
   1498       "instance-create-i1a-token-set",
   1499       "instance-create-i1a-token-ok"),
   1500     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-4",
   1501                                             merchant_url_i1a,
   1502                                             "nx-product",
   1503                                             MHD_HTTP_NOT_FOUND,
   1504                                             NULL),
   1505     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-4",
   1506                                              merchant_url_i1a,
   1507                                              MHD_HTTP_OK,
   1508                                              NULL),
   1509     TALER_TESTING_cmd_merchant_delete_instance_token (
   1510       "instance-create-i1a-token-delete",
   1511       merchant_url,
   1512       "i1a",
   1513       MHD_HTTP_NO_CONTENT),
   1514     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-5",
   1515                                             merchant_url_i1a,
   1516                                             "nx-product",
   1517                                             MHD_HTTP_UNAUTHORIZED,
   1518                                             NULL),
   1519     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-5",
   1520                                              merchant_url_i1a,
   1521                                              MHD_HTTP_UNAUTHORIZED,
   1522                                              NULL),
   1523     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a-fail",
   1524                                                merchant_url_i1a,
   1525                                                NULL,
   1526                                                MHD_HTTP_UNAUTHORIZED),
   1527     TALER_TESTING_cmd_set_authorization ("set-token-auth-valid-again",
   1528                                          "Basic aTFhOm15LXNlY3JldA=="),
   1529     TALER_TESTING_cmd_merchant_post_instance_token (
   1530       "set-auth-valid-again",
   1531       merchant_url,
   1532       "i1a",
   1533       "write", /* scope */
   1534       GNUNET_TIME_UNIT_DAYS, /* duration */
   1535       GNUNET_YES, /* refreshable */
   1536       MHD_HTTP_OK),
   1537     TALER_TESTING_cmd_set_authorization ("unset-auth-valid2",
   1538                                          NULL), // Unset header
   1539     TALER_TESTING_cmd_merchant_set_instance_token (
   1540       "instance-create-i1a-token-set-again",
   1541       "set-auth-valid-again"),
   1542     TALER_TESTING_cmd_merchant_post_instance_auth (
   1543       "instance-create-i1a-auth-ok-idempotent",
   1544       merchant_url_i1a,
   1545       NULL,
   1546       RFC_8959_PREFIX "my-other-secret",
   1547       MHD_HTTP_NO_CONTENT),
   1548     TALER_TESTING_cmd_merchant_post_instance_auth (
   1549       "instance-create-i1a-clear-auth",
   1550       merchant_url_i1a,
   1551       NULL,
   1552       NULL,
   1553       MHD_HTTP_NO_CONTENT),
   1554     TALER_TESTING_cmd_set_authorization ("set-auth-none",
   1555                                          NULL),
   1556     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a",
   1557                                                merchant_url_i1a,
   1558                                                NULL,
   1559                                                MHD_HTTP_NO_CONTENT),
   1560     TALER_TESTING_cmd_end ()
   1561   };
   1562 
   1563   struct TALER_TESTING_Command pay_again[] = {
   1564     cmd_transfer_to_exchange ("create-reserve-20",
   1565                               "EUR:20.04"),
   1566     cmd_exec_wirewatch ("wirewatch-20"),
   1567     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-10",
   1568                                                  "EUR:20.04",
   1569                                                  payer_payto,
   1570                                                  exchange_payto,
   1571                                                  "create-reserve-20"),
   1572     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10a",
   1573                                        "create-reserve-20",
   1574                                        "EUR:5",
   1575                                        0,
   1576                                        MHD_HTTP_OK),
   1577     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10b",
   1578                                        "create-reserve-20",
   1579                                        "EUR:5",
   1580                                        0,
   1581                                        MHD_HTTP_OK),
   1582     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10c",
   1583                                        "create-reserve-20",
   1584                                        "EUR:5",
   1585                                        0,
   1586                                        MHD_HTTP_OK),
   1587     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10d",
   1588                                        "create-reserve-20",
   1589                                        "EUR:5",
   1590                                        0,
   1591                                        MHD_HTTP_OK),
   1592     TALER_TESTING_cmd_status ("withdraw-status-20",
   1593                               "create-reserve-20",
   1594                               "EUR:0",
   1595                               MHD_HTTP_OK),
   1596     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10",
   1597                                             cred.cfg,
   1598                                             merchant_url,
   1599                                             MHD_HTTP_OK,
   1600                                             "10",
   1601                                             GNUNET_TIME_UNIT_ZERO_TS,
   1602                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1603                                             "EUR:10.0"),
   1604     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-10",
   1605                                           merchant_url,
   1606                                           MHD_HTTP_CONFLICT,
   1607                                           "create-proposal-10",
   1608                                           "withdraw-coin-10a;withdraw-coin-1",
   1609                                           "EUR:5",
   1610                                           "EUR:4.99",
   1611                                           NULL),
   1612     TALER_TESTING_cmd_merchant_pay_order ("pay-again-10",
   1613                                           merchant_url,
   1614                                           MHD_HTTP_OK,
   1615                                           "create-proposal-10",
   1616                                           "withdraw-coin-10a;withdraw-coin-10b",
   1617                                           "EUR:5",
   1618                                           "EUR:4.99",
   1619                                           NULL),
   1620     TALER_TESTING_cmd_merchant_pay_order ("pay-too-much-10",
   1621                                           merchant_url,
   1622                                           MHD_HTTP_CONFLICT,
   1623                                           "create-proposal-10",
   1624                                           "withdraw-coin-10c;withdraw-coin-10d",
   1625                                           "EUR:5",
   1626                                           "EUR:4.99",
   1627                                           NULL),
   1628     TALER_TESTING_cmd_sleep (
   1629       "Wait for wire transfer deadline",
   1630       3),
   1631     CMD_EXEC_AGGREGATOR ("run-aggregator-10"),
   1632     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-9.97-10",
   1633                                            EXCHANGE_URL,
   1634                                            "EUR:9.97",
   1635                                            exchange_payto,
   1636                                            merchant_payto),
   1637     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"),
   1638     TALER_TESTING_cmd_end ()
   1639   };
   1640 
   1641   struct TALER_TESTING_Command pay_abort[] = {
   1642     cmd_transfer_to_exchange ("create-reserve-11",
   1643                               "EUR:10.02"),
   1644     cmd_exec_wirewatch ("wirewatch-11"),
   1645     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-11",
   1646                                                  "EUR:10.02",
   1647                                                  payer_payto,
   1648                                                  exchange_payto,
   1649                                                  "create-reserve-11"),
   1650     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11a",
   1651                                        "create-reserve-11",
   1652                                        "EUR:5",
   1653                                        0,
   1654                                        MHD_HTTP_OK),
   1655     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11b",
   1656                                        "create-reserve-11",
   1657                                        "EUR:5",
   1658                                        0,
   1659                                        MHD_HTTP_OK),
   1660     TALER_TESTING_cmd_status ("withdraw-status-11",
   1661                               "create-reserve-11",
   1662                               "EUR:0",
   1663                               MHD_HTTP_OK),
   1664     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-11",
   1665                                             cred.cfg,
   1666                                             merchant_url,
   1667                                             MHD_HTTP_OK,
   1668                                             "11",
   1669                                             GNUNET_TIME_UNIT_ZERO_TS,
   1670                                             GNUNET_TIME_UNIT_FOREVER_TS,
   1671                                             "EUR:10.0"),
   1672     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-good",
   1673                                           merchant_url,
   1674                                           MHD_HTTP_BAD_REQUEST,
   1675                                           "create-proposal-11",
   1676                                           "withdraw-coin-11a",
   1677                                           "EUR:5",
   1678                                           "EUR:4.99",
   1679                                           NULL),
   1680     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-bad",
   1681                                           merchant_url,
   1682                                           MHD_HTTP_CONFLICT,
   1683                                           "create-proposal-11",
   1684                                           "withdraw-coin-1",
   1685                                           "EUR:5",
   1686                                           "EUR:4.99",
   1687                                           NULL),
   1688     TALER_TESTING_cmd_merchant_order_abort ("pay-abort-11",
   1689                                             merchant_url,
   1690                                             "pay-fail-partial-double-11-good",
   1691                                             MHD_HTTP_OK),
   1692     TALER_TESTING_cmd_sleep (
   1693       "Wait for wire transfer deadline",
   1694       3),
   1695     CMD_EXEC_AGGREGATOR ("run-aggregator-11"),
   1696     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-11"),
   1697     TALER_TESTING_cmd_end ()
   1698   };
   1699 
   1700   struct TALER_TESTING_Command templates[] = {
   1701     cmd_transfer_to_exchange ("create-reserve-20x",
   1702                               "EUR:20.04"),
   1703     cmd_exec_wirewatch ("wirewatch-20x"),
   1704     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-20x",
   1705                                                  "EUR:20.04",
   1706                                                  payer_payto,
   1707                                                  exchange_payto,
   1708                                                  "create-reserve-20x"),
   1709     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xa",
   1710                                        "create-reserve-20x",
   1711                                        "EUR:5",
   1712                                        0,
   1713                                        MHD_HTTP_OK),
   1714     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xb",
   1715                                        "create-reserve-20x",
   1716                                        "EUR:5",
   1717                                        0,
   1718                                        MHD_HTTP_OK),
   1719     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xc",
   1720                                        "create-reserve-20x",
   1721                                        "EUR:5",
   1722                                        0,
   1723                                        MHD_HTTP_OK),
   1724     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xd",
   1725                                        "create-reserve-20x",
   1726                                        "EUR:5",
   1727                                        0,
   1728                                        MHD_HTTP_OK),
   1729     TALER_TESTING_cmd_status ("withdraw-status-20x",
   1730                               "create-reserve-20x",
   1731                               "EUR:0",
   1732                               MHD_HTTP_OK),
   1733     TALER_TESTING_cmd_merchant_get_templates ("get-templates-empty",
   1734                                               merchant_url,
   1735                                               MHD_HTTP_OK,
   1736                                               NULL),
   1737     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1",
   1738                                                merchant_url,
   1739                                                "template-1",
   1740                                                "a template",
   1741                                                MHD_HTTP_NO_CONTENT),
   1742     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-idem",
   1743                                                merchant_url,
   1744                                                "template-1",
   1745                                                "a template",
   1746                                                MHD_HTTP_NO_CONTENT),
   1747     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-non-idem",
   1748                                                merchant_url,
   1749                                                "template-1",
   1750                                                "a different template",
   1751                                                MHD_HTTP_CONFLICT),
   1752     TALER_TESTING_cmd_merchant_get_templates ("get-templates-t1",
   1753                                               merchant_url,
   1754                                               MHD_HTTP_OK,
   1755                                               "post-templates-t1",
   1756                                               NULL),
   1757     TALER_TESTING_cmd_merchant_get_template ("get-template-t1",
   1758                                              merchant_url,
   1759                                              "template-1",
   1760                                              MHD_HTTP_OK,
   1761                                              "post-templates-t1"),
   1762     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t2",
   1763                                                merchant_url,
   1764                                                "template-2",
   1765                                                "a template",
   1766                                                MHD_HTTP_NO_CONTENT),
   1767     TALER_TESTING_cmd_merchant_patch_template (
   1768       "patch-templates-t2",
   1769       merchant_url,
   1770       "template-2",
   1771       "another template",
   1772       NULL,
   1773       GNUNET_JSON_PACK (
   1774         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
   1775         GNUNET_JSON_pack_time_rel ("pay_duration",
   1776                                    GNUNET_TIME_UNIT_MINUTES)),
   1777       MHD_HTTP_NO_CONTENT),
   1778     TALER_TESTING_cmd_merchant_get_template ("get-template-t2",
   1779                                              merchant_url,
   1780                                              "template-2",
   1781                                              MHD_HTTP_OK,
   1782                                              "patch-templates-t2"),
   1783     TALER_TESTING_cmd_merchant_get_template ("get-template-nx",
   1784                                              merchant_url,
   1785                                              "template-nx",
   1786                                              MHD_HTTP_NOT_FOUND,
   1787                                              NULL),
   1788     TALER_TESTING_cmd_merchant_post_otp_devices (
   1789       "post-otp-device",
   1790       merchant_url,
   1791       "otp-dev",
   1792       "my OTP device",
   1793       "FEE4P2J",
   1794       TALER_MCA_WITH_PRICE,
   1795       0,
   1796       MHD_HTTP_NO_CONTENT),
   1797     TALER_TESTING_cmd_merchant_patch_template (
   1798       "patch-templates-t3-nx",
   1799       merchant_url,
   1800       "template-3",
   1801       "updated template",
   1802       "otp-dev",
   1803       GNUNET_JSON_PACK (
   1804         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
   1805         GNUNET_JSON_pack_time_rel ("pay_duration",
   1806                                    GNUNET_TIME_UNIT_MINUTES)),
   1807       MHD_HTTP_NOT_FOUND),
   1808     TALER_TESTING_cmd_merchant_post_templates2 (
   1809       "post-templates-t3-amount",
   1810       merchant_url,
   1811       "template-amount",
   1812       "a different template with an amount",
   1813       NULL,
   1814       GNUNET_JSON_PACK (
   1815         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
   1816         GNUNET_JSON_pack_time_rel ("pay_duration",
   1817                                    GNUNET_TIME_UNIT_MINUTES),
   1818         GNUNET_JSON_pack_string ("amount",
   1819                                  "EUR:4")),
   1820       MHD_HTTP_NO_CONTENT),
   1821     TALER_TESTING_cmd_merchant_post_using_templates (
   1822       "using-templates-t1",
   1823       "post-templates-t1",
   1824       NULL,
   1825       merchant_url,
   1826       "1",
   1827       "summary-1",
   1828       "EUR:9.98",
   1829       GNUNET_TIME_UNIT_ZERO_TS,
   1830       GNUNET_TIME_UNIT_FOREVER_TS,
   1831       MHD_HTTP_OK),
   1832     TALER_TESTING_cmd_merchant_post_using_templates (
   1833       "using-templates-t1-amount-missing",
   1834       "post-templates-t1",
   1835       NULL,
   1836       merchant_url,
   1837       "2",
   1838       "summary-1",
   1839       NULL,
   1840       GNUNET_TIME_UNIT_ZERO_TS,
   1841       GNUNET_TIME_UNIT_FOREVER_TS,
   1842       MHD_HTTP_CONFLICT),
   1843     TALER_TESTING_cmd_merchant_post_using_templates (
   1844       "using-templates-t1-summary-missing",
   1845       "post-templates-t1",
   1846       NULL,
   1847       merchant_url,
   1848       "3",
   1849       NULL,
   1850       "EUR:10",
   1851       GNUNET_TIME_UNIT_ZERO_TS,
   1852       GNUNET_TIME_UNIT_FOREVER_TS,
   1853       MHD_HTTP_CONFLICT),
   1854     TALER_TESTING_cmd_merchant_post_using_templates (
   1855       "using-templates-t1-amount-conflict",
   1856       "post-templates-t3-amount",
   1857       NULL,
   1858       merchant_url,
   1859       "4",
   1860       "summary-1",
   1861       "EUR:10",
   1862       GNUNET_TIME_UNIT_ZERO_TS,
   1863       GNUNET_TIME_UNIT_FOREVER_TS,
   1864       MHD_HTTP_CONFLICT),
   1865     TALER_TESTING_cmd_merchant_post_using_templates (
   1866       "using-templates-t1-amount-duplicate",
   1867       "post-templates-t3-amount",
   1868       NULL,
   1869       merchant_url,
   1870       "4",
   1871       "summary-1",
   1872       "EUR:4",
   1873       GNUNET_TIME_UNIT_ZERO_TS,
   1874       GNUNET_TIME_UNIT_FOREVER_TS,
   1875       MHD_HTTP_CONFLICT),
   1876     TALER_TESTING_cmd_merchant_pay_order ("pay-100",
   1877                                           merchant_url,
   1878                                           MHD_HTTP_OK,
   1879                                           "using-templates-t1",
   1880                                           "withdraw-coin-xa;withdraw-coin-xb",
   1881                                           "EUR:4.99",
   1882                                           "EUR:4.99",
   1883                                           NULL),
   1884     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
   1885                                                 merchant_url,
   1886                                                 "t1",
   1887                                                 MHD_HTTP_NOT_FOUND),
   1888     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
   1889                                                 merchant_url,
   1890                                                 "template-1",
   1891                                                 MHD_HTTP_NO_CONTENT),
   1892     TALER_TESTING_cmd_merchant_post_using_templates (
   1893       "post-templates-t1-deleted",
   1894       "post-templates-t1",
   1895       NULL,
   1896       merchant_url,
   1897       "0",
   1898       "summary-1",
   1899       "EUR:5",
   1900       GNUNET_TIME_UNIT_ZERO_TS,
   1901       GNUNET_TIME_UNIT_FOREVER_TS,
   1902       MHD_HTTP_NOT_FOUND),
   1903     TALER_TESTING_cmd_merchant_post_otp_devices (
   1904       "post-otp-device",
   1905       merchant_url,
   1906       "otp-dev-2",
   1907       "my OTP device",
   1908       "secret",
   1909       TALER_MCA_WITH_PRICE,
   1910       0,
   1911       MHD_HTTP_NO_CONTENT),
   1912     TALER_TESTING_cmd_merchant_post_templates2 (
   1913       "post-templates-with-pos-key",
   1914       merchant_url,
   1915       "template-key",
   1916       "a different template with POS KEY",
   1917       "otp-dev-2",
   1918       GNUNET_JSON_PACK (
   1919         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
   1920         GNUNET_JSON_pack_time_rel ("pay_duration",
   1921                                    GNUNET_TIME_UNIT_MINUTES)),
   1922       MHD_HTTP_NO_CONTENT),
   1923 
   1924     TALER_TESTING_cmd_merchant_post_using_templates (
   1925       "using-templates-pos-key",
   1926       "post-templates-with-pos-key",
   1927       "post-otp-device",
   1928       merchant_url,
   1929       "1",
   1930       "summary-1-pos",
   1931       "EUR:9.98",
   1932       GNUNET_TIME_UNIT_ZERO_TS,
   1933       GNUNET_TIME_UNIT_FOREVER_TS,
   1934       MHD_HTTP_OK),
   1935     TALER_TESTING_cmd_merchant_pay_order ("pay-with-pos",
   1936                                           merchant_url,
   1937                                           MHD_HTTP_OK,
   1938                                           "using-templates-pos-key",
   1939                                           "withdraw-coin-xc;withdraw-coin-xd",
   1940                                           "EUR:4.99",
   1941                                           "EUR:4.99",
   1942                                           NULL),
   1943     cmd_transfer_to_exchange ("create-reserve-20y",
   1944                               "EUR:10.02"),
   1945     cmd_exec_wirewatch ("wirewatch-20y"),
   1946     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-20y",
   1947                                                  "EUR:10.02",
   1948                                                  payer_payto,
   1949                                                  exchange_payto,
   1950                                                  "create-reserve-20y"),
   1951     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-yk",
   1952                                        "create-reserve-20y",
   1953                                        "EUR:5",
   1954                                        0,
   1955                                        MHD_HTTP_OK),
   1956     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-ykb",
   1957                                        "create-reserve-20y",
   1958                                        "EUR:5",
   1959                                        0,
   1960                                        MHD_HTTP_OK),
   1961     TALER_TESTING_cmd_status ("withdraw-status-20y",
   1962                               "create-reserve-20y",
   1963                               "EUR:0",
   1964                               MHD_HTTP_OK),
   1965     TALER_TESTING_cmd_merchant_post_products_with_unit_prices (
   1966       "post-products-inv-1",
   1967       merchant_url,
   1968       "inv-product-1",
   1969       "Inventory Product One",
   1970       "test-unit",
   1971       (const char *[]) { "EUR:1", "KUDOS:1" },
   1972       2,
   1973       MHD_HTTP_NO_CONTENT),
   1974     TALER_TESTING_cmd_merchant_post_products_with_unit_prices (
   1975       "post-products-inv-2",
   1976       merchant_url,
   1977       "inv-product-2",
   1978       "Inventory Product Two",
   1979       "test-unit",
   1980       (const char *[]) { "EUR:2", "KUDOS:2" },
   1981       2,
   1982       MHD_HTTP_NO_CONTENT),
   1983     TALER_TESTING_cmd_merchant_post_templates2 (
   1984       "post-templates-inv-one",
   1985       merchant_url,
   1986       "template-inv-one",
   1987       "inventory template one",
   1988       NULL,
   1989       GNUNET_JSON_PACK (
   1990         GNUNET_JSON_pack_string ("template_type",
   1991                                  "inventory-cart"),
   1992         GNUNET_JSON_pack_string ("summary",
   1993                                  "inventory template"),
   1994         GNUNET_JSON_pack_time_rel ("pay_duration",
   1995                                    GNUNET_TIME_UNIT_MINUTES),
   1996         GNUNET_JSON_pack_array_steal (
   1997           "selected_products",
   1998           make_selected_products ("inv-product-1",
   1999                                   "inv-product-2")),
   2000         GNUNET_JSON_pack_bool ("choose_one",
   2001                                true)),
   2002       MHD_HTTP_NO_CONTENT),
   2003     TALER_TESTING_cmd_merchant_wallet_get_template (
   2004       "wallet-get-template-inv-one",
   2005       merchant_url,
   2006       "template-inv-one",
   2007       0,
   2008       NULL,
   2009       NULL,
   2010       false,
   2011       0,
   2012       NULL,
   2013       NULL,
   2014       NULL,
   2015       0,
   2016       0,
   2017       MHD_HTTP_OK),
   2018     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2019       "using-templates-inv-one",
   2020       "post-templates-inv-one",
   2021       NULL,
   2022       merchant_url,
   2023       "inv-1",
   2024       GNUNET_JSON_PACK (
   2025         GNUNET_JSON_pack_string ("amount",
   2026                                  "EUR:1"),
   2027         GNUNET_JSON_pack_string ("template_type",
   2028                                  "inventory-cart"),
   2029         GNUNET_JSON_pack_array_steal (
   2030           "inventory_selection",
   2031           make_inventory_selection ("inv-product-1",
   2032                                     "1.0",
   2033                                     NULL,
   2034                                     NULL))),
   2035       MHD_HTTP_OK),
   2036     TALER_TESTING_cmd_merchant_post_templates2 (
   2037       "post-templates-inv-multi",
   2038       merchant_url,
   2039       "template-inv-multi",
   2040       "inventory template multi",
   2041       NULL,
   2042       GNUNET_JSON_PACK (
   2043         GNUNET_JSON_pack_string ("template_type",
   2044                                  "inventory-cart"),
   2045         GNUNET_JSON_pack_string ("summary",
   2046                                  "inventory template multi"),
   2047         GNUNET_JSON_pack_time_rel ("pay_duration",
   2048                                    GNUNET_TIME_UNIT_MINUTES),
   2049         GNUNET_JSON_pack_array_steal (
   2050           "selected_products",
   2051           make_selected_products ("inv-product-1",
   2052                                   "inv-product-2"))),
   2053       MHD_HTTP_NO_CONTENT),
   2054     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2055       "using-templates-inv-multi",
   2056       "post-templates-inv-multi",
   2057       NULL,
   2058       merchant_url,
   2059       "inv-2",
   2060       GNUNET_JSON_PACK (
   2061         GNUNET_JSON_pack_string ("amount",
   2062                                  "EUR:3"),
   2063         GNUNET_JSON_pack_string ("template_type",
   2064                                  "inventory-cart"),
   2065         GNUNET_JSON_pack_array_steal (
   2066           "inventory_selection",
   2067           make_inventory_selection ("inv-product-1",
   2068                                     "1.0",
   2069                                     "inv-product-2",
   2070                                     "1.0"))),
   2071       MHD_HTTP_OK),
   2072     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2073       "using-templates-inv-one-empty",
   2074       "post-templates-inv-one",
   2075       NULL,
   2076       merchant_url,
   2077       "inv-1-empty",
   2078       GNUNET_JSON_PACK (
   2079         GNUNET_JSON_pack_string ("amount",
   2080                                  "EUR:1"),
   2081         GNUNET_JSON_pack_string ("template_type",
   2082                                  "inventory-cart"),
   2083         GNUNET_JSON_pack_array_steal (
   2084           "inventory_selection",
   2085           json_array ())),
   2086       MHD_HTTP_CONFLICT),
   2087     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2088       "using-templates-inv-one-two",
   2089       "post-templates-inv-one",
   2090       NULL,
   2091       merchant_url,
   2092       "inv-1-two",
   2093       GNUNET_JSON_PACK (
   2094         GNUNET_JSON_pack_string ("amount",
   2095                                  "EUR:3"),
   2096         GNUNET_JSON_pack_string ("template_type",
   2097                                  "inventory-cart"),
   2098         GNUNET_JSON_pack_array_steal (
   2099           "inventory_selection",
   2100           make_inventory_selection ("inv-product-1",
   2101                                     "1.0",
   2102                                     "inv-product-2",
   2103                                     "1.0"))),
   2104       MHD_HTTP_CONFLICT),
   2105     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2106       "using-templates-inv-one-tip",
   2107       "post-templates-inv-one",
   2108       NULL,
   2109       merchant_url,
   2110       "inv-1-tip",
   2111       GNUNET_JSON_PACK (
   2112         GNUNET_JSON_pack_string ("amount",
   2113                                  "EUR:1"),
   2114         GNUNET_JSON_pack_string ("tip",
   2115                                  "EUR:1"),
   2116         GNUNET_JSON_pack_string ("template_type",
   2117                                  "inventory-cart"),
   2118         GNUNET_JSON_pack_array_steal (
   2119           "inventory_selection",
   2120           make_inventory_selection ("inv-product-1",
   2121                                     "1.0",
   2122                                     NULL,
   2123                                     NULL))),
   2124       MHD_HTTP_CONFLICT),
   2125     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2126       "using-templates-inv-one-tip-ok",
   2127       "post-templates-inv-one",
   2128       NULL,
   2129       merchant_url,
   2130       "inv-1-tip-ok",
   2131       GNUNET_JSON_PACK (
   2132         GNUNET_JSON_pack_string ("amount",
   2133                                  "EUR:2"),
   2134         GNUNET_JSON_pack_string ("tip",
   2135                                  "EUR:1"),
   2136         GNUNET_JSON_pack_string ("template_type",
   2137                                  "inventory-cart"),
   2138         GNUNET_JSON_pack_array_steal (
   2139           "inventory_selection",
   2140           make_inventory_selection ("inv-product-1",
   2141                                     "1.0",
   2142                                     NULL,
   2143                                     NULL))),
   2144       MHD_HTTP_OK),
   2145     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2146       "using-templates-inv-one-unknown",
   2147       "post-templates-inv-one",
   2148       NULL,
   2149       merchant_url,
   2150       "inv-1-unknown",
   2151       GNUNET_JSON_PACK (
   2152         GNUNET_JSON_pack_string ("amount",
   2153                                  "EUR:1"),
   2154         GNUNET_JSON_pack_string ("template_type",
   2155                                  "inventory-cart"),
   2156         GNUNET_JSON_pack_array_steal (
   2157           "inventory_selection",
   2158           make_inventory_selection ("inv-product-404",
   2159                                     "1.0",
   2160                                     NULL,
   2161                                     NULL))),
   2162       MHD_HTTP_NOT_FOUND),
   2163     TALER_TESTING_cmd_merchant_post_templates2 (
   2164       "post-templates-inv-only",
   2165       merchant_url,
   2166       "template-inv-only",
   2167       "inventory template only",
   2168       NULL,
   2169       GNUNET_JSON_PACK (
   2170         GNUNET_JSON_pack_string ("template_type",
   2171                                  "inventory-cart"),
   2172         GNUNET_JSON_pack_string ("summary",
   2173                                  "inventory template only"),
   2174         GNUNET_JSON_pack_time_rel ("pay_duration",
   2175                                    GNUNET_TIME_UNIT_MINUTES),
   2176         GNUNET_JSON_pack_array_steal (
   2177           "selected_products",
   2178           make_selected_products ("inv-product-1",
   2179                                   NULL))),
   2180       MHD_HTTP_NO_CONTENT),
   2181     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2182       "using-templates-inv-only-wrong",
   2183       "post-templates-inv-only",
   2184       NULL,
   2185       merchant_url,
   2186       "inv-only-wrong",
   2187       GNUNET_JSON_PACK (
   2188         GNUNET_JSON_pack_string ("amount",
   2189                                  "EUR:2"),
   2190         GNUNET_JSON_pack_string ("template_type",
   2191                                  "inventory-cart"),
   2192         GNUNET_JSON_pack_array_steal (
   2193           "inventory_selection",
   2194           make_inventory_selection ("inv-product-2",
   2195                                     "1.0",
   2196                                     NULL,
   2197                                     NULL))),
   2198       MHD_HTTP_CONFLICT),
   2199     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2200       "using-templates-inv-multi-amount-mismatch",
   2201       "post-templates-inv-multi",
   2202       NULL,
   2203       merchant_url,
   2204       "inv-2-mismatch",
   2205       GNUNET_JSON_PACK (
   2206         GNUNET_JSON_pack_string ("amount",
   2207                                  "EUR:4"),
   2208         GNUNET_JSON_pack_string ("template_type",
   2209                                  "inventory-cart"),
   2210         GNUNET_JSON_pack_array_steal (
   2211           "inventory_selection",
   2212           make_inventory_selection ("inv-product-1",
   2213                                     "1.0",
   2214                                     "inv-product-2",
   2215                                     "1.0"))),
   2216       MHD_HTTP_CONFLICT),
   2217     TALER_TESTING_cmd_merchant_post_units ("post-unit-special",
   2218                                            merchant_url,
   2219                                            "special-unit",
   2220                                            "Special Unit",
   2221                                            "sunit",
   2222                                            true,
   2223                                            1,
   2224                                            true,
   2225                                            json_pack ("{s:s}",
   2226                                                       "en",
   2227                                                       "Special Unit"),
   2228                                            json_pack ("{s:s}",
   2229                                                       "en",
   2230                                                       "sunit"),
   2231                                            MHD_HTTP_NO_CONTENT),
   2232     TALER_TESTING_cmd_merchant_post_categories ("post-category-special",
   2233                                                 merchant_url,
   2234                                                 "Category Special",
   2235                                                 json_pack ("{s:s}",
   2236                                                            "en",
   2237                                                            "Category Special"),
   2238                                                 1,
   2239                                                 MHD_HTTP_OK),
   2240     TALER_TESTING_cmd_merchant_post_categories ("post-category-special-2",
   2241                                                 merchant_url,
   2242                                                 "Category Special Two",
   2243                                                 json_pack ("{s:s}",
   2244                                                            "en",
   2245                                                            "Category Special Two"),
   2246                                                 2,
   2247                                                 MHD_HTTP_OK),
   2248     TALER_TESTING_cmd_merchant_post_products_with_categories (
   2249       "post-products-inv-unit-1",
   2250       merchant_url,
   2251       "inv-unit-product-1",
   2252       "Inventory Unit Product One",
   2253       "special-unit",
   2254       "EUR:5",
   2255       1,
   2256       (const uint64_t[]) { 1 },
   2257       true,
   2258       1,
   2259       MHD_HTTP_NO_CONTENT),
   2260     TALER_TESTING_cmd_merchant_post_products2 (
   2261       "post-products-inv-unit-2",
   2262       merchant_url,
   2263       "inv-unit-product-2",
   2264       "Inventory Unit Product Two",
   2265       json_pack ("{s:s}", "en", "Inventory Unit Product Two"),
   2266       "test-unit",
   2267       "EUR:1.2",
   2268       "",
   2269       json_array (),
   2270       -1, /* total stock: infinite */
   2271       0,  /* minimum age */
   2272       json_pack ("{s:s}", "street", "my street"),
   2273       GNUNET_TIME_UNIT_ZERO_TS,
   2274       MHD_HTTP_NO_CONTENT),
   2275     TALER_TESTING_cmd_merchant_post_products_with_categories (
   2276       "post-products-inv-unit-3",
   2277       merchant_url,
   2278       "inv-unit-product-3",
   2279       "Inventory Unit Product Three",
   2280       "test-unit",
   2281       "EUR:9",
   2282       1,
   2283       (const uint64_t[]) { 2 },
   2284       false,
   2285       0,
   2286       MHD_HTTP_NO_CONTENT),
   2287     TALER_TESTING_cmd_merchant_post_templates2 (
   2288       "post-templates-inv-cat-prod-unit",
   2289       merchant_url,
   2290       "template-inv-cat-prod-unit",
   2291       "inventory template category+product unit",
   2292       NULL,
   2293       GNUNET_JSON_PACK (
   2294         GNUNET_JSON_pack_string ("template_type",
   2295                                  "inventory-cart"),
   2296         GNUNET_JSON_pack_string ("summary",
   2297                                  "inventory template category+product unit"),
   2298         GNUNET_JSON_pack_time_rel ("pay_duration",
   2299                                    GNUNET_TIME_UNIT_MINUTES),
   2300         GNUNET_JSON_pack_array_steal (
   2301           "selected_categories",
   2302           make_selected_categories (1,
   2303                                     0)),
   2304         GNUNET_JSON_pack_array_steal (
   2305           "selected_products",
   2306           make_selected_products ("inv-unit-product-2",
   2307                                   "inv-unit-product-3"))),
   2308       MHD_HTTP_NO_CONTENT),
   2309     TALER_TESTING_cmd_merchant_wallet_get_template (
   2310       "wallet-get-template-inv-cat-prod-unit",
   2311       merchant_url,
   2312       "template-inv-cat-prod-unit",
   2313       3,
   2314       "inv-unit-product-1",
   2315       "special-unit",
   2316       true,
   2317       1,
   2318       json_pack ("{s:s}",
   2319                  "en",
   2320                  "sunit"),
   2321       "inv-unit-product-2",
   2322       "inv-unit-product-3",
   2323       1,
   2324       2,
   2325       MHD_HTTP_OK),
   2326     TALER_TESTING_cmd_merchant_post_using_templates2 (
   2327       "using-templates-inv-cat-prod-unit",
   2328       "post-templates-inv-cat-prod-unit",
   2329       NULL,
   2330       merchant_url,
   2331       "inv-cat-prod-unit",
   2332       GNUNET_JSON_PACK (
   2333         GNUNET_JSON_pack_string ("amount",
   2334                                  "EUR:3.2"),
   2335         GNUNET_JSON_pack_string ("template_type",
   2336                                  "inventory-cart"),
   2337         GNUNET_JSON_pack_array_steal (
   2338           "inventory_selection",
   2339           make_inventory_selection ("inv-unit-product-1",
   2340                                     "0.4",
   2341                                     "inv-unit-product-2",
   2342                                     "1"))),
   2343       MHD_HTTP_OK),
   2344     TALER_TESTING_cmd_merchant_pay_order_choices (
   2345       "pay-inv-cat-prod-unit",
   2346       merchant_url,
   2347       MHD_HTTP_OK,
   2348       "using-templates-inv-cat-prod-unit",
   2349       "withdraw-coin-yk",
   2350       "EUR:3.2",
   2351       "EUR:3.2",
   2352       NULL,
   2353       0,
   2354       NULL),
   2355 
   2356 
   2357     TALER_TESTING_cmd_end ()
   2358   };
   2359 
   2360   struct TALER_TESTING_Command webhooks[] = {
   2361     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-empty",
   2362                                              merchant_url,
   2363                                              MHD_HTTP_OK,
   2364                                              NULL),
   2365     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1",
   2366                                               merchant_url,
   2367                                               "webhook-1",
   2368                                               "Paid",
   2369                                               MHD_HTTP_NO_CONTENT),
   2370     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-idem",
   2371                                               merchant_url,
   2372                                               "webhook-1",
   2373                                               "Paid",
   2374                                               MHD_HTTP_NO_CONTENT),
   2375     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-non-idem",
   2376                                               merchant_url,
   2377                                               "webhook-1",
   2378                                               "Refund",
   2379                                               MHD_HTTP_CONFLICT),
   2380     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-w1",
   2381                                              merchant_url,
   2382                                              MHD_HTTP_OK,
   2383                                              "post-webhooks-w1",
   2384                                              NULL),
   2385     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w1",
   2386                                             merchant_url,
   2387                                             "webhook-1",
   2388                                             MHD_HTTP_OK,
   2389                                             "post-webhooks-w1"),
   2390     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w2",
   2391                                               merchant_url,
   2392                                               "webhook-2",
   2393                                               "Paid",
   2394                                               MHD_HTTP_NO_CONTENT),
   2395     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w2",
   2396                                               merchant_url,
   2397                                               "webhook-2",
   2398                                               "Refund2",
   2399                                               "http://localhost:38188/",
   2400                                               "POST",
   2401                                               "Authorization:WHWOXZXPLL",
   2402                                               "Amount",
   2403                                               MHD_HTTP_NO_CONTENT),
   2404     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w2",
   2405                                             merchant_url,
   2406                                             "webhook-2",
   2407                                             MHD_HTTP_OK,
   2408                                             "patch-webhooks-w2"),
   2409     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-nx",
   2410                                             merchant_url,
   2411                                             "webhook-nx",
   2412                                             MHD_HTTP_NOT_FOUND,
   2413                                             NULL),
   2414     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w3-nx",
   2415                                               merchant_url,
   2416                                               "webhook-3",
   2417                                               "Paid2",
   2418                                               "https://example.com",
   2419                                               "POST",
   2420                                               "Authorization:WHWOXZXPLL",
   2421                                               "Amount",
   2422                                               MHD_HTTP_NOT_FOUND),
   2423     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
   2424                                                merchant_url,
   2425                                                "w1",
   2426                                                MHD_HTTP_NOT_FOUND),
   2427     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
   2428                                                merchant_url,
   2429                                                "webhook-1",
   2430                                                MHD_HTTP_NO_CONTENT),
   2431     TALER_TESTING_cmd_end ()
   2432   };
   2433   struct TALER_TESTING_Command inventory_webhooks[] = {
   2434     TALER_TESTING_cmd_testserver (
   2435       "launch-http-server-for-inventory-webhooks",
   2436       12346),
   2437     TALER_TESTING_cmd_merchant_post_webhooks2 (
   2438       "post-webhooks-inventory-added",
   2439       merchant_url,
   2440       "webhook-inventory-added",
   2441       "inventory_added",
   2442       "http://localhost:12346/",
   2443       "POST",
   2444       "Taler-test-header: inventory",
   2445       "inventory-added",
   2446       MHD_HTTP_NO_CONTENT),
   2447     TALER_TESTING_cmd_merchant_post_webhooks2 (
   2448       "post-webhooks-inventory-updated",
   2449       merchant_url,
   2450       "webhook-inventory-updated",
   2451       "inventory_updated",
   2452       "http://localhost:12346/",
   2453       "POST",
   2454       "Taler-test-header: inventory",
   2455       "inventory-updated",
   2456       MHD_HTTP_NO_CONTENT),
   2457     TALER_TESTING_cmd_merchant_post_webhooks2 (
   2458       "post-webhooks-inventory-deleted",
   2459       merchant_url,
   2460       "webhook-inventory-deleted",
   2461       "inventory_deleted",
   2462       "http://localhost:12346/",
   2463       "POST",
   2464       "Taler-test-header: inventory",
   2465       "inventory-deleted",
   2466       MHD_HTTP_NO_CONTENT),
   2467     TALER_TESTING_cmd_merchant_post_products (
   2468       "post-product-inventory-hook",
   2469       merchant_url,
   2470       "product-inventory-hook",
   2471       "webhook inventory product",
   2472       "EUR:1",
   2473       MHD_HTTP_NO_CONTENT),
   2474     cmd_webhook ("pending-webhooks-inventory-added"),
   2475     TALER_TESTING_cmd_checkserver2 (
   2476       "check-inventory-webhook-added",
   2477       "launch-http-server-for-inventory-webhooks",
   2478       0,
   2479       "/",
   2480       "POST",
   2481       NULL,
   2482       "inventory-added"),
   2483     TALER_TESTING_cmd_merchant_patch_product (
   2484       "patch-product-inventory-hook",
   2485       merchant_url,
   2486       "product-inventory-hook",
   2487       "webhook inventory product patched",
   2488       json_object (),
   2489       "unit",
   2490       "EUR:2",
   2491       "",
   2492       json_array (),
   2493       5,
   2494       0,
   2495       json_object (),
   2496       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
   2497       MHD_HTTP_NO_CONTENT),
   2498     cmd_webhook ("pending-webhooks-inventory-updated"),
   2499     TALER_TESTING_cmd_checkserver2 (
   2500       "check-inventory-webhook-updated",
   2501       "launch-http-server-for-inventory-webhooks",
   2502       1,
   2503       "/",
   2504       "POST",
   2505       NULL,
   2506       "inventory-updated"),
   2507     TALER_TESTING_cmd_merchant_delete_product (
   2508       "delete-product-inventory-hook",
   2509       merchant_url,
   2510       "product-inventory-hook",
   2511       MHD_HTTP_NO_CONTENT),
   2512     cmd_webhook ("pending-webhooks-inventory-deleted"),
   2513     TALER_TESTING_cmd_checkserver2 (
   2514       "check-inventory-webhook-deleted",
   2515       "launch-http-server-for-inventory-webhooks",
   2516       2,
   2517       "/",
   2518       "POST",
   2519       NULL,
   2520       "inventory-deleted"),
   2521     TALER_TESTING_cmd_end ()
   2522   };
   2523   struct TALER_TESTING_Command repurchase[] = {
   2524     cmd_transfer_to_exchange (
   2525       "create-reserve-30x",
   2526       "EUR:30.06"),
   2527     cmd_exec_wirewatch (
   2528       "wirewatch-30x"),
   2529     TALER_TESTING_cmd_check_bank_admin_transfer (
   2530       "check_bank_transfer-30x",
   2531       "EUR:30.06",
   2532       payer_payto,
   2533       exchange_payto,
   2534       "create-reserve-30x"),
   2535     TALER_TESTING_cmd_withdraw_amount (
   2536       "withdraw-coin-rep",
   2537       "create-reserve-30x",
   2538       "EUR:5",
   2539       0,
   2540       MHD_HTTP_OK),
   2541     TALER_TESTING_cmd_merchant_post_orders3 (
   2542       "post-order-repurchase-original",
   2543       cred.cfg,
   2544       merchant_url,
   2545       MHD_HTTP_OK,
   2546       "repurchase-original",
   2547       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_HOURS),
   2548       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
   2549       "https://fulfillment.example.com/",
   2550       "EUR:1.0"),
   2551     TALER_TESTING_cmd_merchant_pay_order (
   2552       "repurchase-pay-first",
   2553       merchant_url,
   2554       MHD_HTTP_OK,
   2555       "post-order-repurchase-original",
   2556       "withdraw-coin-rep",
   2557       "EUR:1.00",
   2558       "EUR:0.99",
   2559       "repurchase-session"),
   2560     TALER_TESTING_cmd_wallet_get_order (
   2561       "repurchase-wallet-check-primary-order",
   2562       merchant_url,
   2563       "post-order-repurchase-original",
   2564       true,
   2565       false,
   2566       false,
   2567       MHD_HTTP_OK),
   2568     TALER_TESTING_cmd_merchant_get_order3 (
   2569       "repurchase-check-primary-payment",
   2570       merchant_url,
   2571       "post-order-repurchase-original",
   2572       TALER_MERCHANT_OSC_PAID,
   2573       "repurchase-session",
   2574       NULL,
   2575       MHD_HTTP_OK),
   2576     TALER_TESTING_cmd_merchant_get_order3 (
   2577       "repurchase-check-primary-payment-bad-binding",
   2578       merchant_url,
   2579       "post-order-repurchase-original",
   2580       TALER_MERCHANT_OSC_CLAIMED, /* someone else has it! */
   2581       "wrong-session",
   2582       NULL,
   2583       MHD_HTTP_OK),
   2584     TALER_TESTING_cmd_merchant_post_orders3 (
   2585       "post-order-repurchase-secondary",
   2586       cred.cfg,
   2587       merchant_url,
   2588       MHD_HTTP_OK,
   2589       "repurchase-secondary",
   2590       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_HOURS),
   2591       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
   2592       "https://fulfillment.example.com/",
   2593       "EUR:1.0"),
   2594     TALER_TESTING_cmd_merchant_get_order3 (
   2595       "repurchase-check-secondary-payment",
   2596       merchant_url,
   2597       "post-order-repurchase-secondary",
   2598       TALER_MERCHANT_OSC_UNPAID,
   2599       "repurchase-session",
   2600       NULL,
   2601       MHD_HTTP_OK),
   2602     TALER_TESTING_cmd_merchant_get_order3 (
   2603       "repurchase-check-secondary-payment",
   2604       merchant_url,
   2605       "post-order-repurchase-secondary",
   2606       TALER_MERCHANT_OSC_UNPAID,
   2607       "repurchase-session",
   2608       "post-order-repurchase-original",
   2609       MHD_HTTP_OK),
   2610     TALER_TESTING_cmd_wallet_get_order2 (
   2611       "repurchase-wallet-check-order-secondary",
   2612       merchant_url,
   2613       "post-order-repurchase-secondary",
   2614       "repurchase-session",
   2615       false,
   2616       false,
   2617       false,
   2618       "post-order-repurchase-original",
   2619       MHD_HTTP_PAYMENT_REQUIRED),
   2620     TALER_TESTING_cmd_wallet_get_order2 (
   2621       "repurchase-wallet-check-order-secondary-bad-session",
   2622       merchant_url,
   2623       "post-order-repurchase-secondary",
   2624       "wrong-session",
   2625       false,
   2626       false,
   2627       false,
   2628       NULL,
   2629       MHD_HTTP_PAYMENT_REQUIRED),
   2630     TALER_TESTING_cmd_merchant_order_refund (
   2631       "refund-repurchased",
   2632       merchant_url,
   2633       "refund repurchase",
   2634       "repurchase-original",
   2635       "EUR:1.0",
   2636       MHD_HTTP_OK),
   2637     TALER_TESTING_cmd_wallet_get_order2 (
   2638       "repurchase-wallet-check-primary-order-refunded-no-session",
   2639       merchant_url,
   2640       "post-order-repurchase-original",
   2641       NULL,
   2642       true,
   2643       true,
   2644       true,
   2645       "post-order-repurchase-original",
   2646       MHD_HTTP_OK),
   2647     TALER_TESTING_cmd_wallet_get_order2 (
   2648       "repurchase-wallet-check-primary-order-refunded",
   2649       merchant_url,
   2650       "post-order-repurchase-original",
   2651       "repurchase-session",
   2652       true,
   2653       true,
   2654       true,
   2655       "post-order-repurchase-original",
   2656       MHD_HTTP_OK),
   2657     TALER_TESTING_cmd_merchant_get_order3 (
   2658       "repurchase-check-refunded",
   2659       merchant_url,
   2660       "post-order-repurchase-secondary",
   2661       TALER_MERCHANT_OSC_CLAIMED,
   2662       "repurchase-session",
   2663       NULL,
   2664       MHD_HTTP_OK),
   2665 
   2666     TALER_TESTING_cmd_end ()
   2667   };
   2668 
   2669   struct TALER_TESTING_Command tokens[] = {
   2670     /**
   2671      * Move money to the exchange's bank account.
   2672      */
   2673     cmd_transfer_to_exchange ("create-reserve-tokens",
   2674                               "EUR:20.03"),
   2675     /**
   2676      * Make a reserve exist, according to the previous transfer.
   2677      */
   2678     cmd_exec_wirewatch ("wirewatch-1"),
   2679     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-tokens",
   2680                                                  "EUR:20.03",
   2681                                                  payer_payto,
   2682                                                  exchange_payto,
   2683                                                  "create-reserve-tokens"),
   2684     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
   2685                                        "create-reserve-tokens",
   2686                                        "EUR:5",
   2687                                        0,
   2688                                        MHD_HTTP_OK),
   2689     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
   2690                                        "create-reserve-tokens",
   2691                                        "EUR:5",
   2692                                        0,
   2693                                        MHD_HTTP_OK),
   2694     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-3",
   2695                                        "create-reserve-tokens",
   2696                                        "EUR:5",
   2697                                        0,
   2698                                        MHD_HTTP_OK),
   2699     TALER_TESTING_cmd_merchant_post_tokenfamilies (
   2700       "create-upcoming-tokenfamily",
   2701       merchant_url,
   2702       MHD_HTTP_NO_CONTENT,
   2703       "subscription-upcoming",
   2704       "Upcoming Subscription",
   2705       "An upcoming subscription that is not valid yet.",
   2706       NULL,
   2707       /* In one day */
   2708       GNUNET_TIME_absolute_to_timestamp (
   2709         GNUNET_TIME_absolute_add (
   2710           GNUNET_TIME_timestamp_get ().abs_time,
   2711           GNUNET_TIME_UNIT_DAYS)),
   2712       /* In a year */
   2713       GNUNET_TIME_absolute_to_timestamp (
   2714         GNUNET_TIME_absolute_add (
   2715           GNUNET_TIME_timestamp_get ().abs_time,
   2716           GNUNET_TIME_UNIT_YEARS)),
   2717       GNUNET_TIME_UNIT_MONTHS,
   2718       GNUNET_TIME_UNIT_MONTHS,
   2719       "subscription"),
   2720     TALER_TESTING_cmd_merchant_post_orders_choices (
   2721       "create-order-with-upcoming-output",
   2722       cred.cfg,
   2723       merchant_url,
   2724       MHD_HTTP_OK,
   2725       "subscription-upcoming",
   2726       "A choice in the contract",
   2727       NULL,
   2728       0,
   2729       1,
   2730       "5-upcoming-output",
   2731       GNUNET_TIME_UNIT_ZERO_TS,
   2732       GNUNET_TIME_UNIT_FOREVER_TS,
   2733       "EUR:5.0"),
   2734     TALER_TESTING_cmd_merchant_post_tokenfamilies (
   2735       "create-tokenfamily",
   2736       merchant_url,
   2737       MHD_HTTP_NO_CONTENT,
   2738       "subscription-1",
   2739       "Subscription",
   2740       "A subscription.",
   2741       NULL,
   2742       GNUNET_TIME_UNIT_ZERO_TS,
   2743       GNUNET_TIME_relative_to_timestamp (
   2744         GNUNET_TIME_UNIT_YEARS),
   2745       GNUNET_TIME_UNIT_MONTHS,
   2746       GNUNET_TIME_UNIT_MONTHS,
   2747       "subscription"),
   2748     TALER_TESTING_cmd_merchant_post_orders_choices (
   2749       "create-order-with-output",
   2750       cred.cfg,
   2751       merchant_url,
   2752       MHD_HTTP_OK,
   2753       "subscription-1",
   2754       "A choice in the contract",
   2755       NULL,
   2756       0,
   2757       1,
   2758       "5-output",
   2759       GNUNET_TIME_UNIT_ZERO_TS,
   2760       GNUNET_TIME_UNIT_FOREVER_TS,
   2761       "EUR:5.0"),
   2762     TALER_TESTING_cmd_merchant_pay_order_choices (
   2763       "pay-order-with-output",
   2764       merchant_url,
   2765       MHD_HTTP_OK,
   2766       "create-order-with-output",
   2767       "withdraw-coin-1",
   2768       "EUR:5",
   2769       "EUR:4.99",
   2770       NULL,
   2771       0,
   2772       NULL),
   2773     TALER_TESTING_cmd_merchant_post_orders_choices (
   2774       "create-order-with-input-and-output",
   2775       cred.cfg,
   2776       merchant_url,
   2777       MHD_HTTP_OK,
   2778       "subscription-1",
   2779       "A choice in the contract",
   2780       NULL,
   2781       1,
   2782       1,
   2783       "5-input-output",
   2784       GNUNET_TIME_UNIT_ZERO_TS,
   2785       GNUNET_TIME_UNIT_FOREVER_TS,
   2786       "EUR:0.0"),
   2787     TALER_TESTING_cmd_merchant_pay_order_choices (
   2788       "pay-order-with-input-and-output",
   2789       merchant_url,
   2790       MHD_HTTP_OK,
   2791       "create-order-with-input-and-output",
   2792       "",
   2793       "EUR:0",
   2794       "EUR:0",
   2795       NULL,
   2796       0,
   2797       "pay-order-with-output"),
   2798     // TALER_TESTING_cmd_merchant_pay_order_choices ("idempotent-pay-order-with-input-and-output",
   2799     //                                               merchant_url,
   2800     //                                               MHD_HTTP_OK,
   2801     //                                               "create-order-with-input-and-output",
   2802     //                                               "",
   2803     //                                               "EUR:0",
   2804     //                                               "EUR:0",
   2805     //                                               NULL,
   2806     //                                               0,
   2807     //                                               "pay-order-with-output"),
   2808     TALER_TESTING_cmd_merchant_post_orders_choices (
   2809       "create-another-order-with-input-and-output",
   2810       cred.cfg,
   2811       merchant_url,
   2812       MHD_HTTP_OK,
   2813       "subscription-1",
   2814       "A choice in the contract",
   2815       NULL,
   2816       1,
   2817       1,
   2818       "5-input-output-2",
   2819       GNUNET_TIME_UNIT_ZERO_TS,
   2820       GNUNET_TIME_UNIT_FOREVER_TS,
   2821       "EUR:0.0"),
   2822     TALER_TESTING_cmd_merchant_pay_order_choices ("double-spend-token",
   2823                                                   merchant_url,
   2824                                                   MHD_HTTP_CONFLICT,
   2825                                                   "create-another-order-with-input-and-output",
   2826                                                   "",
   2827                                                   "EUR:0",
   2828                                                   "EUR:0",
   2829                                                   NULL,
   2830                                                   0,
   2831                                                   "pay-order-with-output"),
   2832     TALER_TESTING_cmd_end ()
   2833   };
   2834 
   2835   const struct DONAU_BearerToken bearer = {
   2836     .token = NULL
   2837   };
   2838 
   2839   struct TALER_TESTING_Command donau[] = {
   2840     TALER_TESTING_cmd_set_var (
   2841       "donau",
   2842       TALER_TESTING_cmd_get_donau ("get-donau",
   2843                                    cred.cfg,
   2844                                    true /* wait for response */)),
   2845     TALER_TESTING_cmd_charity_post_merchant ("post-charity",
   2846                                              "example",
   2847                                              "example.com",
   2848                                              "EUR:50", // max_per_year
   2849                                              &bearer,
   2850                                              "create-another-order-with-input-and-output",
   2851                                              // reusing the merchant_reference for merchant_pub
   2852                                              MHD_HTTP_CREATED),
   2853     TALER_TESTING_cmd_charity_post_merchant ("post-charity-idempotent",
   2854                                              "example",
   2855                                              "example.com",
   2856                                              "EUR:50", // max_per_year
   2857                                              &bearer,
   2858                                              "create-another-order-with-input-and-output",
   2859                                              // reusing the merchant_reference for merchant_pub
   2860                                              MHD_HTTP_CREATED),
   2861     TALER_TESTING_cmd_merchant_post_donau_instance (
   2862       "post-donau-instance",
   2863       merchant_url,
   2864       "create-another-order-with-input-and-output",
   2865       MHD_HTTP_NO_CONTENT),
   2866     TALER_TESTING_cmd_merchant_post_donau_instance (
   2867       "post-donau-instance-idempotent",
   2868       merchant_url,
   2869       "create-another-order-with-input-and-output",
   2870       MHD_HTTP_NO_CONTENT),
   2871     TALER_TESTING_cmd_merchant_get_donau_instances (
   2872       "get-donau-instances-after-insert",
   2873       merchant_url,
   2874       1,
   2875       MHD_HTTP_OK),
   2876     TALER_TESTING_cmd_exec_donaukeyupdate ("run-merchant-donaukeyupdate",
   2877                                            config_file),
   2878     TALER_TESTING_cmd_merchant_get_donau_instances (
   2879       "get-donau-instance",
   2880       merchant_url,
   2881       1,
   2882       MHD_HTTP_OK),
   2883     TALER_TESTING_cmd_merchant_post_orders_donau (
   2884       "create-donau-order",
   2885       cred.cfg,
   2886       merchant_url,
   2887       MHD_HTTP_OK,
   2888       "donau",
   2889       GNUNET_TIME_UNIT_ZERO_TS,
   2890       GNUNET_TIME_UNIT_FOREVER_TS,
   2891       "EUR:1"),
   2892     TALER_TESTING_cmd_merchant_pay_order_donau (
   2893       "pay-donau-order",
   2894       merchant_url,
   2895       MHD_HTTP_OK,
   2896       "create-donau-order",
   2897       "withdraw-coin-3",
   2898       "EUR:1", /* full amount */
   2899       "EUR:0.99", /* amount without fees */
   2900       "EUR:1", /* donation amount */
   2901       NULL,
   2902       0,
   2903       "post-charity",
   2904       GNUNET_TIME_get_current_year (),
   2905       "7560001010000",
   2906       "1234"
   2907       ),
   2908     TALER_TESTING_cmd_merchant_delete_donau_instance (
   2909       "delete-donau-instance",
   2910       merchant_url,
   2911       1,
   2912       MHD_HTTP_NO_CONTENT),
   2913     TALER_TESTING_cmd_merchant_get_donau_instances (
   2914       "get-donau-instances-after-delete",
   2915       merchant_url,
   2916       0,
   2917       MHD_HTTP_OK),
   2918     TALER_TESTING_cmd_end ()
   2919   };
   2920 
   2921   struct TALER_TESTING_Command commands[] = {
   2922     /* general setup */
   2923     TALER_TESTING_cmd_run_fakebank (
   2924       "run-fakebank",
   2925       cred.cfg,
   2926       "exchange-account-exchange"),
   2927     TALER_TESTING_cmd_system_start (
   2928       "start-taler",
   2929       config_file,
   2930       "-emaD",
   2931       "-u", "exchange-account-exchange",
   2932       "-r", "merchant-exchange-test",
   2933       NULL),
   2934     TALER_TESTING_cmd_get_exchange (
   2935       "get-exchange",
   2936       cred.cfg,
   2937       NULL,
   2938       true,
   2939       true),
   2940     TALER_TESTING_cmd_batch (
   2941       "orders-id",
   2942       get_private_order_id),
   2943     TALER_TESTING_cmd_config (
   2944       "config",
   2945       merchant_url,
   2946       MHD_HTTP_OK),
   2947     TALER_TESTING_cmd_merchant_get_instances (
   2948       "instances-empty",
   2949       merchant_url,
   2950       MHD_HTTP_OK,
   2951       NULL),
   2952     TALER_TESTING_cmd_merchant_post_instances (
   2953       "instance-create-default-setup",
   2954       merchant_url,
   2955       "admin",
   2956       MHD_HTTP_NO_CONTENT),
   2957     TALER_TESTING_cmd_merchant_post_account (
   2958       "instance-create-default-account",
   2959       merchant_url,
   2960       merchant_payto,
   2961       NULL, NULL,
   2962       MHD_HTTP_OK),
   2963     TALER_TESTING_cmd_merchant_post_instances (
   2964       "instance-create-i1",
   2965       merchant_url,
   2966       "i1",
   2967       MHD_HTTP_NO_CONTENT),
   2968     TALER_TESTING_cmd_merchant_get_instances (
   2969       "instances-get-i1",
   2970       merchant_url,
   2971       MHD_HTTP_OK,
   2972       "instance-create-i1",
   2973       "instance-create-default-setup",
   2974       NULL),
   2975     TALER_TESTING_cmd_merchant_get_instance (
   2976       "instances-get-i1",
   2977       merchant_url,
   2978       "i1",
   2979       MHD_HTTP_OK,
   2980       "instance-create-i1"),
   2981     TALER_TESTING_cmd_merchant_patch_instance (
   2982       "instance-patch-i1",
   2983       merchant_url,
   2984       "i1",
   2985       "bob-the-merchant",
   2986       json_pack ("{s:s}",
   2987                  "street",
   2988                  "bobstreet"),
   2989       json_pack ("{s:s}",
   2990                  "street",
   2991                  "bobjuryst"),
   2992       true,
   2993       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
   2994       GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
   2995                                      2), /* small pay delay */
   2996       MHD_HTTP_NO_CONTENT),
   2997     TALER_TESTING_cmd_merchant_get_instance (
   2998       "instances-get-i1-2",
   2999       merchant_url,
   3000       "i1",
   3001       MHD_HTTP_OK,
   3002       "instance-patch-i1"),
   3003     TALER_TESTING_cmd_merchant_get_instance (
   3004       "instances-get-i2-nx",
   3005       merchant_url,
   3006       "i2",
   3007       MHD_HTTP_NOT_FOUND,
   3008       NULL),
   3009     TALER_TESTING_cmd_merchant_post_instances2 (
   3010       "instance-create-ACL",
   3011       merchant_url,
   3012       "i-acl",
   3013       "controlled instance",
   3014       json_pack ("{s:s}", "city",
   3015                  "shopcity"),
   3016       json_pack ("{s:s}", "city",
   3017                  "lawyercity"),
   3018       true,
   3019       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
   3020       GNUNET_TIME_UNIT_SECONDS, /* pay delay */
   3021       // FIXME: change this back once
   3022       // we have a update auth test CMD
   3023       // RFC_8959_PREFIX "EXAMPLE",
   3024       NULL,
   3025       MHD_HTTP_NO_CONTENT),
   3026     TALER_TESTING_cmd_merchant_patch_instance (
   3027       "instance-patch-ACL",
   3028       merchant_url,
   3029       "i-acl",
   3030       "controlled instance",
   3031       json_pack ("{s:s}",
   3032                  "street",
   3033                  "bobstreet"),
   3034       json_pack ("{s:s}",
   3035                  "street",
   3036                  "bobjuryst"),
   3037       true,
   3038       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
   3039       GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
   3040                                      2), /* small pay delay */
   3041       MHD_HTTP_NO_CONTENT),
   3042     TALER_TESTING_cmd_merchant_post_instances (
   3043       "instance-create-i2",
   3044       merchant_url,
   3045       "i2",
   3046       MHD_HTTP_NO_CONTENT),
   3047     TALER_TESTING_cmd_merchant_post_instances (
   3048       "instance-create-i2-idem",
   3049       merchant_url,
   3050       "i2",
   3051       MHD_HTTP_NO_CONTENT),
   3052     TALER_TESTING_cmd_merchant_delete_instance (
   3053       "instance-delete-i2",
   3054       merchant_url,
   3055       "i2",
   3056       MHD_HTTP_NO_CONTENT),
   3057     TALER_TESTING_cmd_merchant_get_instance (
   3058       "instances-get-i2-post-deletion",
   3059       merchant_url,
   3060       "i2",
   3061       MHD_HTTP_NOT_FOUND,
   3062       NULL),
   3063     TALER_TESTING_cmd_merchant_purge_instance (
   3064       "instance-delete-then-purge-i2",
   3065       merchant_url,
   3066       "i2",
   3067       MHD_HTTP_NO_CONTENT),
   3068     TALER_TESTING_cmd_merchant_purge_instance (
   3069       "instance-purge-i1",
   3070       merchant_url,
   3071       "i1",
   3072       MHD_HTTP_NO_CONTENT),
   3073     TALER_TESTING_cmd_merchant_delete_instance (
   3074       "instance-purge-then-delete-i1",
   3075       merchant_url,
   3076       "i1",
   3077       MHD_HTTP_NOT_FOUND),
   3078     TALER_TESTING_cmd_merchant_purge_instance (
   3079       "instance-purge-i-acl-middle",
   3080       merchant_url,
   3081       "i-acl",
   3082       MHD_HTTP_NO_CONTENT),
   3083     TALER_TESTING_cmd_merchant_purge_instance (
   3084       "instance-purge-default-middle",
   3085       merchant_url,
   3086       "admin",
   3087       MHD_HTTP_NO_CONTENT),
   3088     TALER_TESTING_cmd_merchant_post_instances (
   3089       "instance-create-default-after-purge",
   3090       merchant_url,
   3091       "admin",
   3092       MHD_HTTP_NO_CONTENT),
   3093     TALER_TESTING_cmd_merchant_post_account (
   3094       "instance-create-default-account-after-purge",
   3095       merchant_url,
   3096       merchant_payto,
   3097       NULL, NULL,
   3098       MHD_HTTP_OK),
   3099     TALER_TESTING_cmd_merchant_get_products (
   3100       "get-products-empty",
   3101       merchant_url,
   3102       MHD_HTTP_OK,
   3103       NULL),
   3104     TALER_TESTING_cmd_merchant_post_products (
   3105       "post-products-p1",
   3106       merchant_url,
   3107       "product-1",
   3108       "a product",
   3109       "EUR:1",
   3110       MHD_HTTP_NO_CONTENT),
   3111     TALER_TESTING_cmd_merchant_post_products (
   3112       "post-products-p1-idem",
   3113       merchant_url,
   3114       "product-1",
   3115       "a product",
   3116       "EUR:1",
   3117       MHD_HTTP_NO_CONTENT),
   3118     TALER_TESTING_cmd_merchant_post_products (
   3119       "post-products-p1-non-idem",
   3120       merchant_url,
   3121       "product-1",
   3122       "a different product",
   3123       "EUR:1",
   3124       MHD_HTTP_CONFLICT),
   3125     TALER_TESTING_cmd_merchant_get_products (
   3126       "get-products-p1",
   3127       merchant_url,
   3128       MHD_HTTP_OK,
   3129       "post-products-p1",
   3130       NULL),
   3131     TALER_TESTING_cmd_merchant_get_product (
   3132       "get-product-p1",
   3133       merchant_url,
   3134       "product-1",
   3135       MHD_HTTP_OK,
   3136       "post-products-p1"),
   3137     TALER_TESTING_cmd_merchant_post_products2 (
   3138       "post-products-img",
   3139       merchant_url,
   3140       "product-img",
   3141       "product with image",
   3142       json_pack ("{s:s}", "en", "product with image"),
   3143       "test-unit",
   3144       "EUR:1",
   3145       "data:image/jpeg;base64,RAWDATA",
   3146       json_array (),
   3147       4,
   3148       0,
   3149       json_pack ("{s:s}", "street", "my street"),
   3150       GNUNET_TIME_UNIT_ZERO_TS,
   3151       MHD_HTTP_NO_CONTENT),
   3152     TALER_TESTING_cmd_get_product_image (
   3153       "get-product-image-img",
   3154       merchant_url,
   3155       "post-products-img",
   3156       "5831ca012639a29df949c3b1e5cd436bac0a5b26a5340ccd95df394b7a8742d6",
   3157       MHD_HTTP_OK),
   3158     TALER_TESTING_cmd_get_product_image (
   3159       "get-product-image-invalid",
   3160       merchant_url,
   3161       NULL,
   3162       "not-a-valid-hash",
   3163       MHD_HTTP_BAD_REQUEST),
   3164     TALER_TESTING_cmd_get_product_image (
   3165       "get-product-image-empty",
   3166       merchant_url,
   3167       NULL,
   3168       "",
   3169       MHD_HTTP_BAD_REQUEST),
   3170     TALER_TESTING_cmd_get_product_image (
   3171       "get-product-image-not-found",
   3172       merchant_url,
   3173       NULL,
   3174       "5831ca012639a29df949c3b1e5cd436bac0a5b26a5340ccd95df394b7a8742d7",
   3175       MHD_HTTP_NOT_FOUND),
   3176     TALER_TESTING_cmd_merchant_post_products (
   3177       "post-products-p2",
   3178       merchant_url,
   3179       "product-2",
   3180       "a product",
   3181       "EUR:1",
   3182       MHD_HTTP_NO_CONTENT),
   3183     TALER_TESTING_cmd_merchant_patch_product (
   3184       "patch-products-p2",
   3185       merchant_url,
   3186       "product-2",
   3187       "another product",
   3188       json_pack ("{s:s}", "en", "text"),
   3189       "kg",
   3190       "EUR:1",
   3191       "data:image/jpeg;base64,RAWDATA",
   3192       json_array (),
   3193       40,
   3194       0,
   3195       json_pack ("{s:s}",
   3196                  "street",
   3197                  "pstreet"),
   3198       GNUNET_TIME_relative_to_timestamp (
   3199         GNUNET_TIME_UNIT_MINUTES),
   3200       MHD_HTTP_NO_CONTENT),
   3201     TALER_TESTING_cmd_merchant_get_product (
   3202       "get-product-p2",
   3203       merchant_url,
   3204       "product-2",
   3205       MHD_HTTP_OK,
   3206       "patch-products-p2"),
   3207     TALER_TESTING_cmd_merchant_get_product (
   3208       "get-product-nx",
   3209       merchant_url,
   3210       "product-nx",
   3211       MHD_HTTP_NOT_FOUND,
   3212       NULL),
   3213     TALER_TESTING_cmd_merchant_patch_product (
   3214       "patch-products-p3-nx",
   3215       merchant_url,
   3216       "product-3",
   3217       "nx updated product",
   3218       json_pack ("{s:s}", "en", "text"),
   3219       "kg",
   3220       "EUR:1",
   3221       "data:image/jpeg;base64,RAWDATA",
   3222       json_array (),
   3223       40,
   3224       0,
   3225       json_pack ("{s:s}",
   3226                  "street",
   3227                  "pstreet"),
   3228       GNUNET_TIME_relative_to_timestamp (
   3229         GNUNET_TIME_UNIT_MINUTES),
   3230       MHD_HTTP_NOT_FOUND),
   3231     TALER_TESTING_cmd_merchant_delete_product (
   3232       "get-products-empty",
   3233       merchant_url,
   3234       "p1",
   3235       MHD_HTTP_NOT_FOUND),
   3236     TALER_TESTING_cmd_merchant_delete_product (
   3237       "get-products-empty",
   3238       merchant_url,
   3239       "product-1",
   3240       MHD_HTTP_NO_CONTENT),
   3241     TALER_TESTING_cmd_merchant_lock_product (
   3242       "lock-product-p2",
   3243       merchant_url,
   3244       "product-2",
   3245       GNUNET_TIME_UNIT_MINUTES,
   3246       2,
   3247       MHD_HTTP_NO_CONTENT),
   3248     TALER_TESTING_cmd_merchant_lock_product (
   3249       "lock-product-nx",
   3250       merchant_url,
   3251       "product-nx",
   3252       GNUNET_TIME_UNIT_MINUTES,
   3253       2,
   3254       MHD_HTTP_NOT_FOUND),
   3255     TALER_TESTING_cmd_merchant_lock_product (
   3256       "lock-product-too-much",
   3257       merchant_url,
   3258       "product-2",
   3259       GNUNET_TIME_UNIT_MINUTES,
   3260       39,
   3261       MHD_HTTP_GONE),
   3262     TALER_TESTING_cmd_merchant_delete_product (
   3263       "delete-product-locked",
   3264       merchant_url,
   3265       "product-2",
   3266       MHD_HTTP_CONFLICT),
   3267     TALER_TESTING_cmd_batch ("pay",
   3268                              pay),
   3269     TALER_TESTING_cmd_batch ("double-spending",
   3270                              double_spending),
   3271     TALER_TESTING_cmd_batch ("pay-again",
   3272                              pay_again),
   3273     TALER_TESTING_cmd_batch ("pay-abort",
   3274                              pay_abort),
   3275     TALER_TESTING_cmd_batch ("refund",
   3276                              refund),
   3277     TALER_TESTING_cmd_batch ("templates",
   3278                              templates),
   3279     TALER_TESTING_cmd_batch ("webhooks",
   3280                              webhooks),
   3281     TALER_TESTING_cmd_batch ("inventory-webhooks",
   3282                              inventory_webhooks),
   3283     TALER_TESTING_cmd_batch ("auth",
   3284                              auth),
   3285     TALER_TESTING_cmd_batch ("repurchase",
   3286                              repurchase),
   3287     TALER_TESTING_cmd_batch ("tokens",
   3288                              tokens),
   3289     TALER_TESTING_cmd_batch ("donau",
   3290                              donau),
   3291     TALER_TESTING_cmd_merchant_get_statisticsamount ("stats-refund",
   3292                                                      merchant_url,
   3293                                                      "refunds-granted",
   3294                                                      6,
   3295                                                      0,
   3296                                                      MHD_HTTP_OK),
   3297     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-issued",
   3298                                                       merchant_url,
   3299                                                       "tokens-issued",
   3300                                                       6,
   3301                                                       1,
   3302                                                       MHD_HTTP_OK),
   3303     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-used",
   3304                                                       merchant_url,
   3305                                                       "tokens-used",
   3306                                                       6,
   3307                                                       1,
   3308                                                       MHD_HTTP_OK),
   3309 
   3310     /**
   3311      * End the suite.
   3312      */
   3313     TALER_TESTING_cmd_end ()
   3314   };
   3315 
   3316   TALER_TESTING_run (is,
   3317                      commands);
   3318 }
   3319 
   3320 
   3321 int
   3322 main (int argc,
   3323       char *const *argv)
   3324 {
   3325   {
   3326     char *cipher;
   3327 
   3328     cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
   3329     GNUNET_assert (NULL != cipher);
   3330     GNUNET_asprintf (&config_file,
   3331                      "test_merchant_api-%s.conf",
   3332                      cipher);
   3333     GNUNET_free (cipher);
   3334   }
   3335   payer_payto.full_payto =
   3336     (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME
   3337     "?receiver-name=" USER_ACCOUNT_NAME;
   3338   exchange_payto.full_payto =
   3339     (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
   3340     "?receiver-name="
   3341     EXCHANGE_ACCOUNT_NAME;
   3342   merchant_payto.full_payto =
   3343     (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
   3344     "?receiver-name=" MERCHANT_ACCOUNT_NAME;
   3345   merchant_url = "http://localhost:8080/";
   3346   GNUNET_asprintf (&merchant_url_i1a,
   3347                    "%sinstances/i1a/",
   3348                    merchant_url);
   3349   return TALER_TESTING_main (argv,
   3350                              "INFO",
   3351                              config_file,
   3352                              "exchange-account-exchange",
   3353                              TALER_TESTING_BS_FAKEBANK,
   3354                              &cred,
   3355                              &run,
   3356                              NULL);
   3357 }
   3358 
   3359 
   3360 /* end of test_merchant_api.c */