LCOV - code coverage report
Current view: top level - testing - test_merchant_api.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 437 437
Test Date: 2025-11-13 17:46:01 Functions: 100.0 % 5 5

            Line data    Source code
       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 "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_merchant_testing_lib.h"
      40              : 
      41              : #ifdef HAVE_DONAU_DONAU_SERVICE_H
      42              : #include <donau/donau_testing_lib.h>
      43              : #endif
      44              : 
      45              : 
      46              : /**
      47              :  * The 'poll-orders-conclude-1' and other 'conclude'
      48              :  * commands should NOT wait for this timeout!
      49              :  */
      50              : #define POLL_ORDER_TIMEOUT \
      51              :         GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
      52              : 
      53              : /**
      54              :  * The 'poll-orders-conclude-1x' and other 'conclude'
      55              :  * commands that should (!) wait for this timeout! Hence,
      56              :  * here we use a short value!
      57              :  */
      58              : #define POLL_ORDER_SHORT_TIMEOUT \
      59              :         GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
      60              : 
      61              : /**
      62              :  * Configuration file we use.  One (big) configuration is used
      63              :  * for the various components for this test.
      64              :  */
      65              : static char *config_file;
      66              : 
      67              : /**
      68              :  * Exchange base URL.  Could also be taken from config.
      69              :  */
      70              : #define EXCHANGE_URL "http://localhost:8081/"
      71              : 
      72              : /**
      73              :  * Payto URI of the customer (payer).
      74              :  */
      75              : static struct TALER_FullPayto payer_payto;
      76              : 
      77              : /**
      78              :  * Payto URI of the exchange (escrow account).
      79              :  */
      80              : static struct TALER_FullPayto exchange_payto;
      81              : 
      82              : /**
      83              :  * Payto URI of the merchant (receiver).
      84              :  */
      85              : static struct TALER_FullPayto merchant_payto;
      86              : 
      87              : /**
      88              :  * Credentials for the test.
      89              :  */
      90              : static struct TALER_TESTING_Credentials cred;
      91              : 
      92              : /**
      93              :  * Merchant base URL.
      94              :  */
      95              : static const char *merchant_url;
      96              : 
      97              : /**
      98              :  * Merchant instance "i1a" base URL.
      99              :  */
     100              : static char *merchant_url_i1a;
     101              : 
     102              : /**
     103              :  * Account number of the exchange at the bank.
     104              :  */
     105              : #define EXCHANGE_ACCOUNT_NAME "2"
     106              : 
     107              : /**
     108              :  * Account number of some user.
     109              :  */
     110              : #define USER_ACCOUNT_NAME "62"
     111              : 
     112              : /**
     113              :  * Account number of some other user.
     114              :  */
     115              : #define USER_ACCOUNT_NAME2 "63"
     116              : 
     117              : /**
     118              :  * Account number used by the merchant
     119              :  */
     120              : #define MERCHANT_ACCOUNT_NAME "3"
     121              : 
     122              : static const char *order_1_transfers[] = {
     123              :   "post-transfer-1",
     124              :   NULL
     125              : };
     126              : 
     127              : static const char *order_1_forgets_1[] = {
     128              :   "forget-1",
     129              :   NULL
     130              : };
     131              : 
     132              : static const char *order_1_forgets_2[] = {
     133              :   "forget-1",
     134              :   "forget-order-array-elem",
     135              :   NULL
     136              : };
     137              : 
     138              : static const char *order_1_forgets_3[] = {
     139              :   "forget-1",
     140              :   "forget-order-array-elem",
     141              :   "forget-order-array-wc",
     142              :   NULL
     143              : };
     144              : 
     145              : /**
     146              :  * Execute the taler-merchant-webhook command with
     147              :  * our configuration file.
     148              :  *
     149              :  * @param label label to use for the command.
     150              :  */
     151              : static struct TALER_TESTING_Command
     152            2 : cmd_webhook (const char *label)
     153              : {
     154            2 :   return TALER_TESTING_cmd_webhook (label, config_file);
     155              : }
     156              : 
     157              : 
     158              : /**
     159              :  * Execute the taler-exchange-wirewatch command with
     160              :  * our configuration file.
     161              :  *
     162              :  * @param label label to use for the command.
     163              :  */
     164              : static struct TALER_TESTING_Command
     165           16 : cmd_exec_wirewatch (const char *label)
     166              : {
     167           16 :   return TALER_TESTING_cmd_exec_wirewatch (label,
     168              :                                            config_file);
     169              : }
     170              : 
     171              : 
     172              : /**
     173              :  * Execute the taler-exchange-aggregator, closer and transfer commands with
     174              :  * our configuration file.
     175              :  *
     176              :  * @param label label to use for the command.
     177              :  */
     178              : #define CMD_EXEC_AGGREGATOR(label) \
     179              :         TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
     180              :         TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
     181              : 
     182              : 
     183              : /**
     184              :  * Run wire transfer of funds from some user's account to the
     185              :  * exchange.
     186              :  *
     187              :  * @param label label to use for the command.
     188              :  * @param amount amount to transfer, i.e. "EUR:1"
     189              :  * @param url exchange_url
     190              :  */
     191              : static struct TALER_TESTING_Command
     192           16 : cmd_transfer_to_exchange (const char *label,
     193              :                           const char *amount)
     194              : {
     195           16 :   return TALER_TESTING_cmd_admin_add_incoming (label,
     196              :                                                amount,
     197              :                                                &cred.ba,
     198              :                                                payer_payto);
     199              : }
     200              : 
     201              : 
     202              : /**
     203              :  * Main function that will tell the interpreter what commands to
     204              :  * run.
     205              :  *
     206              :  * @param cls closure
     207              :  */
     208              : static void
     209            2 : run (void *cls,
     210              :      struct TALER_TESTING_Interpreter *is)
     211              : {
     212              :   struct TALER_TESTING_Command get_private_order_id[] = {
     213            2 :     TALER_TESTING_cmd_merchant_post_instances (
     214              :       "instance-create-admin",
     215              :       merchant_url,
     216              :       "admin",
     217              :       MHD_HTTP_NO_CONTENT),
     218            2 :     TALER_TESTING_cmd_merchant_post_account (
     219              :       "instance-create-default-account",
     220              :       merchant_url,
     221              :       merchant_payto,
     222              :       NULL, NULL,
     223              :       MHD_HTTP_OK),
     224            2 :     TALER_TESTING_cmd_merchant_kyc_get (
     225              :       "instance-create-kyc-0",
     226              :       merchant_url,
     227              :       NULL,
     228              :       NULL,
     229              :       EXCHANGE_URL,
     230              :       TALER_EXCHANGE_KLPT_NONE,
     231              :       MHD_HTTP_NO_CONTENT,
     232              :       false),
     233            2 :     TALER_TESTING_cmd_merchant_post_orders_no_claim (
     234              :       "create-proposal-bad-currency",
     235              :       merchant_url,
     236              :       MHD_HTTP_CONFLICT,
     237              :       "4",
     238            2 :       GNUNET_TIME_UNIT_ZERO_TS,
     239            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     240              :       "XXX:5.0"),
     241            2 :     TALER_TESTING_cmd_merchant_post_orders_no_claim (
     242              :       "create-proposal-4",
     243              :       merchant_url,
     244              :       MHD_HTTP_OK,
     245              :       "4",
     246            2 :       GNUNET_TIME_UNIT_ZERO_TS,
     247            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     248              :       "EUR:5.0"),
     249            2 :     TALER_TESTING_cmd_merchant_get_order (
     250              :       "get-order-4",
     251              :       merchant_url,
     252              :       "create-proposal-4",
     253              :       TALER_MERCHANT_OSC_UNPAID,
     254              :       false,
     255              :       MHD_HTTP_OK,
     256              :       NULL),
     257            2 :     TALER_TESTING_cmd_merchant_delete_order (
     258              :       "delete-order-4",
     259              :       merchant_url,
     260              :       "4",
     261              :       MHD_HTTP_NO_CONTENT),
     262            2 :     TALER_TESTING_cmd_merchant_purge_instance (
     263              :       "purge-admin",
     264              :       merchant_url,
     265              :       "admin",
     266              :       MHD_HTTP_NO_CONTENT),
     267            2 :     TALER_TESTING_cmd_end ()
     268              :   };
     269              : 
     270              :   struct TALER_TESTING_Command pay[] = {
     271              :     /**
     272              :      * Move money to the exchange's bank account.
     273              :      */
     274            2 :     cmd_transfer_to_exchange ("create-reserve-1",
     275              :                               "EUR:10.02"),
     276              :     /**
     277              :      * Make a reserve exist, according to the previous transfer.
     278              :      */
     279            2 :     cmd_exec_wirewatch ("wirewatch-1"),
     280            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2",
     281              :                                                  "EUR:10.02",
     282              :                                                  payer_payto,
     283              :                                                  exchange_payto,
     284              :                                                  "create-reserve-1"),
     285            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
     286              :                                        "create-reserve-1",
     287              :                                        "EUR:5",
     288              :                                        0,
     289              :                                        MHD_HTTP_OK),
     290            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
     291              :                                        "create-reserve-1",
     292              :                                        "EUR:5",
     293              :                                        0,
     294              :                                        MHD_HTTP_OK),
     295            2 :     TALER_TESTING_cmd_merchant_get_orders ("get-orders-empty",
     296              :                                            merchant_url,
     297              :                                            MHD_HTTP_OK,
     298              :                                            NULL),
     299              :     /**
     300              :      * Check the reserve is depleted.
     301              :      */
     302            2 :     TALER_TESTING_cmd_status ("withdraw-status-1",
     303              :                               "create-reserve-1",
     304              :                               "EUR:0",
     305              :                               MHD_HTTP_OK),
     306            2 :     TALER_TESTING_cmd_merchant_delete_order ("delete-order-nx",
     307              :                                              merchant_url,
     308              :                                              "1",
     309              :                                              MHD_HTTP_NOT_FOUND),
     310            2 :     TALER_TESTING_cmd_poll_orders_start ("poll-orders-1-start",
     311              :                                          merchant_url,
     312              :                                          POLL_ORDER_TIMEOUT),
     313            2 :     TALER_TESTING_cmd_merchant_claim_order ("claim-order-nx",
     314              :                                             merchant_url,
     315              :                                             MHD_HTTP_NOT_FOUND,
     316              :                                             NULL,
     317              :                                             "1"),
     318            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1",
     319            2 :                                              cred.cfg,
     320              :                                              merchant_url,
     321              :                                              MHD_HTTP_OK,
     322              :                                              "1",
     323            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     324            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     325              :                                              true,
     326              :                                              "EUR:5.0",
     327              :                                              "x-taler-bank",
     328              :                                              "",
     329              :                                              "",
     330              :                                              NULL),
     331            2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-pay-w1",
     332              :                                               merchant_url,
     333              :                                               "webhook-pay-1",
     334              :                                               "pay",
     335              :                                               MHD_HTTP_NO_CONTENT),
     336            2 :     TALER_TESTING_cmd_testserver ("launch-http-server-for-webhooks",
     337              :                                   12345),
     338            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1-idem",
     339            2 :                                              cred.cfg,
     340              :                                              merchant_url,
     341              :                                              MHD_HTTP_OK,
     342              :                                              "1",
     343            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     344            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     345              :                                              true,
     346              :                                              "EUR:5.0",
     347              :                                              "x-taler-bank",
     348              :                                              "",
     349              :                                              "",
     350              :                                              "create-proposal-1"),
     351            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1x",
     352            2 :                                              cred.cfg,
     353              :                                              merchant_url,
     354              :                                              MHD_HTTP_OK,
     355              :                                              "1x",
     356            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     357            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     358              :                                              true,
     359              :                                              "EUR:5.0",
     360              :                                              "x-taler-bank",
     361              :                                              "",
     362              :                                              "",
     363              :                                              NULL),
     364            2 :     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1",
     365              :                                             merchant_url,
     366              :                                             MHD_HTTP_OK,
     367              :                                             "create-proposal-1",
     368              :                                             NULL),
     369            2 :     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1-bad-nonce",
     370              :                                             merchant_url,
     371              :                                             MHD_HTTP_CONFLICT,
     372              :                                             NULL,
     373              :                                             "1"),
     374            2 :     TALER_TESTING_cmd_merchant_claim_order ("reclaim-1x",
     375              :                                             merchant_url,
     376              :                                             MHD_HTTP_OK,
     377              :                                             "create-proposal-1x",
     378              :                                             NULL),
     379            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1-pre-exists",
     380            2 :                                             cred.cfg,
     381              :                                             merchant_url,
     382              :                                             MHD_HTTP_CONFLICT,
     383              :                                             "1",
     384            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     385            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     386              :                                             "EUR:5.0"),
     387            2 :     TALER_TESTING_cmd_poll_orders_conclude ("poll-orders-1-conclude",
     388              :                                             MHD_HTTP_OK,
     389              :                                             "poll-orders-1-start"),
     390            2 :     TALER_TESTING_cmd_merchant_get_orders ("get-orders-1",
     391              :                                            merchant_url,
     392              :                                            MHD_HTTP_OK,
     393              :                                            "create-proposal-1x",
     394              :                                            "create-proposal-1",
     395              :                                            NULL),
     396            2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1",
     397              :                                         merchant_url,
     398              :                                         "create-proposal-1",
     399              :                                         false,
     400              :                                         false,
     401              :                                         false,
     402              :                                         MHD_HTTP_PAYMENT_REQUIRED),
     403            2 :     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1",
     404              :                                           merchant_url,
     405              :                                           "create-proposal-1",
     406              :                                           TALER_MERCHANT_OSC_CLAIMED,
     407              :                                           false,
     408              :                                           MHD_HTTP_OK,
     409              :                                           NULL),
     410            2 :     TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-start-1",
     411              :                                                merchant_url,
     412              :                                                "create-proposal-1",
     413              :                                                POLL_ORDER_TIMEOUT,
     414              :                                                NULL),
     415            2 :     TALER_TESTING_cmd_wallet_poll_order_start2 ("poll-order-wallet-start-1x",
     416              :                                                 merchant_url,
     417              :                                                 "create-proposal-1x",
     418              :                                                 POLL_ORDER_SHORT_TIMEOUT,
     419              :                                                 NULL, /* no refund */
     420              :                                                 "session-0"),
     421            2 :     TALER_TESTING_cmd_poll_order_start ("poll-order-merchant-1-start",
     422              :                                         merchant_url,
     423              :                                         "1",
     424              :                                         POLL_ORDER_TIMEOUT),
     425            2 :     TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
     426              :                                           merchant_url,
     427              :                                           MHD_HTTP_OK,
     428              :                                           "create-proposal-1",
     429              :                                           "withdraw-coin-1",
     430              :                                           "EUR:5",
     431              :                                           "EUR:4.99",
     432              :                                           "session-0"),
     433            2 :     TALER_TESTING_cmd_poll_order_conclude ("poll-order-merchant-1-conclude",
     434              :                                            MHD_HTTP_OK,
     435              :                                            "poll-order-merchant-1-start"),
     436            2 :     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude",
     437              :                                                   MHD_HTTP_OK,
     438              :                                                   NULL,
     439              :                                                   "poll-order-wallet-start-1"),
     440              :     /* Check for webhook */
     441            2 :     cmd_webhook ("pending-webhooks-pay-w1"),
     442              :     /* Check webhook did anything: have a command that inspects traits of the testserver
     443              :        and check if the traits have the right values set! */
     444            2 :     TALER_TESTING_cmd_checkserver ("check-http-server-for-webhooks",
     445              :                                    "launch-http-server-for-webhooks",
     446              :                                    0),
     447              :     /* Here we expect to run into a timeout, as we do not pay this one */
     448            2 :     TALER_TESTING_cmd_wallet_poll_order_conclude2 ("poll-order-1x-conclude",
     449              :                                                    MHD_HTTP_PAYMENT_REQUIRED,
     450              :                                                    NULL,
     451              :                                                    "poll-order-wallet-start-1x",
     452              :                                                    "1"),
     453            2 :     TALER_TESTING_cmd_merchant_post_orders_paid ("verify-order-1-paid",
     454              :                                                  merchant_url,
     455              :                                                  "deposit-simple",
     456              :                                                  "session-1",
     457              :                                                  MHD_HTTP_OK),
     458            2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1-2",
     459              :                                         merchant_url,
     460              :                                         "create-proposal-1",
     461              :                                         true,
     462              :                                         false,
     463              :                                         false,
     464              :                                         MHD_HTTP_OK),
     465            2 :     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1-2a",
     466              :                                           merchant_url,
     467              :                                           "create-proposal-1",
     468              :                                           TALER_MERCHANT_OSC_PAID,
     469              :                                           false,
     470              :                                           MHD_HTTP_OK,
     471              :                                           NULL),
     472            2 :     TALER_TESTING_cmd_merchant_get_orders ("get-orders-1-paid",
     473              :                                            merchant_url,
     474              :                                            MHD_HTTP_OK,
     475              :                                            "create-proposal-1x",
     476              :                                            "create-proposal-1",
     477              :                                            NULL),
     478            2 :     TALER_TESTING_cmd_merchant_pay_order ("replay-simple",
     479              :                                           merchant_url,
     480              :                                           MHD_HTTP_OK,
     481              :                                           "create-proposal-1",
     482              :                                           "withdraw-coin-1",
     483              :                                           "EUR:5",
     484              :                                           "EUR:4.99",
     485              :                                           "session-0"),
     486            2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"),
     487            2 :     TALER_TESTING_cmd_sleep (
     488              :       "Wait for wire transfer deadline",
     489              :       3),
     490            2 :     CMD_EXEC_AGGREGATOR ("run-aggregator"),
     491            2 :     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-498c",
     492              :                                            EXCHANGE_URL,
     493              :                                            "EUR:4.98",
     494              :                                            exchange_payto,
     495              :                                            merchant_payto),
     496            2 :     TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1",
     497              :                                               &cred.ba,
     498              :                                               merchant_payto,
     499              :                                               merchant_url,
     500              :                                               "EUR:4.98",
     501              :                                               MHD_HTTP_NO_CONTENT,
     502              :                                               "deposit-simple",
     503              :                                               NULL),
     504            2 :     TALER_TESTING_cmd_depositcheck ("run taler-merchant-depositcheck-1",
     505              :                                     config_file),
     506            2 :     TALER_TESTING_cmd_run_tme ("run taler-merchant-reconciliation-1",
     507              :                                config_file),
     508            2 :     TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad",
     509              :                                                merchant_url,
     510              :                                                merchant_payto,
     511              :                                                "EUR:4.98",
     512              :                                                NULL,
     513              :                                                /*non-routable IP address
     514              :                                                so we are sure to not get
     515              :                                                any reply*/
     516              :                                                "http://192.0.2.1/404/",
     517              :                                                MHD_HTTP_NO_CONTENT),
     518            2 :     TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1",
     519              :                                               merchant_url,
     520              :                                               merchant_payto,
     521              :                                               MHD_HTTP_OK,
     522              :                                               "post-transfer-1",
     523              :                                               "post-transfer-bad",
     524              :                                               NULL),
     525            2 :     TALER_TESTING_cmd_merchant_delete_transfer ("delete-transfer-1",
     526              :                                                 merchant_url,
     527              :                                                 "post-transfer-bad",
     528              :                                                 MHD_HTTP_NO_CONTENT),
     529            2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2b",
     530              :                                            merchant_url,
     531              :                                            "create-proposal-1",
     532              :                                            TALER_MERCHANT_OSC_PAID,
     533              :                                            true,
     534              :                                            order_1_transfers, /* "post-transfer-1" */
     535              :                                            false,
     536              :                                            NULL,
     537              :                                            NULL,
     538              :                                            MHD_HTTP_OK),
     539            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-1",
     540              :                                              merchant_url,
     541              :                                              MHD_HTTP_NO_CONTENT,
     542              :                                              "create-proposal-1",
     543              :                                              NULL,
     544              :                                              "$.dummy_obj",
     545              :                                              NULL),
     546            2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-1",
     547              :                                            merchant_url,
     548              :                                            "create-proposal-1",
     549              :                                            TALER_MERCHANT_OSC_PAID,
     550              :                                            true,
     551              :                                            order_1_transfers,
     552              :                                            false,
     553              :                                            NULL,
     554              :                                            order_1_forgets_1,
     555              :                                            MHD_HTTP_OK),
     556            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-unforgettable",
     557              :                                              merchant_url,
     558              :                                              MHD_HTTP_CONFLICT,
     559              :                                              "create-proposal-1",
     560              :                                              NULL,
     561              :                                              "$.amount",
     562              :                                              NULL),
     563            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-nx",
     564              :                                              merchant_url,
     565              :                                              MHD_HTTP_NOT_FOUND,
     566              :                                              NULL,
     567              :                                              "nx-order",
     568              :                                              "$.dummy_obj",
     569              :                                              NULL),
     570            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-elem",
     571              :                                              merchant_url,
     572              :                                              MHD_HTTP_NO_CONTENT,
     573              :                                              "create-proposal-1",
     574              :                                              NULL,
     575              :                                              "$.dummy_array[0].item",
     576              :                                              NULL),
     577            2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-2",
     578              :                                            merchant_url,
     579              :                                            "create-proposal-1",
     580              :                                            TALER_MERCHANT_OSC_PAID,
     581              :                                            true,
     582              :                                            order_1_transfers,
     583              :                                            false,
     584              :                                            NULL,
     585              :                                            order_1_forgets_2,
     586              :                                            MHD_HTTP_OK),
     587            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-wc",
     588              :                                              merchant_url,
     589              :                                              MHD_HTTP_NO_CONTENT,
     590              :                                              "create-proposal-1",
     591              :                                              NULL,
     592              :                                              "$.dummy_array[*].item",
     593              :                                              NULL),
     594            2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-3",
     595              :                                            merchant_url,
     596              :                                            "create-proposal-1",
     597              :                                            TALER_MERCHANT_OSC_PAID,
     598              :                                            true,
     599              :                                            order_1_transfers,
     600              :                                            false,
     601              :                                            NULL,
     602              :                                            order_1_forgets_3,
     603              :                                            MHD_HTTP_OK),
     604            2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-malformed",
     605              :                                              merchant_url,
     606              :                                              MHD_HTTP_BAD_REQUEST,
     607              :                                              "create-proposal-1",
     608              :                                              NULL,
     609              :                                              "$.dummy_array[abc].item",
     610              :                                              NULL),
     611            2 :     TALER_TESTING_cmd_merchant_post_products ("post-products-p3",
     612              :                                               merchant_url,
     613              :                                               "product-3",
     614              :                                               "a product",
     615              :                                               "EUR:1",
     616              :                                               MHD_HTTP_NO_CONTENT),
     617            2 :     TALER_TESTING_cmd_merchant_post_products2 ("post-products-p4",
     618              :                                                merchant_url,
     619              :                                                "product-4age",
     620              :                                                "an age-restricted product",
     621              :                                                NULL,
     622              :                                                "unit",
     623              :                                                "EUR:1",
     624              :                                                "", /* image */
     625              :                                                NULL,
     626              :                                                4,
     627              :                                                16 /* minimum age */,
     628              :                                                NULL,
     629            2 :                                                GNUNET_TIME_UNIT_FOREVER_TS,
     630              :                                                MHD_HTTP_NO_CONTENT),
     631            2 :     TALER_TESTING_cmd_merchant_patch_product ("patch-products-p3",
     632              :                                               merchant_url,
     633              :                                               "product-3",
     634              :                                               "a product",
     635              :                                               json_object (),
     636              :                                               "can",
     637              :                                               "EUR:1",
     638              :                                               "data:image/jpeg;base64,RAWDATA",
     639              :                                               json_array (),
     640              :                                               5,
     641              :                                               0,
     642              :                                               json_object (),
     643              :                                               GNUNET_TIME_relative_to_timestamp
     644              :                                               (
     645              :                                                 GNUNET_TIME_UNIT_MINUTES),
     646              :                                               MHD_HTTP_NO_CONTENT),
     647            2 :     TALER_TESTING_cmd_merchant_lock_product ("lock-product-p3",
     648              :                                              merchant_url,
     649              :                                              "product-3",
     650              :                                              GNUNET_TIME_UNIT_MINUTES,
     651              :                                              2,
     652              :                                              MHD_HTTP_NO_CONTENT),
     653            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-wm-nx",
     654            2 :                                              cred.cfg,
     655              :                                              merchant_url,
     656              :                                              MHD_HTTP_NOT_FOUND,
     657              :                                              "order-p3",
     658            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     659            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     660              :                                              true,
     661              :                                              "EUR:5.0",
     662              :                                              "unsupported-wire-method",
     663              :                                              "product-3/2",
     664              :                                              "", /* locks */
     665              :                                              NULL),
     666            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx",
     667            2 :                                              cred.cfg,
     668              :                                              merchant_url,
     669              :                                              MHD_HTTP_NOT_FOUND,
     670              :                                              "order-p3",
     671            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     672            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     673              :                                              true,
     674              :                                              "EUR:5.0",
     675              :                                              "x-taler-bank",
     676              :                                              "unknown-product/2",
     677              :                                              "",
     678              :                                              NULL),
     679            2 :     TALER_TESTING_cmd_merchant_post_orders2 (
     680              :       "create-proposal-p3-not-enough-stock",
     681            2 :       cred.cfg,
     682              :       merchant_url,
     683              :       MHD_HTTP_GONE,
     684              :       "order-p3",
     685            2 :       GNUNET_TIME_UNIT_ZERO_TS,
     686            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     687              :       true,
     688              :       "EUR:5.0",
     689              :       "x-taler-bank",
     690              :       "product-3/24",
     691              :       "",
     692              :       NULL),
     693            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3",
     694            2 :                                              cred.cfg,
     695              :                                              merchant_url,
     696              :                                              MHD_HTTP_OK,
     697              :                                              "order-p3",
     698            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     699            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     700              :                                              false,
     701              :                                              "EUR:5.0",
     702              :                                              "x-taler-bank",
     703              :                                              "product-3/3",
     704              :                                              "lock-product-p3",
     705              :                                              NULL),
     706            2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p4-age",
     707            2 :                                              cred.cfg,
     708              :                                              merchant_url,
     709              :                                              MHD_HTTP_OK,
     710              :                                              "order-p4-age",
     711            2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     712            2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     713              :                                              false,
     714              :                                              "EUR:5.0",
     715              :                                              "x-taler-bank",
     716              :                                              "product-4age",
     717              :                                              "", /* locks */
     718              :                                              NULL),
     719            2 :     TALER_TESTING_cmd_merchant_get_order4 ("get-order-merchant-p4-age",
     720              :                                            merchant_url,
     721              :                                            "create-proposal-p4-age",
     722              :                                            TALER_MERCHANT_OSC_CLAIMED,
     723              :                                            16,
     724              :                                            MHD_HTTP_OK),
     725            2 :     TALER_TESTING_cmd_merchant_delete_order ("delete-order-paid",
     726              :                                              merchant_url,
     727              :                                              "1",
     728              :                                              MHD_HTTP_CONFLICT),
     729            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-no-id",
     730            2 :                                             cred.cfg,
     731              :                                             merchant_url,
     732              :                                             MHD_HTTP_OK,
     733              :                                             NULL,
     734            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     735            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     736              :                                             "EUR:5.0"),
     737            2 :     TALER_TESTING_cmd_merchant_delete_webhook ("post-webhooks-pay-w1",
     738              :                                                merchant_url,
     739              :                                                "webhook-pay-1",
     740              :                                                MHD_HTTP_NO_CONTENT),
     741            2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
     742            2 :     TALER_TESTING_cmd_end ()
     743              :   };
     744              :   struct TALER_TESTING_Command double_spending[] = {
     745            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
     746            2 :                                             cred.cfg,
     747              :                                             merchant_url,
     748              :                                             MHD_HTTP_OK,
     749              :                                             "2",
     750            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     751            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     752              :                                             "EUR:5.0"),
     753            2 :     TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
     754              :                                             merchant_url,
     755              :                                             MHD_HTTP_OK,
     756              :                                             "create-proposal-2",
     757              :                                             NULL),
     758            2 :     TALER_TESTING_cmd_merchant_pay_order ("deposit-double-2",
     759              :                                           merchant_url,
     760              :                                           MHD_HTTP_CONFLICT,
     761              :                                           "create-proposal-2",
     762              :                                           "withdraw-coin-1",
     763              :                                           "EUR:5",
     764              :                                           "EUR:4.99",
     765              :                                           NULL),
     766            2 :     TALER_TESTING_cmd_end ()
     767              :   };
     768              : 
     769            2 :   const char *order_1r_refunds[] = {
     770              :     "refund-increase-1r",
     771              :     "refund-increase-1r-2",
     772              :     NULL
     773              :   };
     774              :   struct TALER_TESTING_Command refund[] = {
     775            2 :     cmd_transfer_to_exchange ("create-reserve-1r",
     776              :                               "EUR:10.02"),
     777              :     /**
     778              :      * Make a reserve exist, according to the previous transfer.
     779              :      */
     780            2 :     cmd_exec_wirewatch ("wirewatch-1r"),
     781            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2r",
     782              :                                                  "EUR:10.02",
     783              :                                                  payer_payto,
     784              :                                                  exchange_payto,
     785              :                                                  "create-reserve-1r"),
     786            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1r",
     787              :                                        "create-reserve-1r",
     788              :                                        "EUR:5",
     789              :                                        0,
     790              :                                        MHD_HTTP_OK),
     791            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2r",
     792              :                                        "create-reserve-1r",
     793              :                                        "EUR:5",
     794              :                                        0,
     795              :                                        MHD_HTTP_OK),
     796              :     /**
     797              :      * Check the reserve is depleted.
     798              :      */
     799            2 :     TALER_TESTING_cmd_status ("withdraw-status-1r",
     800              :                               "create-reserve-1r",
     801              :                               "EUR:0",
     802              :                               MHD_HTTP_OK),
     803            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1r",
     804            2 :                                             cred.cfg,
     805              :                                             merchant_url,
     806              :                                             MHD_HTTP_OK,
     807              :                                             "1r",
     808            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     809            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     810              :                                             "EUR:5.0"),
     811            2 :     TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-refund-1-low",
     812              :                                                merchant_url,
     813              :                                                "create-proposal-1r",
     814              :                                                POLL_ORDER_TIMEOUT,
     815              :                                                "EUR:0.01"),
     816            2 :     TALER_TESTING_cmd_wallet_poll_order_start (
     817              :       "poll-order-wallet-refund-1-high",
     818              :       merchant_url,
     819              :       "create-proposal-1r",
     820              :       POLL_ORDER_TIMEOUT,
     821              :       "EUR:0.2"),
     822            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-for-refund-1r",
     823              :                                           merchant_url,
     824              :                                           MHD_HTTP_OK,
     825              :                                           "create-proposal-1r",
     826              :                                           "withdraw-coin-1r",
     827              :                                           "EUR:5",
     828              :                                           "EUR:4.99",
     829              :                                           NULL),
     830            2 :     TALER_TESTING_cmd_poll_order_start ("poll-payment-refund-1",
     831              :                                         merchant_url,
     832              :                                         "1r", /* proposal name, not cmd ref! */
     833              :                                         POLL_ORDER_TIMEOUT),
     834            2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r",
     835              :                                              merchant_url,
     836              :                                              "refund test",
     837              :                                              "1r", /* order ID */
     838              :                                              "EUR:0.1",
     839              :                                              MHD_HTTP_OK),
     840            2 :     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-low",
     841              :                                                   MHD_HTTP_OK,
     842              :                                                   "EUR:0.1",
     843              :                                                   "poll-order-wallet-refund-1-low"),
     844            2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r",
     845              :                                         merchant_url,
     846              :                                         "create-proposal-1r",
     847              :                                         true,
     848              :                                         true,
     849              :                                         true,
     850              :                                         MHD_HTTP_OK),
     851            2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r-2",
     852              :                                              merchant_url,
     853              :                                              "refund test 2",
     854              :                                              "1r", /* order ID */
     855              :                                              "EUR:1.0",
     856              :                                              MHD_HTTP_OK),
     857            2 :     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-high",
     858              :                                                   MHD_HTTP_OK,
     859              :                                                   "EUR:1.0",
     860              :                                                   "poll-order-wallet-refund-1-high"),
     861            2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-2",
     862              :                                         merchant_url,
     863              :                                         "create-proposal-1r",
     864              :                                         true,
     865              :                                         true,
     866              :                                         true,
     867              :                                         MHD_HTTP_OK),
     868            2 :     TALER_TESTING_cmd_wallet_order_refund ("obtain-refund-1r",
     869              :                                            merchant_url,
     870              :                                            "create-proposal-1r",
     871              :                                            MHD_HTTP_OK,
     872              :                                            "refund-increase-1r",
     873              :                                            "refund-increase-1r-2",
     874              :                                            NULL),
     875            2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-3",
     876              :                                         merchant_url,
     877              :                                         "create-proposal-1r",
     878              :                                         true,
     879              :                                         true,
     880              :                                         false,
     881              :                                         MHD_HTTP_OK),
     882            2 :     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1r",
     883              :                                           merchant_url,
     884              :                                           "create-proposal-1r",
     885              :                                           TALER_MERCHANT_OSC_PAID,
     886              :                                           true,
     887              :                                           MHD_HTTP_OK,
     888              :                                           "refund-increase-1r",
     889              :                                           "refund-increase-1r-2",
     890              :                                           NULL),
     891            2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1r-2",
     892              :                                            merchant_url,
     893              :                                            "create-proposal-1r",
     894              :                                            TALER_MERCHANT_OSC_PAID,
     895              :                                            false,
     896              :                                            NULL,
     897              :                                            true,
     898              :                                            order_1r_refunds,
     899              :                                            NULL,
     900              :                                            MHD_HTTP_OK),
     901            2 :     TALER_TESTING_cmd_poll_order_conclude ("poll-payment-refund-conclude-1",
     902              :                                            MHD_HTTP_OK,
     903              :                                            "poll-payment-refund-1"),
     904              : 
     905              :     /* Test /refund on a contract that was never paid.  */
     906            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-not-to-be-paid",
     907            2 :                                             cred.cfg,
     908              :                                             merchant_url,
     909              :                                             MHD_HTTP_OK,
     910              :                                             "1-unpaid",
     911            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     912            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     913              :                                             "EUR:5.0"),
     914              :     /* Try to increase an unpaid proposal.  */
     915            2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-unpaid-proposal",
     916              :                                              merchant_url,
     917              :                                              "refund test",
     918              :                                              "1-unpaid",
     919              :                                              "EUR:0.1",
     920              :                                              MHD_HTTP_CONFLICT),
     921              :     /* Try to increase a non existent proposal.  */
     922            2 :     TALER_TESTING_cmd_merchant_order_refund (
     923              :       "refund-increase-nonexistent-proposal",
     924              :       merchant_url,
     925              :       "refund test",
     926              :       "non-existent-id",
     927              :       "EUR:0.1",
     928              :       MHD_HTTP_NOT_FOUND),
     929              :     /*
     930              :        The following block will (1) create a new
     931              :        reserve, then (2) a proposal, then (3) pay for
     932              :        it, and finally (4) attempt to pick up a refund
     933              :        from it without any increasing taking place
     934              :        in the first place.
     935              :     */
     936            2 :     cmd_transfer_to_exchange ("create-reserve-unincreased-refund",
     937              :                               "EUR:5.01"),
     938            2 :     cmd_exec_wirewatch ("wirewatch-unincreased-refund"),
     939            2 :     TALER_TESTING_cmd_check_bank_admin_transfer (
     940              :       "check_bank_transfer-unincreased-refund",
     941              :       "EUR:5.01",
     942              :       payer_payto,
     943              :       exchange_payto,
     944              :       "create-reserve-unincreased-refund"),
     945            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unincreased-refund",
     946              :                                        "create-reserve-unincreased-refund",
     947              :                                        "EUR:5",
     948              :                                        0,
     949              :                                        MHD_HTTP_OK),
     950            2 :     TALER_TESTING_cmd_merchant_post_orders (
     951              :       "create-proposal-unincreased-refund",
     952            2 :       cred.cfg,
     953              :       merchant_url,
     954              :       MHD_HTTP_OK,
     955              :       "unincreased-proposal",
     956            2 :       GNUNET_TIME_UNIT_ZERO_TS,
     957            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     958              :       "EUR:5.0"),
     959            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-unincreased-proposal",
     960              :                                           merchant_url,
     961              :                                           MHD_HTTP_OK,
     962              :                                           "create-proposal-unincreased-refund",
     963              :                                           "withdraw-coin-unincreased-refund",
     964              :                                           "EUR:5",
     965              :                                           "EUR:4.99",
     966              :                                           NULL),
     967            2 :     TALER_TESTING_cmd_sleep (
     968              :       "Wait for wire transfer deadline",
     969              :       3),
     970            2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-unincreased-refund"),
     971            2 :     TALER_TESTING_cmd_check_bank_transfer (
     972              :       "check_bank_transfer-paid-unincreased-refund",
     973              :       EXCHANGE_URL,
     974              :       "EUR:8.97", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r'
     975              :                      and MINUS 0.1 MINUS 0.9 from
     976              :                      'refund-increase-1r' and 'refund-increase-1r-2' */
     977              :       exchange_payto,
     978              :       merchant_payto),
     979            2 :     TALER_TESTING_cmd_end ()
     980              :   };
     981              : 
     982              :   struct TALER_TESTING_Command auth[] = {
     983            2 :     TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1a",
     984              :                                                merchant_url,
     985              :                                                "i1a",
     986              :                                                MHD_HTTP_NO_CONTENT),
     987            2 :     TALER_TESTING_cmd_merchant_post_account (
     988              :       "instance-create-i1a-account",
     989              :       merchant_url_i1a,
     990              :       merchant_payto,
     991              :       NULL, NULL,
     992              :       MHD_HTTP_OK),
     993            2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1",
     994              :                                             merchant_url_i1a,
     995              :                                             "nx-product",
     996              :                                             MHD_HTTP_NOT_FOUND,
     997              :                                             NULL),
     998            2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-1",
     999              :                                              merchant_url_i1a,
    1000              :                                              MHD_HTTP_OK,
    1001              :                                              NULL),
    1002            2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-2",
    1003              :                                             merchant_url_i1a,
    1004              :                                             "nx-product",
    1005              :                                             MHD_HTTP_NOT_FOUND,
    1006              :                                             NULL),
    1007            2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-2",
    1008              :                                              merchant_url_i1a,
    1009              :                                              MHD_HTTP_OK,
    1010              :                                              NULL),
    1011            2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1012              :       "instance-create-i1a-auth-ok",
    1013              :       merchant_url,
    1014              :       "i1a",
    1015              :       "my-secret",
    1016              :       MHD_HTTP_NO_CONTENT),
    1017            2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-3",
    1018              :                                             merchant_url_i1a,
    1019              :                                             "nx-product",
    1020              :                                             MHD_HTTP_UNAUTHORIZED,
    1021              :                                             NULL),
    1022            2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-3",
    1023              :                                              merchant_url_i1a,
    1024              :                                              MHD_HTTP_UNAUTHORIZED,
    1025              :                                              NULL),
    1026            2 :     TALER_TESTING_cmd_set_authorization ("set-auth-valid",
    1027              :                                          "Basic aTFhOm15LXNlY3JldA=="),
    1028            2 :     TALER_TESTING_cmd_merchant_post_instance_token (
    1029              :       "instance-create-i1a-token-ok",
    1030              :       merchant_url,
    1031              :       "i1a",
    1032              :       "write", /* scope */
    1033              :       GNUNET_TIME_UNIT_DAYS, /* duration */
    1034              :       GNUNET_YES, /* refreshable */
    1035              :       MHD_HTTP_OK),
    1036            2 :     TALER_TESTING_cmd_set_authorization ("unset-auth-valid",
    1037              :                                          NULL), // Unset header
    1038            2 :     TALER_TESTING_cmd_merchant_set_instance_token (
    1039              :       "instance-create-i1a-token-set",
    1040              :       "instance-create-i1a-token-ok"),
    1041            2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-4",
    1042              :                                             merchant_url_i1a,
    1043              :                                             "nx-product",
    1044              :                                             MHD_HTTP_NOT_FOUND,
    1045              :                                             NULL),
    1046            2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-4",
    1047              :                                              merchant_url_i1a,
    1048              :                                              MHD_HTTP_OK,
    1049              :                                              NULL),
    1050            2 :     TALER_TESTING_cmd_merchant_delete_instance_token (
    1051              :       "instance-create-i1a-token-delete",
    1052              :       merchant_url,
    1053              :       "i1a",
    1054              :       MHD_HTTP_NO_CONTENT),
    1055            2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-5",
    1056              :                                             merchant_url_i1a,
    1057              :                                             "nx-product",
    1058              :                                             MHD_HTTP_UNAUTHORIZED,
    1059              :                                             NULL),
    1060            2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-5",
    1061              :                                              merchant_url_i1a,
    1062              :                                              MHD_HTTP_UNAUTHORIZED,
    1063              :                                              NULL),
    1064            2 :     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a-fail",
    1065              :                                                merchant_url_i1a,
    1066              :                                                NULL,
    1067              :                                                MHD_HTTP_UNAUTHORIZED),
    1068            2 :     TALER_TESTING_cmd_set_authorization ("set-token-auth-valid-again",
    1069              :                                          "Basic aTFhOm15LXNlY3JldA=="),
    1070            2 :     TALER_TESTING_cmd_merchant_post_instance_token (
    1071              :       "set-auth-valid-again",
    1072              :       merchant_url,
    1073              :       "i1a",
    1074              :       "write", /* scope */
    1075              :       GNUNET_TIME_UNIT_DAYS, /* duration */
    1076              :       GNUNET_YES, /* refreshable */
    1077              :       MHD_HTTP_OK),
    1078            2 :     TALER_TESTING_cmd_set_authorization ("unset-auth-valid2",
    1079              :                                          NULL), // Unset header
    1080            2 :     TALER_TESTING_cmd_merchant_set_instance_token (
    1081              :       "instance-create-i1a-token-set-again",
    1082              :       "set-auth-valid-again"),
    1083            2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1084              :       "instance-create-i1a-auth-ok-idempotent",
    1085              :       merchant_url_i1a,
    1086              :       NULL,
    1087              :       RFC_8959_PREFIX "my-other-secret",
    1088              :       MHD_HTTP_NO_CONTENT),
    1089            2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1090              :       "instance-create-i1a-clear-auth",
    1091              :       merchant_url_i1a,
    1092              :       NULL,
    1093              :       NULL,
    1094              :       MHD_HTTP_NO_CONTENT),
    1095            2 :     TALER_TESTING_cmd_set_authorization ("set-auth-none",
    1096              :                                          NULL),
    1097            2 :     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a",
    1098              :                                                merchant_url_i1a,
    1099              :                                                NULL,
    1100              :                                                MHD_HTTP_NO_CONTENT),
    1101            2 :     TALER_TESTING_cmd_end ()
    1102              :   };
    1103              : 
    1104              :   struct TALER_TESTING_Command pay_again[] = {
    1105            2 :     cmd_transfer_to_exchange ("create-reserve-20",
    1106              :                               "EUR:20.04"),
    1107            2 :     cmd_exec_wirewatch ("wirewatch-20"),
    1108            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-10",
    1109              :                                                  "EUR:20.04",
    1110              :                                                  payer_payto,
    1111              :                                                  exchange_payto,
    1112              :                                                  "create-reserve-20"),
    1113            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10a",
    1114              :                                        "create-reserve-20",
    1115              :                                        "EUR:5",
    1116              :                                        0,
    1117              :                                        MHD_HTTP_OK),
    1118            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10b",
    1119              :                                        "create-reserve-20",
    1120              :                                        "EUR:5",
    1121              :                                        0,
    1122              :                                        MHD_HTTP_OK),
    1123            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10c",
    1124              :                                        "create-reserve-20",
    1125              :                                        "EUR:5",
    1126              :                                        0,
    1127              :                                        MHD_HTTP_OK),
    1128            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10d",
    1129              :                                        "create-reserve-20",
    1130              :                                        "EUR:5",
    1131              :                                        0,
    1132              :                                        MHD_HTTP_OK),
    1133            2 :     TALER_TESTING_cmd_status ("withdraw-status-20",
    1134              :                               "create-reserve-20",
    1135              :                               "EUR:0",
    1136              :                               MHD_HTTP_OK),
    1137            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10",
    1138            2 :                                             cred.cfg,
    1139              :                                             merchant_url,
    1140              :                                             MHD_HTTP_OK,
    1141              :                                             "10",
    1142            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
    1143            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
    1144              :                                             "EUR:10.0"),
    1145            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-10",
    1146              :                                           merchant_url,
    1147              :                                           MHD_HTTP_CONFLICT,
    1148              :                                           "create-proposal-10",
    1149              :                                           "withdraw-coin-10a;withdraw-coin-1",
    1150              :                                           "EUR:5",
    1151              :                                           "EUR:4.99",
    1152              :                                           NULL),
    1153            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-again-10",
    1154              :                                           merchant_url,
    1155              :                                           MHD_HTTP_OK,
    1156              :                                           "create-proposal-10",
    1157              :                                           "withdraw-coin-10a;withdraw-coin-10b",
    1158              :                                           "EUR:5",
    1159              :                                           "EUR:4.99",
    1160              :                                           NULL),
    1161            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-too-much-10",
    1162              :                                           merchant_url,
    1163              :                                           MHD_HTTP_CONFLICT,
    1164              :                                           "create-proposal-10",
    1165              :                                           "withdraw-coin-10c;withdraw-coin-10d",
    1166              :                                           "EUR:5",
    1167              :                                           "EUR:4.99",
    1168              :                                           NULL),
    1169            2 :     TALER_TESTING_cmd_sleep (
    1170              :       "Wait for wire transfer deadline",
    1171              :       3),
    1172            2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-10"),
    1173            2 :     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-9.97-10",
    1174              :                                            EXCHANGE_URL,
    1175              :                                            "EUR:9.97",
    1176              :                                            exchange_payto,
    1177              :                                            merchant_payto),
    1178            2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"),
    1179            2 :     TALER_TESTING_cmd_end ()
    1180              :   };
    1181              : 
    1182              :   struct TALER_TESTING_Command pay_abort[] = {
    1183            2 :     cmd_transfer_to_exchange ("create-reserve-11",
    1184              :                               "EUR:10.02"),
    1185            2 :     cmd_exec_wirewatch ("wirewatch-11"),
    1186            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-11",
    1187              :                                                  "EUR:10.02",
    1188              :                                                  payer_payto,
    1189              :                                                  exchange_payto,
    1190              :                                                  "create-reserve-11"),
    1191            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11a",
    1192              :                                        "create-reserve-11",
    1193              :                                        "EUR:5",
    1194              :                                        0,
    1195              :                                        MHD_HTTP_OK),
    1196            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11b",
    1197              :                                        "create-reserve-11",
    1198              :                                        "EUR:5",
    1199              :                                        0,
    1200              :                                        MHD_HTTP_OK),
    1201            2 :     TALER_TESTING_cmd_status ("withdraw-status-11",
    1202              :                               "create-reserve-11",
    1203              :                               "EUR:0",
    1204              :                               MHD_HTTP_OK),
    1205            2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-11",
    1206            2 :                                             cred.cfg,
    1207              :                                             merchant_url,
    1208              :                                             MHD_HTTP_OK,
    1209              :                                             "11",
    1210            2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
    1211            2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
    1212              :                                             "EUR:10.0"),
    1213            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-good",
    1214              :                                           merchant_url,
    1215              :                                           MHD_HTTP_BAD_REQUEST,
    1216              :                                           "create-proposal-11",
    1217              :                                           "withdraw-coin-11a",
    1218              :                                           "EUR:5",
    1219              :                                           "EUR:4.99",
    1220              :                                           NULL),
    1221            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-bad",
    1222              :                                           merchant_url,
    1223              :                                           MHD_HTTP_CONFLICT,
    1224              :                                           "create-proposal-11",
    1225              :                                           "withdraw-coin-1",
    1226              :                                           "EUR:5",
    1227              :                                           "EUR:4.99",
    1228              :                                           NULL),
    1229            2 :     TALER_TESTING_cmd_merchant_order_abort ("pay-abort-11",
    1230              :                                             merchant_url,
    1231              :                                             "pay-fail-partial-double-11-good",
    1232              :                                             MHD_HTTP_OK),
    1233            2 :     TALER_TESTING_cmd_sleep (
    1234              :       "Wait for wire transfer deadline",
    1235              :       3),
    1236            2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-11"),
    1237            2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-11"),
    1238            2 :     TALER_TESTING_cmd_end ()
    1239              :   };
    1240              : 
    1241              :   struct TALER_TESTING_Command templates[] = {
    1242            2 :     cmd_transfer_to_exchange ("create-reserve-20x",
    1243              :                               "EUR:20.04"),
    1244            2 :     cmd_exec_wirewatch ("wirewatch-20x"),
    1245            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-20x",
    1246              :                                                  "EUR:20.04",
    1247              :                                                  payer_payto,
    1248              :                                                  exchange_payto,
    1249              :                                                  "create-reserve-20x"),
    1250            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xa",
    1251              :                                        "create-reserve-20x",
    1252              :                                        "EUR:5",
    1253              :                                        0,
    1254              :                                        MHD_HTTP_OK),
    1255            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xb",
    1256              :                                        "create-reserve-20x",
    1257              :                                        "EUR:5",
    1258              :                                        0,
    1259              :                                        MHD_HTTP_OK),
    1260            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xc",
    1261              :                                        "create-reserve-20x",
    1262              :                                        "EUR:5",
    1263              :                                        0,
    1264              :                                        MHD_HTTP_OK),
    1265            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xd",
    1266              :                                        "create-reserve-20x",
    1267              :                                        "EUR:5",
    1268              :                                        0,
    1269              :                                        MHD_HTTP_OK),
    1270            2 :     TALER_TESTING_cmd_status ("withdraw-status-20x",
    1271              :                               "create-reserve-20x",
    1272              :                               "EUR:0",
    1273              :                               MHD_HTTP_OK),
    1274            2 :     TALER_TESTING_cmd_merchant_get_templates ("get-templates-empty",
    1275              :                                               merchant_url,
    1276              :                                               MHD_HTTP_OK,
    1277              :                                               NULL),
    1278            2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1",
    1279              :                                                merchant_url,
    1280              :                                                "template-1",
    1281              :                                                "a template",
    1282              :                                                MHD_HTTP_NO_CONTENT),
    1283            2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-idem",
    1284              :                                                merchant_url,
    1285              :                                                "template-1",
    1286              :                                                "a template",
    1287              :                                                MHD_HTTP_NO_CONTENT),
    1288            2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-non-idem",
    1289              :                                                merchant_url,
    1290              :                                                "template-1",
    1291              :                                                "a different template",
    1292              :                                                MHD_HTTP_CONFLICT),
    1293            2 :     TALER_TESTING_cmd_merchant_get_templates ("get-templates-t1",
    1294              :                                               merchant_url,
    1295              :                                               MHD_HTTP_OK,
    1296              :                                               "post-templates-t1",
    1297              :                                               NULL),
    1298            2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-t1",
    1299              :                                              merchant_url,
    1300              :                                              "template-1",
    1301              :                                              MHD_HTTP_OK,
    1302              :                                              "post-templates-t1"),
    1303            2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t2",
    1304              :                                                merchant_url,
    1305              :                                                "template-2",
    1306              :                                                "a template",
    1307              :                                                MHD_HTTP_NO_CONTENT),
    1308            2 :     TALER_TESTING_cmd_merchant_patch_template (
    1309              :       "patch-templates-t2",
    1310              :       merchant_url,
    1311              :       "template-2",
    1312              :       "another template",
    1313              :       NULL,
    1314            2 :       GNUNET_JSON_PACK (
    1315              :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1316              :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1317              :                                    GNUNET_TIME_UNIT_MINUTES)),
    1318              :       MHD_HTTP_NO_CONTENT),
    1319            2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-t2",
    1320              :                                              merchant_url,
    1321              :                                              "template-2",
    1322              :                                              MHD_HTTP_OK,
    1323              :                                              "patch-templates-t2"),
    1324            2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-nx",
    1325              :                                              merchant_url,
    1326              :                                              "template-nx",
    1327              :                                              MHD_HTTP_NOT_FOUND,
    1328              :                                              NULL),
    1329            2 :     TALER_TESTING_cmd_merchant_post_otp_devices (
    1330              :       "post-otp-device",
    1331              :       merchant_url,
    1332              :       "otp-dev",
    1333              :       "my OTP device",
    1334              :       "FEE4P2J",
    1335              :       TALER_MCA_WITH_PRICE,
    1336              :       0,
    1337              :       MHD_HTTP_NO_CONTENT),
    1338            2 :     TALER_TESTING_cmd_merchant_patch_template (
    1339              :       "patch-templates-t3-nx",
    1340              :       merchant_url,
    1341              :       "template-3",
    1342              :       "updated template",
    1343              :       "otp-dev",
    1344            2 :       GNUNET_JSON_PACK (
    1345              :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1346              :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1347              :                                    GNUNET_TIME_UNIT_MINUTES)),
    1348              :       MHD_HTTP_NOT_FOUND),
    1349            2 :     TALER_TESTING_cmd_merchant_post_templates2 (
    1350              :       "post-templates-t3-amount",
    1351              :       merchant_url,
    1352              :       "template-amount",
    1353              :       "a different template with an amount",
    1354              :       NULL,
    1355            2 :       GNUNET_JSON_PACK (
    1356              :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1357              :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1358              :                                    GNUNET_TIME_UNIT_MINUTES),
    1359              :         GNUNET_JSON_pack_string ("amount",
    1360              :                                  "EUR:4")),
    1361              :       MHD_HTTP_NO_CONTENT),
    1362            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1363              :       "using-templates-t1",
    1364              :       "post-templates-t1",
    1365              :       NULL,
    1366              :       merchant_url,
    1367              :       "1",
    1368              :       "summary-1",
    1369              :       "EUR:9.98",
    1370            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1371            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1372              :       MHD_HTTP_OK),
    1373            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1374              :       "using-templates-t1-amount-missing",
    1375              :       "post-templates-t1",
    1376              :       NULL,
    1377              :       merchant_url,
    1378              :       "2",
    1379              :       "summary-1",
    1380              :       NULL,
    1381            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1382            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1383              :       MHD_HTTP_CONFLICT),
    1384            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1385              :       "using-templates-t1-summary-missing",
    1386              :       "post-templates-t1",
    1387              :       NULL,
    1388              :       merchant_url,
    1389              :       "3",
    1390              :       NULL,
    1391              :       "EUR:10",
    1392            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1393            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1394              :       MHD_HTTP_CONFLICT),
    1395            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1396              :       "using-templates-t1-amount-conflict",
    1397              :       "post-templates-t3-amount",
    1398              :       NULL,
    1399              :       merchant_url,
    1400              :       "4",
    1401              :       "summary-1",
    1402              :       "EUR:10",
    1403            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1404            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1405              :       MHD_HTTP_CONFLICT),
    1406            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1407              :       "using-templates-t1-amount-duplicate",
    1408              :       "post-templates-t3-amount",
    1409              :       NULL,
    1410              :       merchant_url,
    1411              :       "4",
    1412              :       "summary-1",
    1413              :       "EUR:4",
    1414            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1415            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1416              :       MHD_HTTP_CONFLICT),
    1417            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-100",
    1418              :                                           merchant_url,
    1419              :                                           MHD_HTTP_OK,
    1420              :                                           "using-templates-t1",
    1421              :                                           "withdraw-coin-xa;withdraw-coin-xb",
    1422              :                                           "EUR:4.99",
    1423              :                                           "EUR:4.99",
    1424              :                                           NULL),
    1425            2 :     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
    1426              :                                                 merchant_url,
    1427              :                                                 "t1",
    1428              :                                                 MHD_HTTP_NOT_FOUND),
    1429            2 :     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
    1430              :                                                 merchant_url,
    1431              :                                                 "template-1",
    1432              :                                                 MHD_HTTP_NO_CONTENT),
    1433            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1434              :       "post-templates-t1-deleted",
    1435              :       "post-templates-t1",
    1436              :       NULL,
    1437              :       merchant_url,
    1438              :       "0",
    1439              :       "summary-1",
    1440              :       "EUR:5",
    1441            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1442            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1443              :       MHD_HTTP_NOT_FOUND),
    1444            2 :     TALER_TESTING_cmd_merchant_post_otp_devices (
    1445              :       "post-otp-device",
    1446              :       merchant_url,
    1447              :       "otp-dev-2",
    1448              :       "my OTP device",
    1449              :       "secret",
    1450              :       TALER_MCA_WITH_PRICE,
    1451              :       0,
    1452              :       MHD_HTTP_NO_CONTENT),
    1453            2 :     TALER_TESTING_cmd_merchant_post_templates2 (
    1454              :       "post-templates-with-pos-key",
    1455              :       merchant_url,
    1456              :       "template-key",
    1457              :       "a different template with POS KEY",
    1458              :       "otp-dev-2",
    1459            2 :       GNUNET_JSON_PACK (
    1460              :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1461              :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1462              :                                    GNUNET_TIME_UNIT_MINUTES)),
    1463              :       MHD_HTTP_NO_CONTENT),
    1464              : 
    1465            2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1466              :       "using-templates-pos-key",
    1467              :       "post-templates-with-pos-key",
    1468              :       "post-otp-device",
    1469              :       merchant_url,
    1470              :       "1",
    1471              :       "summary-1-pos",
    1472              :       "EUR:9.98",
    1473            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1474            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1475              :       MHD_HTTP_OK),
    1476            2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-with-pos",
    1477              :                                           merchant_url,
    1478              :                                           MHD_HTTP_OK,
    1479              :                                           "using-templates-pos-key",
    1480              :                                           "withdraw-coin-xc;withdraw-coin-xd",
    1481              :                                           "EUR:4.99",
    1482              :                                           "EUR:4.99",
    1483              :                                           NULL),
    1484              : 
    1485              : 
    1486            2 :     TALER_TESTING_cmd_end ()
    1487              :   };
    1488              : 
    1489              :   struct TALER_TESTING_Command webhooks[] = {
    1490            2 :     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-empty",
    1491              :                                              merchant_url,
    1492              :                                              MHD_HTTP_OK,
    1493              :                                              NULL),
    1494            2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1",
    1495              :                                               merchant_url,
    1496              :                                               "webhook-1",
    1497              :                                               "Paid",
    1498              :                                               MHD_HTTP_NO_CONTENT),
    1499            2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-idem",
    1500              :                                               merchant_url,
    1501              :                                               "webhook-1",
    1502              :                                               "Paid",
    1503              :                                               MHD_HTTP_NO_CONTENT),
    1504            2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-non-idem",
    1505              :                                               merchant_url,
    1506              :                                               "webhook-1",
    1507              :                                               "Refund",
    1508              :                                               MHD_HTTP_CONFLICT),
    1509            2 :     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-w1",
    1510              :                                              merchant_url,
    1511              :                                              MHD_HTTP_OK,
    1512              :                                              "post-webhooks-w1",
    1513              :                                              NULL),
    1514            2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w1",
    1515              :                                             merchant_url,
    1516              :                                             "webhook-1",
    1517              :                                             MHD_HTTP_OK,
    1518              :                                             "post-webhooks-w1"),
    1519            2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w2",
    1520              :                                               merchant_url,
    1521              :                                               "webhook-2",
    1522              :                                               "Paid",
    1523              :                                               MHD_HTTP_NO_CONTENT),
    1524            2 :     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w2",
    1525              :                                               merchant_url,
    1526              :                                               "webhook-2",
    1527              :                                               "Refund2",
    1528              :                                               "http://localhost:38188/",
    1529              :                                               "POST",
    1530              :                                               "Authorization:WHWOXZXPLL",
    1531              :                                               "Amount",
    1532              :                                               MHD_HTTP_NO_CONTENT),
    1533            2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w2",
    1534              :                                             merchant_url,
    1535              :                                             "webhook-2",
    1536              :                                             MHD_HTTP_OK,
    1537              :                                             "patch-webhooks-w2"),
    1538            2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-nx",
    1539              :                                             merchant_url,
    1540              :                                             "webhook-nx",
    1541              :                                             MHD_HTTP_NOT_FOUND,
    1542              :                                             NULL),
    1543            2 :     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w3-nx",
    1544              :                                               merchant_url,
    1545              :                                               "webhook-3",
    1546              :                                               "Paid2",
    1547              :                                               "https://example.com",
    1548              :                                               "POST",
    1549              :                                               "Authorization:WHWOXZXPLL",
    1550              :                                               "Amount",
    1551              :                                               MHD_HTTP_NOT_FOUND),
    1552            2 :     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
    1553              :                                                merchant_url,
    1554              :                                                "w1",
    1555              :                                                MHD_HTTP_NOT_FOUND),
    1556            2 :     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
    1557              :                                                merchant_url,
    1558              :                                                "webhook-1",
    1559              :                                                MHD_HTTP_NO_CONTENT),
    1560            2 :     TALER_TESTING_cmd_end ()
    1561              :   };
    1562              :   struct TALER_TESTING_Command repurchase[] = {
    1563            2 :     cmd_transfer_to_exchange (
    1564              :       "create-reserve-30x",
    1565              :       "EUR:30.06"),
    1566            2 :     cmd_exec_wirewatch (
    1567              :       "wirewatch-30x"),
    1568            2 :     TALER_TESTING_cmd_check_bank_admin_transfer (
    1569              :       "check_bank_transfer-30x",
    1570              :       "EUR:30.06",
    1571              :       payer_payto,
    1572              :       exchange_payto,
    1573              :       "create-reserve-30x"),
    1574            2 :     TALER_TESTING_cmd_withdraw_amount (
    1575              :       "withdraw-coin-rep",
    1576              :       "create-reserve-30x",
    1577              :       "EUR:5",
    1578              :       0,
    1579              :       MHD_HTTP_OK),
    1580            2 :     TALER_TESTING_cmd_merchant_post_orders3 (
    1581              :       "post-order-repurchase-original",
    1582            2 :       cred.cfg,
    1583              :       merchant_url,
    1584              :       MHD_HTTP_OK,
    1585              :       "repurchase-original",
    1586              :       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
    1587            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1588              :       "https://fulfillment.example.com/",
    1589              :       "EUR:1.0"),
    1590            2 :     TALER_TESTING_cmd_merchant_pay_order (
    1591              :       "repurchase-pay-first",
    1592              :       merchant_url,
    1593              :       MHD_HTTP_OK,
    1594              :       "post-order-repurchase-original",
    1595              :       "withdraw-coin-rep",
    1596              :       "EUR:1.00",
    1597              :       "EUR:0.99",
    1598              :       "repurchase-session"),
    1599            2 :     TALER_TESTING_cmd_wallet_get_order (
    1600              :       "repurchase-wallet-check-primary-order",
    1601              :       merchant_url,
    1602              :       "post-order-repurchase-original",
    1603              :       true,
    1604              :       false,
    1605              :       false,
    1606              :       MHD_HTTP_OK),
    1607            2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1608              :       "repurchase-check-primary-payment",
    1609              :       merchant_url,
    1610              :       "post-order-repurchase-original",
    1611              :       TALER_MERCHANT_OSC_PAID,
    1612              :       "repurchase-session",
    1613              :       NULL,
    1614              :       MHD_HTTP_OK),
    1615            2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1616              :       "repurchase-check-primary-payment-bad-binding",
    1617              :       merchant_url,
    1618              :       "post-order-repurchase-original",
    1619              :       TALER_MERCHANT_OSC_CLAIMED, /* someone else has it! */
    1620              :       "wrong-session",
    1621              :       NULL,
    1622              :       MHD_HTTP_OK),
    1623            2 :     TALER_TESTING_cmd_merchant_post_orders3 (
    1624              :       "post-order-repurchase-secondary",
    1625            2 :       cred.cfg,
    1626              :       merchant_url,
    1627              :       MHD_HTTP_OK,
    1628              :       "repurchase-secondary",
    1629              :       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
    1630            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1631              :       "https://fulfillment.example.com/",
    1632              :       "EUR:1.0"),
    1633            2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1634              :       "repurchase-check-secondary-payment",
    1635              :       merchant_url,
    1636              :       "post-order-repurchase-secondary",
    1637              :       TALER_MERCHANT_OSC_UNPAID,
    1638              :       "repurchase-session",
    1639              :       NULL,
    1640              :       MHD_HTTP_OK),
    1641            2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1642              :       "repurchase-check-secondary-payment",
    1643              :       merchant_url,
    1644              :       "post-order-repurchase-secondary",
    1645              :       TALER_MERCHANT_OSC_UNPAID,
    1646              :       "repurchase-session",
    1647              :       "post-order-repurchase-original",
    1648              :       MHD_HTTP_OK),
    1649            2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1650              :       "repurchase-wallet-check-order-secondary",
    1651              :       merchant_url,
    1652              :       "post-order-repurchase-secondary",
    1653              :       "repurchase-session",
    1654              :       false,
    1655              :       false,
    1656              :       false,
    1657              :       "post-order-repurchase-original",
    1658              :       MHD_HTTP_PAYMENT_REQUIRED),
    1659            2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1660              :       "repurchase-wallet-check-order-secondary-bad-session",
    1661              :       merchant_url,
    1662              :       "post-order-repurchase-secondary",
    1663              :       "wrong-session",
    1664              :       false,
    1665              :       false,
    1666              :       false,
    1667              :       NULL,
    1668              :       MHD_HTTP_PAYMENT_REQUIRED),
    1669            2 :     TALER_TESTING_cmd_merchant_order_refund (
    1670              :       "refund-repurchased",
    1671              :       merchant_url,
    1672              :       "refund repurchase",
    1673              :       "repurchase-original",
    1674              :       "EUR:1.0",
    1675              :       MHD_HTTP_OK),
    1676            2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1677              :       "repurchase-wallet-check-primary-order-refunded-no-session",
    1678              :       merchant_url,
    1679              :       "post-order-repurchase-original",
    1680              :       NULL,
    1681              :       true,
    1682              :       true,
    1683              :       true,
    1684              :       "post-order-repurchase-original",
    1685              :       MHD_HTTP_OK),
    1686            2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1687              :       "repurchase-wallet-check-primary-order-refunded",
    1688              :       merchant_url,
    1689              :       "post-order-repurchase-original",
    1690              :       "repurchase-session",
    1691              :       true,
    1692              :       true,
    1693              :       true,
    1694              :       "post-order-repurchase-original",
    1695              :       MHD_HTTP_OK),
    1696            2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1697              :       "repurchase-check-refunded",
    1698              :       merchant_url,
    1699              :       "post-order-repurchase-secondary",
    1700              :       TALER_MERCHANT_OSC_CLAIMED,
    1701              :       "repurchase-session",
    1702              :       NULL,
    1703              :       MHD_HTTP_OK),
    1704              : 
    1705            2 :     TALER_TESTING_cmd_end ()
    1706              :   };
    1707              : 
    1708              :   struct TALER_TESTING_Command tokens[] = {
    1709              :     /**
    1710              :      * Move money to the exchange's bank account.
    1711              :      */
    1712            2 :     cmd_transfer_to_exchange ("create-reserve-tokens",
    1713              :                               "EUR:20.03"),
    1714              :     /**
    1715              :      * Make a reserve exist, according to the previous transfer.
    1716              :      */
    1717            2 :     cmd_exec_wirewatch ("wirewatch-1"),
    1718            2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-tokens",
    1719              :                                                  "EUR:20.03",
    1720              :                                                  payer_payto,
    1721              :                                                  exchange_payto,
    1722              :                                                  "create-reserve-tokens"),
    1723            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
    1724              :                                        "create-reserve-tokens",
    1725              :                                        "EUR:5",
    1726              :                                        0,
    1727              :                                        MHD_HTTP_OK),
    1728            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
    1729              :                                        "create-reserve-tokens",
    1730              :                                        "EUR:5",
    1731              :                                        0,
    1732              :                                        MHD_HTTP_OK),
    1733            2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-3",
    1734              :                                        "create-reserve-tokens",
    1735              :                                        "EUR:5",
    1736              :                                        0,
    1737              :                                        MHD_HTTP_OK),
    1738            6 :     TALER_TESTING_cmd_merchant_post_tokenfamilies (
    1739              :       "create-upcoming-tokenfamily",
    1740              :       merchant_url,
    1741              :       MHD_HTTP_NO_CONTENT,
    1742              :       "subscription-upcoming",
    1743              :       "Upcoming Subscription",
    1744              :       "An upcoming subscription that is not valid yet.",
    1745              :       NULL,
    1746              :       /* In one day */
    1747              :       GNUNET_TIME_absolute_to_timestamp (
    1748              :         GNUNET_TIME_absolute_add (
    1749            2 :           GNUNET_TIME_timestamp_get ().abs_time,
    1750              :           GNUNET_TIME_UNIT_DAYS)),
    1751              :       /* In a year */
    1752              :       GNUNET_TIME_absolute_to_timestamp (
    1753              :         GNUNET_TIME_absolute_add (
    1754            2 :           GNUNET_TIME_timestamp_get ().abs_time,
    1755              :           GNUNET_TIME_UNIT_YEARS)),
    1756              :       GNUNET_TIME_UNIT_MONTHS,
    1757              :       GNUNET_TIME_UNIT_MONTHS,
    1758              :       "subscription"),
    1759            2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1760              :       "create-order-with-upcoming-output",
    1761            2 :       cred.cfg,
    1762              :       merchant_url,
    1763              :       MHD_HTTP_OK,
    1764              :       "subscription-upcoming",
    1765              :       "A choice in the contract",
    1766              :       NULL,
    1767              :       0,
    1768              :       1,
    1769              :       "5-upcoming-output",
    1770            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1771            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1772              :       "EUR:5.0"),
    1773            2 :     TALER_TESTING_cmd_merchant_post_tokenfamilies (
    1774              :       "create-tokenfamily",
    1775              :       merchant_url,
    1776              :       MHD_HTTP_NO_CONTENT,
    1777              :       "subscription-1",
    1778              :       "Subscription",
    1779              :       "A subscription.",
    1780              :       NULL,
    1781            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1782              :       GNUNET_TIME_relative_to_timestamp
    1783              :         (GNUNET_TIME_UNIT_YEARS),
    1784              :       GNUNET_TIME_UNIT_MONTHS,
    1785              :       GNUNET_TIME_UNIT_MONTHS,
    1786              :       "subscription"),
    1787            2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1788              :       "create-order-with-output",
    1789            2 :       cred.cfg,
    1790              :       merchant_url,
    1791              :       MHD_HTTP_OK,
    1792              :       "subscription-1",
    1793              :       "A choice in the contract",
    1794              :       NULL,
    1795              :       0,
    1796              :       1,
    1797              :       "5-output",
    1798            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1799            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1800              :       "EUR:5.0"),
    1801            2 :     TALER_TESTING_cmd_merchant_pay_order_choices (
    1802              :       "pay-order-with-output",
    1803              :       merchant_url,
    1804              :       MHD_HTTP_OK,
    1805              :       "create-order-with-output",
    1806              :       "withdraw-coin-1",
    1807              :       "EUR:5",
    1808              :       "EUR:4.99",
    1809              :       NULL,
    1810              :       0,
    1811              :       NULL),
    1812            2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1813              :       "create-order-with-input-and-output",
    1814            2 :       cred.cfg,
    1815              :       merchant_url,
    1816              :       MHD_HTTP_OK,
    1817              :       "subscription-1",
    1818              :       "A choice in the contract",
    1819              :       NULL,
    1820              :       1,
    1821              :       1,
    1822              :       "5-input-output",
    1823            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1824            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1825              :       "EUR:0.0"),
    1826            2 :     TALER_TESTING_cmd_merchant_pay_order_choices (
    1827              :       "pay-order-with-input-and-output",
    1828              :       merchant_url,
    1829              :       MHD_HTTP_OK,
    1830              :       "create-order-with-input-and-output",
    1831              :       "",
    1832              :       "EUR:0",
    1833              :       "EUR:0",
    1834              :       NULL,
    1835              :       0,
    1836              :       "pay-order-with-output"),
    1837              :     // TALER_TESTING_cmd_merchant_pay_order_choices ("idempotent-pay-order-with-input-and-output",
    1838              :     //                                               merchant_url,
    1839              :     //                                               MHD_HTTP_OK,
    1840              :     //                                               "create-order-with-input-and-output",
    1841              :     //                                               "",
    1842              :     //                                               "EUR:0",
    1843              :     //                                               "EUR:0",
    1844              :     //                                               NULL,
    1845              :     //                                               0,
    1846              :     //                                               "pay-order-with-output"),
    1847            2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1848              :       "create-another-order-with-input-and-output",
    1849            2 :       cred.cfg,
    1850              :       merchant_url,
    1851              :       MHD_HTTP_OK,
    1852              :       "subscription-1",
    1853              :       "A choice in the contract",
    1854              :       NULL,
    1855              :       1,
    1856              :       1,
    1857              :       "5-input-output-2",
    1858            2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1859            2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1860              :       "EUR:0.0"),
    1861            2 :     TALER_TESTING_cmd_merchant_pay_order_choices ("double-spend-token",
    1862              :                                                   merchant_url,
    1863              :                                                   MHD_HTTP_CONFLICT,
    1864              :                                                   "create-another-order-with-input-and-output",
    1865              :                                                   "",
    1866              :                                                   "EUR:0",
    1867              :                                                   "EUR:0",
    1868              :                                                   NULL,
    1869              :                                                   0,
    1870              :                                                   "pay-order-with-output"),
    1871            2 :     TALER_TESTING_cmd_end ()
    1872              :   };
    1873              : 
    1874              :   #ifdef HAVE_DONAU_DONAU_SERVICE_H
    1875              :   const struct DONAU_BearerToken bearer = {
    1876              :     .token = NULL
    1877              :   };
    1878              : 
    1879              :   struct TALER_TESTING_Command donau[] = {
    1880              :     TALER_TESTING_cmd_set_var (
    1881              :       "donau",
    1882              :       TALER_TESTING_cmd_get_donau ("get-donau",
    1883              :                                    cred.cfg,
    1884              :                                    true)),
    1885              :     TALER_TESTING_cmd_charity_post_merchant ("post-charity",
    1886              :                                              "example",
    1887              :                                              "example.com",
    1888              :                                              "EUR:50", // max_per_year
    1889              :                                              &bearer,
    1890              :                                              "create-another-order-with-input-and-output",
    1891              :                                              // reusing the merchant_reference for merchant_pub
    1892              :                                              MHD_HTTP_CREATED),
    1893              :     TALER_TESTING_cmd_charity_post_merchant ("post-charity-idempotent",
    1894              :                                              "example",
    1895              :                                              "example.com",
    1896              :                                              "EUR:50", // max_per_year
    1897              :                                              &bearer,
    1898              :                                              "create-another-order-with-input-and-output",
    1899              :                                              // reusing the merchant_reference for merchant_pub
    1900              :                                              MHD_HTTP_CREATED),
    1901              :     TALER_TESTING_cmd_merchant_post_donau_instance (
    1902              :       "post-donau-instance",
    1903              :       merchant_url,
    1904              :       "create-another-order-with-input-and-output",
    1905              :       MHD_HTTP_NO_CONTENT),
    1906              :     TALER_TESTING_cmd_merchant_post_donau_instance (
    1907              :       "post-donau-instance-idempotent",
    1908              :       merchant_url,
    1909              :       "create-another-order-with-input-and-output",
    1910              :       MHD_HTTP_NO_CONTENT),
    1911              :     TALER_TESTING_cmd_merchant_get_donau_instances (
    1912              :       "get-donau-instances-after-insert",
    1913              :       merchant_url,
    1914              :       1,
    1915              :       MHD_HTTP_OK),
    1916              :     TALER_TESTING_cmd_sleep (
    1917              :       "In this time donaukeyupdate must fetch the keys from the donau",
    1918              :       1),
    1919              :     TALER_TESTING_cmd_merchant_get_donau_instances (
    1920              :       "get-donau-instance",
    1921              :       merchant_url,
    1922              :       1,
    1923              :       MHD_HTTP_OK),
    1924              :     TALER_TESTING_cmd_merchant_post_orders_donau (
    1925              :       "create-donau-order",
    1926              :       cred.cfg,
    1927              :       merchant_url,
    1928              :       MHD_HTTP_OK,
    1929              :       "donau",
    1930              :       GNUNET_TIME_UNIT_ZERO_TS,
    1931              :       GNUNET_TIME_UNIT_FOREVER_TS,
    1932              :       "EUR:1"),
    1933              :     TALER_TESTING_cmd_merchant_pay_order_donau (
    1934              :       "pay-donau-order",
    1935              :       merchant_url,
    1936              :       MHD_HTTP_OK,
    1937              :       "create-donau-order",
    1938              :       "withdraw-coin-3",
    1939              :       "EUR:1", /* full amount */
    1940              :       "EUR:0.99", /* amount without fees */
    1941              :       "EUR:1", /* donation amount */
    1942              :       NULL,
    1943              :       0,
    1944              :       "post-charity",
    1945              :       2025,
    1946              :       "7560001010000",
    1947              :       "1234"
    1948              :       ),
    1949              :     TALER_TESTING_cmd_merchant_delete_donau_instance (
    1950              :       "delete-donau-instance",
    1951              :       merchant_url,
    1952              :       1,
    1953              :       MHD_HTTP_NO_CONTENT),
    1954              :     TALER_TESTING_cmd_merchant_get_donau_instances (
    1955              :       "get-donau-instances-after-delete",
    1956              :       merchant_url,
    1957              :       0,
    1958              :       MHD_HTTP_OK),
    1959              :     TALER_TESTING_cmd_end ()
    1960              :   };
    1961              :   #endif
    1962              : 
    1963              :   struct TALER_TESTING_Command commands[] = {
    1964              :     /* general setup */
    1965            2 :     TALER_TESTING_cmd_run_fakebank (
    1966              :       "run-fakebank",
    1967            2 :       cred.cfg,
    1968              :       "exchange-account-exchange"),
    1969              :     #ifdef HAVE_DONAU_DONAU_SERVICE_H
    1970              :     TALER_TESTING_cmd_system_start (
    1971              :       "start-taler",
    1972              :       config_file,
    1973              :       "-emaDZ",
    1974              :       "-u", "exchange-account-exchange",
    1975              :       "-r", "merchant-exchange-test",
    1976              :       NULL),
    1977              :     #else
    1978            2 :     TALER_TESTING_cmd_system_start (
    1979              :       "start-taler",
    1980              :       config_file,
    1981              :       "-ema",
    1982              :       "-u", "exchange-account-exchange",
    1983              :       "-r", "merchant-exchange-test",
    1984              :       NULL),
    1985              :     #endif
    1986            2 :     TALER_TESTING_cmd_get_exchange (
    1987              :       "get-exchange",
    1988            2 :       cred.cfg,
    1989              :       NULL,
    1990              :       true,
    1991              :       true),
    1992            2 :     TALER_TESTING_cmd_batch (
    1993              :       "orders-id",
    1994              :       get_private_order_id),
    1995            2 :     TALER_TESTING_cmd_config (
    1996              :       "config",
    1997              :       merchant_url,
    1998              :       MHD_HTTP_OK),
    1999            2 :     TALER_TESTING_cmd_merchant_get_instances (
    2000              :       "instances-empty",
    2001              :       merchant_url,
    2002              :       MHD_HTTP_OK,
    2003              :       NULL),
    2004            2 :     TALER_TESTING_cmd_merchant_post_instances (
    2005              :       "instance-create-default-setup",
    2006              :       merchant_url,
    2007              :       "admin",
    2008              :       MHD_HTTP_NO_CONTENT),
    2009            2 :     TALER_TESTING_cmd_merchant_post_account (
    2010              :       "instance-create-default-account",
    2011              :       merchant_url,
    2012              :       merchant_payto,
    2013              :       NULL, NULL,
    2014              :       MHD_HTTP_OK),
    2015            2 :     TALER_TESTING_cmd_merchant_post_instances (
    2016              :       "instance-create-i1",
    2017              :       merchant_url,
    2018              :       "i1",
    2019              :       MHD_HTTP_NO_CONTENT),
    2020            2 :     TALER_TESTING_cmd_merchant_get_instances (
    2021              :       "instances-get-i1",
    2022              :       merchant_url,
    2023              :       MHD_HTTP_OK,
    2024              :       "instance-create-i1",
    2025              :       "instance-create-default-setup",
    2026              :       NULL),
    2027            2 :     TALER_TESTING_cmd_merchant_get_instance (
    2028              :       "instances-get-i1",
    2029              :       merchant_url,
    2030              :       "i1",
    2031              :       MHD_HTTP_OK,
    2032              :       "instance-create-i1"),
    2033            4 :     TALER_TESTING_cmd_merchant_patch_instance (
    2034              :       "instance-patch-i1",
    2035              :       merchant_url,
    2036              :       "i1",
    2037              :       "bob-the-merchant",
    2038              :       json_pack ("{s:s}",
    2039              :                  "street",
    2040              :                  "bobstreet"),
    2041              :       json_pack ("{s:s}",
    2042              :                  "street",
    2043              :                  "bobjuryst"),
    2044              :       true,
    2045            2 :       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
    2046              :       GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
    2047              :                                      2), /* small pay delay */
    2048              :       MHD_HTTP_NO_CONTENT),
    2049            2 :     TALER_TESTING_cmd_merchant_get_instance (
    2050              :       "instances-get-i1-2",
    2051              :       merchant_url,
    2052              :       "i1",
    2053              :       MHD_HTTP_OK,
    2054              :       "instance-patch-i1"),
    2055            2 :     TALER_TESTING_cmd_merchant_get_instance (
    2056              :       "instances-get-i2-nx",
    2057              :       merchant_url,
    2058              :       "i2",
    2059              :       MHD_HTTP_NOT_FOUND,
    2060              :       NULL),
    2061            4 :     TALER_TESTING_cmd_merchant_post_instances2 (
    2062              :       "instance-create-ACL",
    2063              :       merchant_url,
    2064              :       "i-acl",
    2065              :       "controlled instance",
    2066              :       json_pack ("{s:s}", "city",
    2067              :                  "shopcity"),
    2068              :       json_pack ("{s:s}", "city",
    2069              :                  "lawyercity"),
    2070              :       true,
    2071            2 :       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
    2072              :       GNUNET_TIME_UNIT_SECONDS, /* pay delay */
    2073              :       // FIXME: change this back once
    2074              :       // we have a update auth test CMD
    2075              :       // RFC_8959_PREFIX "EXAMPLE",
    2076              :       NULL,
    2077              :       MHD_HTTP_NO_CONTENT),
    2078            4 :     TALER_TESTING_cmd_merchant_patch_instance (
    2079              :       "instance-patch-ACL",
    2080              :       merchant_url,
    2081              :       "i-acl",
    2082              :       "controlled instance",
    2083              :       json_pack ("{s:s}",
    2084              :                  "street",
    2085              :                  "bobstreet"),
    2086              :       json_pack ("{s:s}",
    2087              :                  "street",
    2088              :                  "bobjuryst"),
    2089              :       true,
    2090            2 :       GNUNET_TIME_UNIT_ZERO, /* wire transfer */
    2091              :       GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
    2092              :                                      2), /* small pay delay */
    2093              :       MHD_HTTP_NO_CONTENT),
    2094            2 :     TALER_TESTING_cmd_merchant_post_instances (
    2095              :       "instance-create-i2",
    2096              :       merchant_url,
    2097              :       "i2",
    2098              :       MHD_HTTP_NO_CONTENT),
    2099            2 :     TALER_TESTING_cmd_merchant_post_instances (
    2100              :       "instance-create-i2-idem",
    2101              :       merchant_url,
    2102              :       "i2",
    2103              :       MHD_HTTP_NO_CONTENT),
    2104            2 :     TALER_TESTING_cmd_merchant_delete_instance (
    2105              :       "instance-delete-i2",
    2106              :       merchant_url,
    2107              :       "i2",
    2108              :       MHD_HTTP_NO_CONTENT),
    2109            2 :     TALER_TESTING_cmd_merchant_get_instance (
    2110              :       "instances-get-i2-post-deletion",
    2111              :       merchant_url,
    2112              :       "i2",
    2113              :       MHD_HTTP_NOT_FOUND,
    2114              :       NULL),
    2115            2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2116              :       "instance-delete-then-purge-i2",
    2117              :       merchant_url,
    2118              :       "i2",
    2119              :       MHD_HTTP_NO_CONTENT),
    2120            2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2121              :       "instance-purge-i1",
    2122              :       merchant_url,
    2123              :       "i1",
    2124              :       MHD_HTTP_NO_CONTENT),
    2125            2 :     TALER_TESTING_cmd_merchant_delete_instance (
    2126              :       "instance-purge-then-delete-i1",
    2127              :       merchant_url,
    2128              :       "i1",
    2129              :       MHD_HTTP_NOT_FOUND),
    2130            2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2131              :       "instance-purge-i-acl-middle",
    2132              :       merchant_url,
    2133              :       "i-acl",
    2134              :       MHD_HTTP_NO_CONTENT),
    2135            2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2136              :       "instance-purge-default-middle",
    2137              :       merchant_url,
    2138              :       "admin",
    2139              :       MHD_HTTP_NO_CONTENT),
    2140            2 :     TALER_TESTING_cmd_merchant_post_instances (
    2141              :       "instance-create-default-after-purge",
    2142              :       merchant_url,
    2143              :       "admin",
    2144              :       MHD_HTTP_NO_CONTENT),
    2145            2 :     TALER_TESTING_cmd_merchant_post_account (
    2146              :       "instance-create-default-account-after-purge",
    2147              :       merchant_url,
    2148              :       merchant_payto,
    2149              :       NULL, NULL,
    2150              :       MHD_HTTP_OK),
    2151            2 :     TALER_TESTING_cmd_merchant_get_products (
    2152              :       "get-products-empty",
    2153              :       merchant_url,
    2154              :       MHD_HTTP_OK,
    2155              :       NULL),
    2156            2 :     TALER_TESTING_cmd_merchant_post_products (
    2157              :       "post-products-p1",
    2158              :       merchant_url,
    2159              :       "product-1",
    2160              :       "a product",
    2161              :       "EUR:1",
    2162              :       MHD_HTTP_NO_CONTENT),
    2163            2 :     TALER_TESTING_cmd_merchant_post_products (
    2164              :       "post-products-p1-idem",
    2165              :       merchant_url,
    2166              :       "product-1",
    2167              :       "a product",
    2168              :       "EUR:1",
    2169              :       MHD_HTTP_NO_CONTENT),
    2170            2 :     TALER_TESTING_cmd_merchant_post_products (
    2171              :       "post-products-p1-non-idem",
    2172              :       merchant_url,
    2173              :       "product-1",
    2174              :       "a different product",
    2175              :       "EUR:1",
    2176              :       MHD_HTTP_CONFLICT),
    2177            2 :     TALER_TESTING_cmd_merchant_get_products (
    2178              :       "get-products-p1",
    2179              :       merchant_url,
    2180              :       MHD_HTTP_OK,
    2181              :       "post-products-p1",
    2182              :       NULL),
    2183            2 :     TALER_TESTING_cmd_merchant_get_product (
    2184              :       "get-product-p1",
    2185              :       merchant_url,
    2186              :       "product-1",
    2187              :       MHD_HTTP_OK,
    2188              :       "post-products-p1"),
    2189            2 :     TALER_TESTING_cmd_merchant_post_products (
    2190              :       "post-products-p2",
    2191              :       merchant_url,
    2192              :       "product-2",
    2193              :       "a product",
    2194              :       "EUR:1",
    2195              :       MHD_HTTP_NO_CONTENT),
    2196            2 :     TALER_TESTING_cmd_merchant_patch_product (
    2197              :       "patch-products-p2",
    2198              :       merchant_url,
    2199              :       "product-2",
    2200              :       "another product",
    2201              :       json_pack ("{s:s}", "en", "text"),
    2202              :       "kg",
    2203              :       "EUR:1",
    2204              :       "data:image/jpeg;base64,RAWDATA",
    2205              :       json_array (),
    2206              :       40,
    2207              :       0,
    2208              :       json_pack ("{s:s}",
    2209              :                  "street",
    2210              :                  "pstreet"),
    2211              :       GNUNET_TIME_relative_to_timestamp (
    2212              :         GNUNET_TIME_UNIT_MINUTES),
    2213              :       MHD_HTTP_NO_CONTENT),
    2214            2 :     TALER_TESTING_cmd_merchant_get_product (
    2215              :       "get-product-p2",
    2216              :       merchant_url,
    2217              :       "product-2",
    2218              :       MHD_HTTP_OK,
    2219              :       "patch-products-p2"),
    2220            2 :     TALER_TESTING_cmd_merchant_get_product (
    2221              :       "get-product-nx",
    2222              :       merchant_url,
    2223              :       "product-nx",
    2224              :       MHD_HTTP_NOT_FOUND,
    2225              :       NULL),
    2226            2 :     TALER_TESTING_cmd_merchant_patch_product (
    2227              :       "patch-products-p3-nx",
    2228              :       merchant_url,
    2229              :       "product-3",
    2230              :       "nx updated product",
    2231              :       json_pack ("{s:s}", "en", "text"),
    2232              :       "kg",
    2233              :       "EUR:1",
    2234              :       "data:image/jpeg;base64,RAWDATA",
    2235              :       json_array (),
    2236              :       40,
    2237              :       0,
    2238              :       json_pack ("{s:s}",
    2239              :                  "street",
    2240              :                  "pstreet"),
    2241              :       GNUNET_TIME_relative_to_timestamp (
    2242              :         GNUNET_TIME_UNIT_MINUTES),
    2243              :       MHD_HTTP_NOT_FOUND),
    2244            2 :     TALER_TESTING_cmd_merchant_delete_product (
    2245              :       "get-products-empty",
    2246              :       merchant_url,
    2247              :       "p1",
    2248              :       MHD_HTTP_NOT_FOUND),
    2249            2 :     TALER_TESTING_cmd_merchant_delete_product (
    2250              :       "get-products-empty",
    2251              :       merchant_url,
    2252              :       "product-1",
    2253              :       MHD_HTTP_NO_CONTENT),
    2254            2 :     TALER_TESTING_cmd_merchant_lock_product (
    2255              :       "lock-product-p2",
    2256              :       merchant_url,
    2257              :       "product-2",
    2258              :       GNUNET_TIME_UNIT_MINUTES,
    2259              :       2,
    2260              :       MHD_HTTP_NO_CONTENT),
    2261            2 :     TALER_TESTING_cmd_merchant_lock_product (
    2262              :       "lock-product-nx",
    2263              :       merchant_url,
    2264              :       "product-nx",
    2265              :       GNUNET_TIME_UNIT_MINUTES,
    2266              :       2,
    2267              :       MHD_HTTP_NOT_FOUND),
    2268            2 :     TALER_TESTING_cmd_merchant_lock_product (
    2269              :       "lock-product-too-much",
    2270              :       merchant_url,
    2271              :       "product-2",
    2272              :       GNUNET_TIME_UNIT_MINUTES,
    2273              :       39,
    2274              :       MHD_HTTP_GONE),
    2275            2 :     TALER_TESTING_cmd_merchant_delete_product (
    2276              :       "delete-product-locked",
    2277              :       merchant_url,
    2278              :       "product-2",
    2279              :       MHD_HTTP_CONFLICT),
    2280            2 :     TALER_TESTING_cmd_batch ("pay",
    2281              :                              pay),
    2282            2 :     TALER_TESTING_cmd_batch ("double-spending",
    2283              :                              double_spending),
    2284            2 :     TALER_TESTING_cmd_batch ("pay-again",
    2285              :                              pay_again),
    2286            2 :     TALER_TESTING_cmd_batch ("pay-abort",
    2287              :                              pay_abort),
    2288            2 :     TALER_TESTING_cmd_batch ("refund",
    2289              :                              refund),
    2290            2 :     TALER_TESTING_cmd_batch ("templates",
    2291              :                              templates),
    2292            2 :     TALER_TESTING_cmd_batch ("webhooks",
    2293              :                              webhooks),
    2294            2 :     TALER_TESTING_cmd_batch ("auth",
    2295              :                              auth),
    2296            2 :     TALER_TESTING_cmd_batch ("repurchase",
    2297              :                              repurchase),
    2298            2 :     TALER_TESTING_cmd_batch ("tokens",
    2299              :                              tokens),
    2300              : 
    2301              :     #ifdef HAVE_DONAU_DONAU_SERVICE_H
    2302              :     TALER_TESTING_cmd_batch ("donau",
    2303              :                              donau),
    2304              :     #endif
    2305              : 
    2306            2 :     TALER_TESTING_cmd_merchant_get_statisticsamount ("stats-refund",
    2307              :                                                      merchant_url,
    2308              :                                                      "refunds-granted", 6, 0,
    2309              :                                                      MHD_HTTP_OK),
    2310            2 :     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-issued",
    2311              :                                                       merchant_url,
    2312              :                                                       "tokens-issued", 6, 0,
    2313              :                                                       MHD_HTTP_OK),
    2314            2 :     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-used",
    2315              :                                                       merchant_url,
    2316              :                                                       "tokens-used", 6, 0,
    2317              :                                                       MHD_HTTP_OK),
    2318              : 
    2319              :     /**
    2320              :      * End the suite.
    2321              :      */
    2322            2 :     TALER_TESTING_cmd_end ()
    2323              :   };
    2324              : 
    2325            2 :   TALER_TESTING_run (is,
    2326              :                      commands);
    2327            2 : }
    2328              : 
    2329              : 
    2330              : int
    2331            2 : main (int argc,
    2332              :       char *const *argv)
    2333              : {
    2334              :   {
    2335              :     char *cipher;
    2336              : 
    2337            2 :     cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
    2338            2 :     GNUNET_assert (NULL != cipher);
    2339            2 :     GNUNET_asprintf (&config_file,
    2340              :                      "test_merchant_api-%s.conf",
    2341              :                      cipher);
    2342            2 :     GNUNET_free (cipher);
    2343              :   }
    2344            2 :   payer_payto.full_payto =
    2345              :     (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME
    2346              :     "?receiver-name=" USER_ACCOUNT_NAME;
    2347            2 :   exchange_payto.full_payto =
    2348              :     (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
    2349              :     "?receiver-name="
    2350              :     EXCHANGE_ACCOUNT_NAME;
    2351            2 :   merchant_payto.full_payto =
    2352              :     (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
    2353              :     "?receiver-name=" MERCHANT_ACCOUNT_NAME;
    2354            2 :   merchant_url = "http://localhost:8080/";
    2355            2 :   GNUNET_asprintf (&merchant_url_i1a,
    2356              :                    "%sinstances/i1a/",
    2357              :                    merchant_url);
    2358            2 :   return TALER_TESTING_main (argv,
    2359              :                              "INFO",
    2360              :                              config_file,
    2361              :                              "exchange-account-exchange",
    2362              :                              TALER_TESTING_BS_FAKEBANK,
    2363              :                              &cred,
    2364              :                              &run,
    2365              :                              NULL);
    2366              : }
    2367              : 
    2368              : 
    2369              : /* end of test_merchant_api.c */
        

Generated by: LCOV version 2.0-1