LCOV - code coverage report
Current view: top level - testing - test_merchant_api.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 430 430 100.0 %
Date: 2025-08-28 06:06:54 Functions: 5 5 100.0 %

          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 :     CMD_EXEC_AGGREGATOR ("run-aggregator"),
     488           2 :     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-498c",
     489             :                                            EXCHANGE_URL,
     490             :                                            "EUR:4.98",
     491             :                                            exchange_payto,
     492             :                                            merchant_payto),
     493           2 :     TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1",
     494             :                                               &cred.ba,
     495             :                                               merchant_payto,
     496             :                                               merchant_url,
     497             :                                               "EUR:4.98",
     498             :                                               MHD_HTTP_NO_CONTENT,
     499             :                                               "deposit-simple",
     500             :                                               NULL),
     501           2 :     TALER_TESTING_cmd_depositcheck ("run taler-merchant-depositcheck-1",
     502             :                                     config_file),
     503           2 :     TALER_TESTING_cmd_run_tme ("run taler-merchant-reconciliation-1",
     504             :                                config_file),
     505           2 :     TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad",
     506             :                                                merchant_url,
     507             :                                                merchant_payto,
     508             :                                                "EUR:4.98",
     509             :                                                NULL,
     510             :                                                /*non-routable IP address
     511             :                                                so we are sure to not get
     512             :                                                any reply*/
     513             :                                                "http://192.0.2.1/404/",
     514             :                                                MHD_HTTP_NO_CONTENT),
     515           2 :     TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1",
     516             :                                               merchant_url,
     517             :                                               merchant_payto,
     518             :                                               MHD_HTTP_OK,
     519             :                                               "post-transfer-1",
     520             :                                               "post-transfer-bad",
     521             :                                               NULL),
     522           2 :     TALER_TESTING_cmd_merchant_delete_transfer ("delete-transfer-1",
     523             :                                                 merchant_url,
     524             :                                                 "post-transfer-bad",
     525             :                                                 MHD_HTTP_NO_CONTENT),
     526           2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-2b",
     527             :                                            merchant_url,
     528             :                                            "create-proposal-1",
     529             :                                            TALER_MERCHANT_OSC_PAID,
     530             :                                            true,
     531             :                                            order_1_transfers, /* "post-transfer-1" */
     532             :                                            false,
     533             :                                            NULL,
     534             :                                            NULL,
     535             :                                            MHD_HTTP_OK),
     536           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-1",
     537             :                                              merchant_url,
     538             :                                              MHD_HTTP_NO_CONTENT,
     539             :                                              "create-proposal-1",
     540             :                                              NULL,
     541             :                                              "$.dummy_obj",
     542             :                                              NULL),
     543           2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-1",
     544             :                                            merchant_url,
     545             :                                            "create-proposal-1",
     546             :                                            TALER_MERCHANT_OSC_PAID,
     547             :                                            true,
     548             :                                            order_1_transfers,
     549             :                                            false,
     550             :                                            NULL,
     551             :                                            order_1_forgets_1,
     552             :                                            MHD_HTTP_OK),
     553           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-unforgettable",
     554             :                                              merchant_url,
     555             :                                              MHD_HTTP_CONFLICT,
     556             :                                              "create-proposal-1",
     557             :                                              NULL,
     558             :                                              "$.amount",
     559             :                                              NULL),
     560           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-nx",
     561             :                                              merchant_url,
     562             :                                              MHD_HTTP_NOT_FOUND,
     563             :                                              NULL,
     564             :                                              "nx-order",
     565             :                                              "$.dummy_obj",
     566             :                                              NULL),
     567           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-elem",
     568             :                                              merchant_url,
     569             :                                              MHD_HTTP_NO_CONTENT,
     570             :                                              "create-proposal-1",
     571             :                                              NULL,
     572             :                                              "$.dummy_array[0].item",
     573             :                                              NULL),
     574           2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-2",
     575             :                                            merchant_url,
     576             :                                            "create-proposal-1",
     577             :                                            TALER_MERCHANT_OSC_PAID,
     578             :                                            true,
     579             :                                            order_1_transfers,
     580             :                                            false,
     581             :                                            NULL,
     582             :                                            order_1_forgets_2,
     583             :                                            MHD_HTTP_OK),
     584           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-array-wc",
     585             :                                              merchant_url,
     586             :                                              MHD_HTTP_NO_CONTENT,
     587             :                                              "create-proposal-1",
     588             :                                              NULL,
     589             :                                              "$.dummy_array[*].item",
     590             :                                              NULL),
     591           2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1-forget-3",
     592             :                                            merchant_url,
     593             :                                            "create-proposal-1",
     594             :                                            TALER_MERCHANT_OSC_PAID,
     595             :                                            true,
     596             :                                            order_1_transfers,
     597             :                                            false,
     598             :                                            NULL,
     599             :                                            order_1_forgets_3,
     600             :                                            MHD_HTTP_OK),
     601           2 :     TALER_TESTING_cmd_merchant_forget_order ("forget-order-malformed",
     602             :                                              merchant_url,
     603             :                                              MHD_HTTP_BAD_REQUEST,
     604             :                                              "create-proposal-1",
     605             :                                              NULL,
     606             :                                              "$.dummy_array[abc].item",
     607             :                                              NULL),
     608           2 :     TALER_TESTING_cmd_merchant_post_products ("post-products-p3",
     609             :                                               merchant_url,
     610             :                                               "product-3",
     611             :                                               "a product",
     612             :                                               "EUR:1",
     613             :                                               MHD_HTTP_NO_CONTENT),
     614           2 :     TALER_TESTING_cmd_merchant_post_products2 ("post-products-p4",
     615             :                                                merchant_url,
     616             :                                                "product-4age",
     617             :                                                "an age-restricted product",
     618             :                                                NULL,
     619             :                                                "unit",
     620             :                                                "EUR:1",
     621             :                                                "", /* image */
     622             :                                                NULL,
     623             :                                                4,
     624             :                                                16 /* minimum age */,
     625             :                                                NULL,
     626           2 :                                                GNUNET_TIME_UNIT_FOREVER_TS,
     627             :                                                MHD_HTTP_NO_CONTENT),
     628           2 :     TALER_TESTING_cmd_merchant_patch_product ("patch-products-p3",
     629             :                                               merchant_url,
     630             :                                               "product-3",
     631             :                                               "a product",
     632             :                                               json_object (),
     633             :                                               "can",
     634             :                                               "EUR:1",
     635             :                                               "data:image/jpeg;base64,RAWDATA",
     636             :                                               json_array (),
     637             :                                               5,
     638             :                                               0,
     639             :                                               json_object (),
     640             :                                               GNUNET_TIME_relative_to_timestamp
     641             :                                               (
     642             :                                                 GNUNET_TIME_UNIT_MINUTES),
     643             :                                               MHD_HTTP_NO_CONTENT),
     644           2 :     TALER_TESTING_cmd_merchant_lock_product ("lock-product-p3",
     645             :                                              merchant_url,
     646             :                                              "product-3",
     647             :                                              GNUNET_TIME_UNIT_MINUTES,
     648             :                                              2,
     649             :                                              MHD_HTTP_NO_CONTENT),
     650           2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-wm-nx",
     651           2 :                                              cred.cfg,
     652             :                                              merchant_url,
     653             :                                              MHD_HTTP_NOT_FOUND,
     654             :                                              "order-p3",
     655           2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     656           2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     657             :                                              true,
     658             :                                              "EUR:5.0",
     659             :                                              "unsupported-wire-method",
     660             :                                              "product-3/2",
     661             :                                              "", /* locks */
     662             :                                              NULL),
     663           2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx",
     664           2 :                                              cred.cfg,
     665             :                                              merchant_url,
     666             :                                              MHD_HTTP_NOT_FOUND,
     667             :                                              "order-p3",
     668           2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     669           2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     670             :                                              true,
     671             :                                              "EUR:5.0",
     672             :                                              "x-taler-bank",
     673             :                                              "unknown-product/2",
     674             :                                              "",
     675             :                                              NULL),
     676           2 :     TALER_TESTING_cmd_merchant_post_orders2 (
     677             :       "create-proposal-p3-not-enough-stock",
     678           2 :       cred.cfg,
     679             :       merchant_url,
     680             :       MHD_HTTP_GONE,
     681             :       "order-p3",
     682           2 :       GNUNET_TIME_UNIT_ZERO_TS,
     683           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     684             :       true,
     685             :       "EUR:5.0",
     686             :       "x-taler-bank",
     687             :       "product-3/24",
     688             :       "",
     689             :       NULL),
     690           2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3",
     691           2 :                                              cred.cfg,
     692             :                                              merchant_url,
     693             :                                              MHD_HTTP_OK,
     694             :                                              "order-p3",
     695           2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     696           2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     697             :                                              false,
     698             :                                              "EUR:5.0",
     699             :                                              "x-taler-bank",
     700             :                                              "product-3/3",
     701             :                                              "lock-product-p3",
     702             :                                              NULL),
     703           2 :     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p4-age",
     704           2 :                                              cred.cfg,
     705             :                                              merchant_url,
     706             :                                              MHD_HTTP_OK,
     707             :                                              "order-p4-age",
     708           2 :                                              GNUNET_TIME_UNIT_ZERO_TS,
     709           2 :                                              GNUNET_TIME_UNIT_FOREVER_TS,
     710             :                                              false,
     711             :                                              "EUR:5.0",
     712             :                                              "x-taler-bank",
     713             :                                              "product-4age",
     714             :                                              "", /* locks */
     715             :                                              NULL),
     716           2 :     TALER_TESTING_cmd_merchant_get_order4 ("get-order-merchant-p4-age",
     717             :                                            merchant_url,
     718             :                                            "create-proposal-p4-age",
     719             :                                            TALER_MERCHANT_OSC_CLAIMED,
     720             :                                            16,
     721             :                                            MHD_HTTP_OK),
     722           2 :     TALER_TESTING_cmd_merchant_delete_order ("delete-order-paid",
     723             :                                              merchant_url,
     724             :                                              "1",
     725             :                                              MHD_HTTP_CONFLICT),
     726           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-no-id",
     727           2 :                                             cred.cfg,
     728             :                                             merchant_url,
     729             :                                             MHD_HTTP_OK,
     730             :                                             NULL,
     731           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     732           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     733             :                                             "EUR:5.0"),
     734           2 :     TALER_TESTING_cmd_merchant_delete_webhook ("post-webhooks-pay-w1",
     735             :                                                merchant_url,
     736             :                                                "webhook-pay-1",
     737             :                                                MHD_HTTP_NO_CONTENT),
     738           2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"),
     739           2 :     TALER_TESTING_cmd_end ()
     740             :   };
     741             :   struct TALER_TESTING_Command double_spending[] = {
     742           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
     743           2 :                                             cred.cfg,
     744             :                                             merchant_url,
     745             :                                             MHD_HTTP_OK,
     746             :                                             "2",
     747           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     748           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     749             :                                             "EUR:5.0"),
     750           2 :     TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
     751             :                                             merchant_url,
     752             :                                             MHD_HTTP_OK,
     753             :                                             "create-proposal-2",
     754             :                                             NULL),
     755           2 :     TALER_TESTING_cmd_merchant_pay_order ("deposit-double-2",
     756             :                                           merchant_url,
     757             :                                           MHD_HTTP_CONFLICT,
     758             :                                           "create-proposal-2",
     759             :                                           "withdraw-coin-1",
     760             :                                           "EUR:5",
     761             :                                           "EUR:4.99",
     762             :                                           NULL),
     763           2 :     TALER_TESTING_cmd_end ()
     764             :   };
     765             : 
     766           2 :   const char *order_1r_refunds[] = {
     767             :     "refund-increase-1r",
     768             :     "refund-increase-1r-2",
     769             :     NULL
     770             :   };
     771             :   struct TALER_TESTING_Command refund[] = {
     772           2 :     cmd_transfer_to_exchange ("create-reserve-1r",
     773             :                               "EUR:10.02"),
     774             :     /**
     775             :      * Make a reserve exist, according to the previous transfer.
     776             :      */
     777           2 :     cmd_exec_wirewatch ("wirewatch-1r"),
     778           2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2r",
     779             :                                                  "EUR:10.02",
     780             :                                                  payer_payto,
     781             :                                                  exchange_payto,
     782             :                                                  "create-reserve-1r"),
     783           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1r",
     784             :                                        "create-reserve-1r",
     785             :                                        "EUR:5",
     786             :                                        0,
     787             :                                        MHD_HTTP_OK),
     788           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2r",
     789             :                                        "create-reserve-1r",
     790             :                                        "EUR:5",
     791             :                                        0,
     792             :                                        MHD_HTTP_OK),
     793             :     /**
     794             :      * Check the reserve is depleted.
     795             :      */
     796           2 :     TALER_TESTING_cmd_status ("withdraw-status-1r",
     797             :                               "create-reserve-1r",
     798             :                               "EUR:0",
     799             :                               MHD_HTTP_OK),
     800           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1r",
     801           2 :                                             cred.cfg,
     802             :                                             merchant_url,
     803             :                                             MHD_HTTP_OK,
     804             :                                             "1r",
     805           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     806           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     807             :                                             "EUR:5.0"),
     808           2 :     TALER_TESTING_cmd_wallet_poll_order_start ("poll-order-wallet-refund-1-low",
     809             :                                                merchant_url,
     810             :                                                "create-proposal-1r",
     811             :                                                POLL_ORDER_TIMEOUT,
     812             :                                                "EUR:0.01"),
     813           2 :     TALER_TESTING_cmd_wallet_poll_order_start (
     814             :       "poll-order-wallet-refund-1-high",
     815             :       merchant_url,
     816             :       "create-proposal-1r",
     817             :       POLL_ORDER_TIMEOUT,
     818             :       "EUR:0.2"),
     819           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-for-refund-1r",
     820             :                                           merchant_url,
     821             :                                           MHD_HTTP_OK,
     822             :                                           "create-proposal-1r",
     823             :                                           "withdraw-coin-1r",
     824             :                                           "EUR:5",
     825             :                                           "EUR:4.99",
     826             :                                           NULL),
     827           2 :     TALER_TESTING_cmd_poll_order_start ("poll-payment-refund-1",
     828             :                                         merchant_url,
     829             :                                         "1r", /* proposal name, not cmd ref! */
     830             :                                         POLL_ORDER_TIMEOUT),
     831           2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r",
     832             :                                              merchant_url,
     833             :                                              "refund test",
     834             :                                              "1r", /* order ID */
     835             :                                              "EUR:0.1",
     836             :                                              MHD_HTTP_OK),
     837           2 :     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-low",
     838             :                                                   MHD_HTTP_OK,
     839             :                                                   "EUR:0.1",
     840             :                                                   "poll-order-wallet-refund-1-low"),
     841           2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r",
     842             :                                         merchant_url,
     843             :                                         "create-proposal-1r",
     844             :                                         true,
     845             :                                         true,
     846             :                                         true,
     847             :                                         MHD_HTTP_OK),
     848           2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-1r-2",
     849             :                                              merchant_url,
     850             :                                              "refund test 2",
     851             :                                              "1r", /* order ID */
     852             :                                              "EUR:1.0",
     853             :                                              MHD_HTTP_OK),
     854           2 :     TALER_TESTING_cmd_wallet_poll_order_conclude ("poll-order-1-conclude-high",
     855             :                                                   MHD_HTTP_OK,
     856             :                                                   "EUR:1.0",
     857             :                                                   "poll-order-wallet-refund-1-high"),
     858           2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-2",
     859             :                                         merchant_url,
     860             :                                         "create-proposal-1r",
     861             :                                         true,
     862             :                                         true,
     863             :                                         true,
     864             :                                         MHD_HTTP_OK),
     865           2 :     TALER_TESTING_cmd_wallet_order_refund ("obtain-refund-1r",
     866             :                                            merchant_url,
     867             :                                            "create-proposal-1r",
     868             :                                            MHD_HTTP_OK,
     869             :                                            "refund-increase-1r",
     870             :                                            "refund-increase-1r-2",
     871             :                                            NULL),
     872           2 :     TALER_TESTING_cmd_wallet_get_order ("get-order-wallet-1r-3",
     873             :                                         merchant_url,
     874             :                                         "create-proposal-1r",
     875             :                                         true,
     876             :                                         true,
     877             :                                         false,
     878             :                                         MHD_HTTP_OK),
     879           2 :     TALER_TESTING_cmd_merchant_get_order ("get-order-merchant-1r",
     880             :                                           merchant_url,
     881             :                                           "create-proposal-1r",
     882             :                                           TALER_MERCHANT_OSC_PAID,
     883             :                                           true,
     884             :                                           MHD_HTTP_OK,
     885             :                                           "refund-increase-1r",
     886             :                                           "refund-increase-1r-2",
     887             :                                           NULL),
     888           2 :     TALER_TESTING_cmd_merchant_get_order2 ("get-order-merchant-1r-2",
     889             :                                            merchant_url,
     890             :                                            "create-proposal-1r",
     891             :                                            TALER_MERCHANT_OSC_PAID,
     892             :                                            false,
     893             :                                            NULL,
     894             :                                            true,
     895             :                                            order_1r_refunds,
     896             :                                            NULL,
     897             :                                            MHD_HTTP_OK),
     898           2 :     TALER_TESTING_cmd_poll_order_conclude ("poll-payment-refund-conclude-1",
     899             :                                            MHD_HTTP_OK,
     900             :                                            "poll-payment-refund-1"),
     901             : 
     902             :     /* Test /refund on a contract that was never paid.  */
     903           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-not-to-be-paid",
     904           2 :                                             cred.cfg,
     905             :                                             merchant_url,
     906             :                                             MHD_HTTP_OK,
     907             :                                             "1-unpaid",
     908           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
     909           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
     910             :                                             "EUR:5.0"),
     911             :     /* Try to increase an unpaid proposal.  */
     912           2 :     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-unpaid-proposal",
     913             :                                              merchant_url,
     914             :                                              "refund test",
     915             :                                              "1-unpaid",
     916             :                                              "EUR:0.1",
     917             :                                              MHD_HTTP_CONFLICT),
     918             :     /* Try to increase a non existent proposal.  */
     919           2 :     TALER_TESTING_cmd_merchant_order_refund (
     920             :       "refund-increase-nonexistent-proposal",
     921             :       merchant_url,
     922             :       "refund test",
     923             :       "non-existent-id",
     924             :       "EUR:0.1",
     925             :       MHD_HTTP_NOT_FOUND),
     926             :     /*
     927             :        The following block will (1) create a new
     928             :        reserve, then (2) a proposal, then (3) pay for
     929             :        it, and finally (4) attempt to pick up a refund
     930             :        from it without any increasing taking place
     931             :        in the first place.
     932             :     */
     933           2 :     cmd_transfer_to_exchange ("create-reserve-unincreased-refund",
     934             :                               "EUR:5.01"),
     935           2 :     cmd_exec_wirewatch ("wirewatch-unincreased-refund"),
     936           2 :     TALER_TESTING_cmd_check_bank_admin_transfer (
     937             :       "check_bank_transfer-unincreased-refund",
     938             :       "EUR:5.01",
     939             :       payer_payto,
     940             :       exchange_payto,
     941             :       "create-reserve-unincreased-refund"),
     942           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unincreased-refund",
     943             :                                        "create-reserve-unincreased-refund",
     944             :                                        "EUR:5",
     945             :                                        0,
     946             :                                        MHD_HTTP_OK),
     947           2 :     TALER_TESTING_cmd_merchant_post_orders (
     948             :       "create-proposal-unincreased-refund",
     949           2 :       cred.cfg,
     950             :       merchant_url,
     951             :       MHD_HTTP_OK,
     952             :       "unincreased-proposal",
     953           2 :       GNUNET_TIME_UNIT_ZERO_TS,
     954           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
     955             :       "EUR:5.0"),
     956           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-unincreased-proposal",
     957             :                                           merchant_url,
     958             :                                           MHD_HTTP_OK,
     959             :                                           "create-proposal-unincreased-refund",
     960             :                                           "withdraw-coin-unincreased-refund",
     961             :                                           "EUR:5",
     962             :                                           "EUR:4.99",
     963             :                                           NULL),
     964           2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-unincreased-refund"),
     965           2 :     TALER_TESTING_cmd_check_bank_transfer (
     966             :       "check_bank_transfer-paid-unincreased-refund",
     967             :       EXCHANGE_URL,
     968             :       "EUR:8.97", /* '4.98 from above', plus 4.99 from 'pay-for-refund-1r'
     969             :                      and MINUS 0.1 MINUS 0.9 from
     970             :                      'refund-increase-1r' and 'refund-increase-1r-2' */
     971             :       exchange_payto,
     972             :       merchant_payto),
     973           2 :     TALER_TESTING_cmd_end ()
     974             :   };
     975             : 
     976             :   struct TALER_TESTING_Command auth[] = {
     977           2 :     TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1a",
     978             :                                                merchant_url,
     979             :                                                "i1a",
     980             :                                                MHD_HTTP_NO_CONTENT),
     981           2 :     TALER_TESTING_cmd_merchant_post_account (
     982             :       "instance-create-i1a-account",
     983             :       merchant_url_i1a,
     984             :       merchant_payto,
     985             :       NULL, NULL,
     986             :       MHD_HTTP_OK),
     987           2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1",
     988             :                                             merchant_url_i1a,
     989             :                                             "nx-product",
     990             :                                             MHD_HTTP_NOT_FOUND,
     991             :                                             NULL),
     992           2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-1",
     993             :                                              merchant_url_i1a,
     994             :                                              MHD_HTTP_OK,
     995             :                                              NULL),
     996           2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-2",
     997             :                                             merchant_url_i1a,
     998             :                                             "nx-product",
     999             :                                             MHD_HTTP_NOT_FOUND,
    1000             :                                             NULL),
    1001           2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-2",
    1002             :                                              merchant_url_i1a,
    1003             :                                              MHD_HTTP_OK,
    1004             :                                              NULL),
    1005           2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1006             :       "instance-create-i1a-auth-ok",
    1007             :       merchant_url,
    1008             :       "i1a",
    1009             :       "my-secret",
    1010             :       MHD_HTTP_NO_CONTENT),
    1011           2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-3",
    1012             :                                             merchant_url_i1a,
    1013             :                                             "nx-product",
    1014             :                                             MHD_HTTP_UNAUTHORIZED,
    1015             :                                             NULL),
    1016           2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-3",
    1017             :                                              merchant_url_i1a,
    1018             :                                              MHD_HTTP_UNAUTHORIZED,
    1019             :                                              NULL),
    1020           2 :     TALER_TESTING_cmd_set_authorization ("set-auth-valid",
    1021             :                                          "Basic aTFhOm15LXNlY3JldA=="),
    1022           2 :     TALER_TESTING_cmd_merchant_post_instance_token (
    1023             :       "instance-create-i1a-token-ok",
    1024             :       merchant_url,
    1025             :       "i1a",
    1026             :       "write", /* scope */
    1027             :       GNUNET_TIME_UNIT_DAYS, /* duration */
    1028             :       GNUNET_YES, /* refreshable */
    1029             :       MHD_HTTP_OK),
    1030           2 :     TALER_TESTING_cmd_set_authorization ("unset-auth-valid",
    1031             :                                          NULL), // Unset header
    1032           2 :     TALER_TESTING_cmd_merchant_set_instance_token (
    1033             :       "instance-create-i1a-token-set",
    1034             :       "instance-create-i1a-token-ok"),
    1035           2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-4",
    1036             :                                             merchant_url_i1a,
    1037             :                                             "nx-product",
    1038             :                                             MHD_HTTP_NOT_FOUND,
    1039             :                                             NULL),
    1040           2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-4",
    1041             :                                              merchant_url_i1a,
    1042             :                                              MHD_HTTP_OK,
    1043             :                                              NULL),
    1044           2 :     TALER_TESTING_cmd_merchant_delete_instance_token (
    1045             :       "instance-create-i1a-token-delete",
    1046             :       merchant_url,
    1047             :       "i1a",
    1048             :       MHD_HTTP_NO_CONTENT),
    1049           2 :     TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-5",
    1050             :                                             merchant_url_i1a,
    1051             :                                             "nx-product",
    1052             :                                             MHD_HTTP_UNAUTHORIZED,
    1053             :                                             NULL),
    1054           2 :     TALER_TESTING_cmd_merchant_get_products ("get-i1a-products-empty-5",
    1055             :                                              merchant_url_i1a,
    1056             :                                              MHD_HTTP_UNAUTHORIZED,
    1057             :                                              NULL),
    1058           2 :     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a-fail",
    1059             :                                                merchant_url_i1a,
    1060             :                                                NULL,
    1061             :                                                MHD_HTTP_UNAUTHORIZED),
    1062           2 :     TALER_TESTING_cmd_set_authorization ("set-token-auth-valid-again",
    1063             :                                          "Basic aTFhOm15LXNlY3JldA=="),
    1064           2 :     TALER_TESTING_cmd_merchant_post_instance_token (
    1065             :       "set-auth-valid-again",
    1066             :       merchant_url,
    1067             :       "i1a",
    1068             :       "write", /* scope */
    1069             :       GNUNET_TIME_UNIT_DAYS, /* duration */
    1070             :       GNUNET_YES, /* refreshable */
    1071             :       MHD_HTTP_OK),
    1072           2 :     TALER_TESTING_cmd_set_authorization ("unset-auth-valid2",
    1073             :                                          NULL), // Unset header
    1074           2 :     TALER_TESTING_cmd_merchant_set_instance_token (
    1075             :       "instance-create-i1a-token-set-again",
    1076             :       "set-auth-valid-again"),
    1077           2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1078             :       "instance-create-i1a-auth-ok-idempotent",
    1079             :       merchant_url_i1a,
    1080             :       NULL,
    1081             :       RFC_8959_PREFIX "my-other-secret",
    1082             :       MHD_HTTP_NO_CONTENT),
    1083           2 :     TALER_TESTING_cmd_merchant_post_instance_auth (
    1084             :       "instance-create-i1a-clear-auth",
    1085             :       merchant_url_i1a,
    1086             :       NULL,
    1087             :       NULL,
    1088             :       MHD_HTTP_NO_CONTENT),
    1089           2 :     TALER_TESTING_cmd_set_authorization ("set-auth-none",
    1090             :                                          NULL),
    1091           2 :     TALER_TESTING_cmd_merchant_purge_instance ("instance-delete-i1a",
    1092             :                                                merchant_url_i1a,
    1093             :                                                NULL,
    1094             :                                                MHD_HTTP_NO_CONTENT),
    1095           2 :     TALER_TESTING_cmd_end ()
    1096             :   };
    1097             : 
    1098             :   struct TALER_TESTING_Command pay_again[] = {
    1099           2 :     cmd_transfer_to_exchange ("create-reserve-20",
    1100             :                               "EUR:20.04"),
    1101           2 :     cmd_exec_wirewatch ("wirewatch-20"),
    1102           2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-10",
    1103             :                                                  "EUR:20.04",
    1104             :                                                  payer_payto,
    1105             :                                                  exchange_payto,
    1106             :                                                  "create-reserve-20"),
    1107           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10a",
    1108             :                                        "create-reserve-20",
    1109             :                                        "EUR:5",
    1110             :                                        0,
    1111             :                                        MHD_HTTP_OK),
    1112           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10b",
    1113             :                                        "create-reserve-20",
    1114             :                                        "EUR:5",
    1115             :                                        0,
    1116             :                                        MHD_HTTP_OK),
    1117           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10c",
    1118             :                                        "create-reserve-20",
    1119             :                                        "EUR:5",
    1120             :                                        0,
    1121             :                                        MHD_HTTP_OK),
    1122           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-10d",
    1123             :                                        "create-reserve-20",
    1124             :                                        "EUR:5",
    1125             :                                        0,
    1126             :                                        MHD_HTTP_OK),
    1127           2 :     TALER_TESTING_cmd_status ("withdraw-status-20",
    1128             :                               "create-reserve-20",
    1129             :                               "EUR:0",
    1130             :                               MHD_HTTP_OK),
    1131           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10",
    1132           2 :                                             cred.cfg,
    1133             :                                             merchant_url,
    1134             :                                             MHD_HTTP_OK,
    1135             :                                             "10",
    1136           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
    1137           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
    1138             :                                             "EUR:10.0"),
    1139           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-10",
    1140             :                                           merchant_url,
    1141             :                                           MHD_HTTP_CONFLICT,
    1142             :                                           "create-proposal-10",
    1143             :                                           "withdraw-coin-10a;withdraw-coin-1",
    1144             :                                           "EUR:5",
    1145             :                                           "EUR:4.99",
    1146             :                                           NULL),
    1147           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-again-10",
    1148             :                                           merchant_url,
    1149             :                                           MHD_HTTP_OK,
    1150             :                                           "create-proposal-10",
    1151             :                                           "withdraw-coin-10a;withdraw-coin-10b",
    1152             :                                           "EUR:5",
    1153             :                                           "EUR:4.99",
    1154             :                                           NULL),
    1155           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-too-much-10",
    1156             :                                           merchant_url,
    1157             :                                           MHD_HTTP_CONFLICT,
    1158             :                                           "create-proposal-10",
    1159             :                                           "withdraw-coin-10c;withdraw-coin-10d",
    1160             :                                           "EUR:5",
    1161             :                                           "EUR:4.99",
    1162             :                                           NULL),
    1163           2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-10"),
    1164           2 :     TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-9.97-10",
    1165             :                                            EXCHANGE_URL,
    1166             :                                            "EUR:9.97",
    1167             :                                            exchange_payto,
    1168             :                                            merchant_payto),
    1169           2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-10"),
    1170           2 :     TALER_TESTING_cmd_end ()
    1171             :   };
    1172             : 
    1173             :   struct TALER_TESTING_Command pay_abort[] = {
    1174           2 :     cmd_transfer_to_exchange ("create-reserve-11",
    1175             :                               "EUR:10.02"),
    1176           2 :     cmd_exec_wirewatch ("wirewatch-11"),
    1177           2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-11",
    1178             :                                                  "EUR:10.02",
    1179             :                                                  payer_payto,
    1180             :                                                  exchange_payto,
    1181             :                                                  "create-reserve-11"),
    1182           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11a",
    1183             :                                        "create-reserve-11",
    1184             :                                        "EUR:5",
    1185             :                                        0,
    1186             :                                        MHD_HTTP_OK),
    1187           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-11b",
    1188             :                                        "create-reserve-11",
    1189             :                                        "EUR:5",
    1190             :                                        0,
    1191             :                                        MHD_HTTP_OK),
    1192           2 :     TALER_TESTING_cmd_status ("withdraw-status-11",
    1193             :                               "create-reserve-11",
    1194             :                               "EUR:0",
    1195             :                               MHD_HTTP_OK),
    1196           2 :     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-11",
    1197           2 :                                             cred.cfg,
    1198             :                                             merchant_url,
    1199             :                                             MHD_HTTP_OK,
    1200             :                                             "11",
    1201           2 :                                             GNUNET_TIME_UNIT_ZERO_TS,
    1202           2 :                                             GNUNET_TIME_UNIT_FOREVER_TS,
    1203             :                                             "EUR:10.0"),
    1204           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-good",
    1205             :                                           merchant_url,
    1206             :                                           MHD_HTTP_BAD_REQUEST,
    1207             :                                           "create-proposal-11",
    1208             :                                           "withdraw-coin-11a",
    1209             :                                           "EUR:5",
    1210             :                                           "EUR:4.99",
    1211             :                                           NULL),
    1212           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-bad",
    1213             :                                           merchant_url,
    1214             :                                           MHD_HTTP_CONFLICT,
    1215             :                                           "create-proposal-11",
    1216             :                                           "withdraw-coin-1",
    1217             :                                           "EUR:5",
    1218             :                                           "EUR:4.99",
    1219             :                                           NULL),
    1220           2 :     TALER_TESTING_cmd_merchant_order_abort ("pay-abort-11",
    1221             :                                             merchant_url,
    1222             :                                             "pay-fail-partial-double-11-good",
    1223             :                                             MHD_HTTP_OK),
    1224           2 :     CMD_EXEC_AGGREGATOR ("run-aggregator-11"),
    1225           2 :     TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-11"),
    1226           2 :     TALER_TESTING_cmd_end ()
    1227             :   };
    1228             : 
    1229             :   struct TALER_TESTING_Command templates[] = {
    1230           2 :     cmd_transfer_to_exchange ("create-reserve-20x",
    1231             :                               "EUR:20.04"),
    1232           2 :     cmd_exec_wirewatch ("wirewatch-20x"),
    1233           2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-20x",
    1234             :                                                  "EUR:20.04",
    1235             :                                                  payer_payto,
    1236             :                                                  exchange_payto,
    1237             :                                                  "create-reserve-20x"),
    1238           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xa",
    1239             :                                        "create-reserve-20x",
    1240             :                                        "EUR:5",
    1241             :                                        0,
    1242             :                                        MHD_HTTP_OK),
    1243           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xb",
    1244             :                                        "create-reserve-20x",
    1245             :                                        "EUR:5",
    1246             :                                        0,
    1247             :                                        MHD_HTTP_OK),
    1248           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xc",
    1249             :                                        "create-reserve-20x",
    1250             :                                        "EUR:5",
    1251             :                                        0,
    1252             :                                        MHD_HTTP_OK),
    1253           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-xd",
    1254             :                                        "create-reserve-20x",
    1255             :                                        "EUR:5",
    1256             :                                        0,
    1257             :                                        MHD_HTTP_OK),
    1258           2 :     TALER_TESTING_cmd_status ("withdraw-status-20x",
    1259             :                               "create-reserve-20x",
    1260             :                               "EUR:0",
    1261             :                               MHD_HTTP_OK),
    1262           2 :     TALER_TESTING_cmd_merchant_get_templates ("get-templates-empty",
    1263             :                                               merchant_url,
    1264             :                                               MHD_HTTP_OK,
    1265             :                                               NULL),
    1266           2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1",
    1267             :                                                merchant_url,
    1268             :                                                "template-1",
    1269             :                                                "a template",
    1270             :                                                MHD_HTTP_NO_CONTENT),
    1271           2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-idem",
    1272             :                                                merchant_url,
    1273             :                                                "template-1",
    1274             :                                                "a template",
    1275             :                                                MHD_HTTP_NO_CONTENT),
    1276           2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t1-non-idem",
    1277             :                                                merchant_url,
    1278             :                                                "template-1",
    1279             :                                                "a different template",
    1280             :                                                MHD_HTTP_CONFLICT),
    1281           2 :     TALER_TESTING_cmd_merchant_get_templates ("get-templates-t1",
    1282             :                                               merchant_url,
    1283             :                                               MHD_HTTP_OK,
    1284             :                                               "post-templates-t1",
    1285             :                                               NULL),
    1286           2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-t1",
    1287             :                                              merchant_url,
    1288             :                                              "template-1",
    1289             :                                              MHD_HTTP_OK,
    1290             :                                              "post-templates-t1"),
    1291           2 :     TALER_TESTING_cmd_merchant_post_templates ("post-templates-t2",
    1292             :                                                merchant_url,
    1293             :                                                "template-2",
    1294             :                                                "a template",
    1295             :                                                MHD_HTTP_NO_CONTENT),
    1296           2 :     TALER_TESTING_cmd_merchant_patch_template (
    1297             :       "patch-templates-t2",
    1298             :       merchant_url,
    1299             :       "template-2",
    1300             :       "another template",
    1301             :       NULL,
    1302           2 :       GNUNET_JSON_PACK (
    1303             :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1304             :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1305             :                                    GNUNET_TIME_UNIT_MINUTES)),
    1306             :       MHD_HTTP_NO_CONTENT),
    1307           2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-t2",
    1308             :                                              merchant_url,
    1309             :                                              "template-2",
    1310             :                                              MHD_HTTP_OK,
    1311             :                                              "patch-templates-t2"),
    1312           2 :     TALER_TESTING_cmd_merchant_get_template ("get-template-nx",
    1313             :                                              merchant_url,
    1314             :                                              "template-nx",
    1315             :                                              MHD_HTTP_NOT_FOUND,
    1316             :                                              NULL),
    1317           2 :     TALER_TESTING_cmd_merchant_post_otp_devices (
    1318             :       "post-otp-device",
    1319             :       merchant_url,
    1320             :       "otp-dev",
    1321             :       "my OTP device",
    1322             :       "FEE4P2J",
    1323             :       TALER_MCA_WITH_PRICE,
    1324             :       0,
    1325             :       MHD_HTTP_NO_CONTENT),
    1326           2 :     TALER_TESTING_cmd_merchant_patch_template (
    1327             :       "patch-templates-t3-nx",
    1328             :       merchant_url,
    1329             :       "template-3",
    1330             :       "updated template",
    1331             :       "otp-dev",
    1332           2 :       GNUNET_JSON_PACK (
    1333             :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1334             :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1335             :                                    GNUNET_TIME_UNIT_MINUTES)),
    1336             :       MHD_HTTP_NOT_FOUND),
    1337           2 :     TALER_TESTING_cmd_merchant_post_templates2 (
    1338             :       "post-templates-t3-amount",
    1339             :       merchant_url,
    1340             :       "template-amount",
    1341             :       "a different template with an amount",
    1342             :       NULL,
    1343           2 :       GNUNET_JSON_PACK (
    1344             :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1345             :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1346             :                                    GNUNET_TIME_UNIT_MINUTES),
    1347             :         GNUNET_JSON_pack_string ("amount",
    1348             :                                  "EUR:4")),
    1349             :       MHD_HTTP_NO_CONTENT),
    1350           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1351             :       "using-templates-t1",
    1352             :       "post-templates-t1",
    1353             :       NULL,
    1354             :       merchant_url,
    1355             :       "1",
    1356             :       "summary-1",
    1357             :       "EUR:9.98",
    1358           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1359           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1360             :       MHD_HTTP_OK),
    1361           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1362             :       "using-templates-t1-amount-missing",
    1363             :       "post-templates-t1",
    1364             :       NULL,
    1365             :       merchant_url,
    1366             :       "2",
    1367             :       "summary-1",
    1368             :       NULL,
    1369           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1370           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1371             :       MHD_HTTP_CONFLICT),
    1372           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1373             :       "using-templates-t1-summary-missing",
    1374             :       "post-templates-t1",
    1375             :       NULL,
    1376             :       merchant_url,
    1377             :       "3",
    1378             :       NULL,
    1379             :       "EUR:10",
    1380           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1381           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1382             :       MHD_HTTP_CONFLICT),
    1383           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1384             :       "using-templates-t1-amount-conflict",
    1385             :       "post-templates-t3-amount",
    1386             :       NULL,
    1387             :       merchant_url,
    1388             :       "4",
    1389             :       "summary-1",
    1390             :       "EUR:10",
    1391           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1392           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1393             :       MHD_HTTP_CONFLICT),
    1394           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1395             :       "using-templates-t1-amount-duplicate",
    1396             :       "post-templates-t3-amount",
    1397             :       NULL,
    1398             :       merchant_url,
    1399             :       "4",
    1400             :       "summary-1",
    1401             :       "EUR:4",
    1402           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1403           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1404             :       MHD_HTTP_CONFLICT),
    1405           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-100",
    1406             :                                           merchant_url,
    1407             :                                           MHD_HTTP_OK,
    1408             :                                           "using-templates-t1",
    1409             :                                           "withdraw-coin-xa;withdraw-coin-xb",
    1410             :                                           "EUR:4.99",
    1411             :                                           "EUR:4.99",
    1412             :                                           NULL),
    1413           2 :     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
    1414             :                                                 merchant_url,
    1415             :                                                 "t1",
    1416             :                                                 MHD_HTTP_NOT_FOUND),
    1417           2 :     TALER_TESTING_cmd_merchant_delete_template ("get-templates-empty",
    1418             :                                                 merchant_url,
    1419             :                                                 "template-1",
    1420             :                                                 MHD_HTTP_NO_CONTENT),
    1421           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1422             :       "post-templates-t1-deleted",
    1423             :       "post-templates-t1",
    1424             :       NULL,
    1425             :       merchant_url,
    1426             :       "0",
    1427             :       "summary-1",
    1428             :       "EUR:5",
    1429           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1430           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1431             :       MHD_HTTP_NOT_FOUND),
    1432           2 :     TALER_TESTING_cmd_merchant_post_otp_devices (
    1433             :       "post-otp-device",
    1434             :       merchant_url,
    1435             :       "otp-dev-2",
    1436             :       "my OTP device",
    1437             :       "secret",
    1438             :       TALER_MCA_WITH_PRICE,
    1439             :       0,
    1440             :       MHD_HTTP_NO_CONTENT),
    1441           2 :     TALER_TESTING_cmd_merchant_post_templates2 (
    1442             :       "post-templates-with-pos-key",
    1443             :       merchant_url,
    1444             :       "template-key",
    1445             :       "a different template with POS KEY",
    1446             :       "otp-dev-2",
    1447           2 :       GNUNET_JSON_PACK (
    1448             :         GNUNET_JSON_pack_uint64 ("minimum_age", 0),
    1449             :         GNUNET_JSON_pack_time_rel ("pay_duration",
    1450             :                                    GNUNET_TIME_UNIT_MINUTES)),
    1451             :       MHD_HTTP_NO_CONTENT),
    1452             : 
    1453           2 :     TALER_TESTING_cmd_merchant_post_using_templates (
    1454             :       "using-templates-pos-key",
    1455             :       "post-templates-with-pos-key",
    1456             :       "post-otp-device",
    1457             :       merchant_url,
    1458             :       "1",
    1459             :       "summary-1-pos",
    1460             :       "EUR:9.98",
    1461           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1462           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1463             :       MHD_HTTP_OK),
    1464           2 :     TALER_TESTING_cmd_merchant_pay_order ("pay-with-pos",
    1465             :                                           merchant_url,
    1466             :                                           MHD_HTTP_OK,
    1467             :                                           "using-templates-pos-key",
    1468             :                                           "withdraw-coin-xc;withdraw-coin-xd",
    1469             :                                           "EUR:4.99",
    1470             :                                           "EUR:4.99",
    1471             :                                           NULL),
    1472             : 
    1473             : 
    1474           2 :     TALER_TESTING_cmd_end ()
    1475             :   };
    1476             : 
    1477             :   struct TALER_TESTING_Command webhooks[] = {
    1478           2 :     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-empty",
    1479             :                                              merchant_url,
    1480             :                                              MHD_HTTP_OK,
    1481             :                                              NULL),
    1482           2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1",
    1483             :                                               merchant_url,
    1484             :                                               "webhook-1",
    1485             :                                               "Paid",
    1486             :                                               MHD_HTTP_NO_CONTENT),
    1487           2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-idem",
    1488             :                                               merchant_url,
    1489             :                                               "webhook-1",
    1490             :                                               "Paid",
    1491             :                                               MHD_HTTP_NO_CONTENT),
    1492           2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w1-non-idem",
    1493             :                                               merchant_url,
    1494             :                                               "webhook-1",
    1495             :                                               "Refund",
    1496             :                                               MHD_HTTP_CONFLICT),
    1497           2 :     TALER_TESTING_cmd_merchant_get_webhooks ("get-webhooks-w1",
    1498             :                                              merchant_url,
    1499             :                                              MHD_HTTP_OK,
    1500             :                                              "post-webhooks-w1",
    1501             :                                              NULL),
    1502           2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w1",
    1503             :                                             merchant_url,
    1504             :                                             "webhook-1",
    1505             :                                             MHD_HTTP_OK,
    1506             :                                             "post-webhooks-w1"),
    1507           2 :     TALER_TESTING_cmd_merchant_post_webhooks ("post-webhooks-w2",
    1508             :                                               merchant_url,
    1509             :                                               "webhook-2",
    1510             :                                               "Paid",
    1511             :                                               MHD_HTTP_NO_CONTENT),
    1512           2 :     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w2",
    1513             :                                               merchant_url,
    1514             :                                               "webhook-2",
    1515             :                                               "Refund2",
    1516             :                                               "http://localhost:38188/",
    1517             :                                               "POST",
    1518             :                                               "Authorization:WHWOXZXPLL",
    1519             :                                               "Amount",
    1520             :                                               MHD_HTTP_NO_CONTENT),
    1521           2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-w2",
    1522             :                                             merchant_url,
    1523             :                                             "webhook-2",
    1524             :                                             MHD_HTTP_OK,
    1525             :                                             "patch-webhooks-w2"),
    1526           2 :     TALER_TESTING_cmd_merchant_get_webhook ("get-webhook-nx",
    1527             :                                             merchant_url,
    1528             :                                             "webhook-nx",
    1529             :                                             MHD_HTTP_NOT_FOUND,
    1530             :                                             NULL),
    1531           2 :     TALER_TESTING_cmd_merchant_patch_webhook ("patch-webhooks-w3-nx",
    1532             :                                               merchant_url,
    1533             :                                               "webhook-3",
    1534             :                                               "Paid2",
    1535             :                                               "https://example.com",
    1536             :                                               "POST",
    1537             :                                               "Authorization:WHWOXZXPLL",
    1538             :                                               "Amount",
    1539             :                                               MHD_HTTP_NOT_FOUND),
    1540           2 :     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
    1541             :                                                merchant_url,
    1542             :                                                "w1",
    1543             :                                                MHD_HTTP_NOT_FOUND),
    1544           2 :     TALER_TESTING_cmd_merchant_delete_webhook ("get-webhooks-empty",
    1545             :                                                merchant_url,
    1546             :                                                "webhook-1",
    1547             :                                                MHD_HTTP_NO_CONTENT),
    1548           2 :     TALER_TESTING_cmd_end ()
    1549             :   };
    1550             :   struct TALER_TESTING_Command repurchase[] = {
    1551           2 :     cmd_transfer_to_exchange (
    1552             :       "create-reserve-30x",
    1553             :       "EUR:30.06"),
    1554           2 :     cmd_exec_wirewatch (
    1555             :       "wirewatch-30x"),
    1556           2 :     TALER_TESTING_cmd_check_bank_admin_transfer (
    1557             :       "check_bank_transfer-30x",
    1558             :       "EUR:30.06",
    1559             :       payer_payto,
    1560             :       exchange_payto,
    1561             :       "create-reserve-30x"),
    1562           2 :     TALER_TESTING_cmd_withdraw_amount (
    1563             :       "withdraw-coin-rep",
    1564             :       "create-reserve-30x",
    1565             :       "EUR:5",
    1566             :       0,
    1567             :       MHD_HTTP_OK),
    1568           2 :     TALER_TESTING_cmd_merchant_post_orders3 (
    1569             :       "post-order-repurchase-original",
    1570           2 :       cred.cfg,
    1571             :       merchant_url,
    1572             :       MHD_HTTP_OK,
    1573             :       "repurchase-original",
    1574             :       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
    1575           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1576             :       "https://fulfillment.example.com/",
    1577             :       "EUR:1.0"),
    1578           2 :     TALER_TESTING_cmd_merchant_pay_order (
    1579             :       "repurchase-pay-first",
    1580             :       merchant_url,
    1581             :       MHD_HTTP_OK,
    1582             :       "post-order-repurchase-original",
    1583             :       "withdraw-coin-rep",
    1584             :       "EUR:1.00",
    1585             :       "EUR:0.99",
    1586             :       "repurchase-session"),
    1587           2 :     TALER_TESTING_cmd_wallet_get_order (
    1588             :       "repurchase-wallet-check-primary-order",
    1589             :       merchant_url,
    1590             :       "post-order-repurchase-original",
    1591             :       true,
    1592             :       false,
    1593             :       false,
    1594             :       MHD_HTTP_OK),
    1595           2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1596             :       "repurchase-check-primary-payment",
    1597             :       merchant_url,
    1598             :       "post-order-repurchase-original",
    1599             :       TALER_MERCHANT_OSC_PAID,
    1600             :       "repurchase-session",
    1601             :       NULL,
    1602             :       MHD_HTTP_OK),
    1603           2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1604             :       "repurchase-check-primary-payment-bad-binding",
    1605             :       merchant_url,
    1606             :       "post-order-repurchase-original",
    1607             :       TALER_MERCHANT_OSC_CLAIMED, /* someone else has it! */
    1608             :       "wrong-session",
    1609             :       NULL,
    1610             :       MHD_HTTP_OK),
    1611           2 :     TALER_TESTING_cmd_merchant_post_orders3 (
    1612             :       "post-order-repurchase-secondary",
    1613           2 :       cred.cfg,
    1614             :       merchant_url,
    1615             :       MHD_HTTP_OK,
    1616             :       "repurchase-secondary",
    1617             :       GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_MINUTES),
    1618           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1619             :       "https://fulfillment.example.com/",
    1620             :       "EUR:1.0"),
    1621           2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1622             :       "repurchase-check-secondary-payment",
    1623             :       merchant_url,
    1624             :       "post-order-repurchase-secondary",
    1625             :       TALER_MERCHANT_OSC_UNPAID,
    1626             :       "repurchase-session",
    1627             :       NULL,
    1628             :       MHD_HTTP_OK),
    1629           2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1630             :       "repurchase-check-secondary-payment",
    1631             :       merchant_url,
    1632             :       "post-order-repurchase-secondary",
    1633             :       TALER_MERCHANT_OSC_UNPAID,
    1634             :       "repurchase-session",
    1635             :       "post-order-repurchase-original",
    1636             :       MHD_HTTP_OK),
    1637           2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1638             :       "repurchase-wallet-check-order-secondary",
    1639             :       merchant_url,
    1640             :       "post-order-repurchase-secondary",
    1641             :       "repurchase-session",
    1642             :       false,
    1643             :       false,
    1644             :       false,
    1645             :       "post-order-repurchase-original",
    1646             :       MHD_HTTP_PAYMENT_REQUIRED),
    1647           2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1648             :       "repurchase-wallet-check-order-secondary-bad-session",
    1649             :       merchant_url,
    1650             :       "post-order-repurchase-secondary",
    1651             :       "wrong-session",
    1652             :       false,
    1653             :       false,
    1654             :       false,
    1655             :       NULL,
    1656             :       MHD_HTTP_PAYMENT_REQUIRED),
    1657           2 :     TALER_TESTING_cmd_merchant_order_refund (
    1658             :       "refund-repurchased",
    1659             :       merchant_url,
    1660             :       "refund repurchase",
    1661             :       "repurchase-original",
    1662             :       "EUR:1.0",
    1663             :       MHD_HTTP_OK),
    1664           2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1665             :       "repurchase-wallet-check-primary-order-refunded-no-session",
    1666             :       merchant_url,
    1667             :       "post-order-repurchase-original",
    1668             :       NULL,
    1669             :       true,
    1670             :       true,
    1671             :       true,
    1672             :       "post-order-repurchase-original",
    1673             :       MHD_HTTP_OK),
    1674           2 :     TALER_TESTING_cmd_wallet_get_order2 (
    1675             :       "repurchase-wallet-check-primary-order-refunded",
    1676             :       merchant_url,
    1677             :       "post-order-repurchase-original",
    1678             :       "repurchase-session",
    1679             :       true,
    1680             :       true,
    1681             :       true,
    1682             :       "post-order-repurchase-original",
    1683             :       MHD_HTTP_OK),
    1684           2 :     TALER_TESTING_cmd_merchant_get_order3 (
    1685             :       "repurchase-check-refunded",
    1686             :       merchant_url,
    1687             :       "post-order-repurchase-secondary",
    1688             :       TALER_MERCHANT_OSC_CLAIMED,
    1689             :       "repurchase-session",
    1690             :       NULL,
    1691             :       MHD_HTTP_OK),
    1692             : 
    1693           2 :     TALER_TESTING_cmd_end ()
    1694             :   };
    1695             : 
    1696             :   struct TALER_TESTING_Command tokens[] = {
    1697             :     /**
    1698             :      * Move money to the exchange's bank account.
    1699             :      */
    1700           2 :     cmd_transfer_to_exchange ("create-reserve-tokens",
    1701             :                               "EUR:20.03"),
    1702             :     /**
    1703             :      * Make a reserve exist, according to the previous transfer.
    1704             :      */
    1705           2 :     cmd_exec_wirewatch ("wirewatch-1"),
    1706           2 :     TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-tokens",
    1707             :                                                  "EUR:20.03",
    1708             :                                                  payer_payto,
    1709             :                                                  exchange_payto,
    1710             :                                                  "create-reserve-tokens"),
    1711           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
    1712             :                                        "create-reserve-tokens",
    1713             :                                        "EUR:5",
    1714             :                                        0,
    1715             :                                        MHD_HTTP_OK),
    1716           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
    1717             :                                        "create-reserve-tokens",
    1718             :                                        "EUR:5",
    1719             :                                        0,
    1720             :                                        MHD_HTTP_OK),
    1721           2 :     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-3",
    1722             :                                        "create-reserve-tokens",
    1723             :                                        "EUR:5",
    1724             :                                        0,
    1725             :                                        MHD_HTTP_OK),
    1726           6 :     TALER_TESTING_cmd_merchant_post_tokenfamilies (
    1727             :       "create-upcoming-tokenfamily",
    1728             :       merchant_url,
    1729             :       MHD_HTTP_NO_CONTENT,
    1730             :       "subscription-upcoming",
    1731             :       "Upcoming Subscription",
    1732             :       "An upcoming subscription that is not valid yet.",
    1733             :       NULL,
    1734             :       /* In one day */
    1735             :       GNUNET_TIME_absolute_to_timestamp (
    1736             :         GNUNET_TIME_absolute_add (
    1737           2 :           GNUNET_TIME_timestamp_get ().abs_time,
    1738             :           GNUNET_TIME_UNIT_DAYS)),
    1739             :       /* In a year */
    1740             :       GNUNET_TIME_absolute_to_timestamp (
    1741             :         GNUNET_TIME_absolute_add (
    1742           2 :           GNUNET_TIME_timestamp_get ().abs_time,
    1743             :           GNUNET_TIME_UNIT_YEARS)),
    1744             :       GNUNET_TIME_UNIT_MONTHS,
    1745             :       GNUNET_TIME_UNIT_MONTHS,
    1746             :       "subscription"),
    1747           2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1748             :       "create-order-with-upcoming-output",
    1749           2 :       cred.cfg,
    1750             :       merchant_url,
    1751             :       MHD_HTTP_OK,
    1752             :       "subscription-upcoming",
    1753             :       "A choice in the contract",
    1754             :       NULL,
    1755             :       0,
    1756             :       1,
    1757             :       "5-upcoming-output",
    1758           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1759           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1760             :       "EUR:5.0"),
    1761           2 :     TALER_TESTING_cmd_merchant_post_tokenfamilies (
    1762             :       "create-tokenfamily",
    1763             :       merchant_url,
    1764             :       MHD_HTTP_NO_CONTENT,
    1765             :       "subscription-1",
    1766             :       "Subscription",
    1767             :       "A subscription.",
    1768             :       NULL,
    1769           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1770             :       GNUNET_TIME_relative_to_timestamp
    1771             :         (GNUNET_TIME_UNIT_YEARS),
    1772             :       GNUNET_TIME_UNIT_MONTHS,
    1773             :       GNUNET_TIME_UNIT_MONTHS,
    1774             :       "subscription"),
    1775           2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1776             :       "create-order-with-output",
    1777           2 :       cred.cfg,
    1778             :       merchant_url,
    1779             :       MHD_HTTP_OK,
    1780             :       "subscription-1",
    1781             :       "A choice in the contract",
    1782             :       NULL,
    1783             :       0,
    1784             :       1,
    1785             :       "5-output",
    1786           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1787           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1788             :       "EUR:5.0"),
    1789           2 :     TALER_TESTING_cmd_merchant_pay_order_choices (
    1790             :       "pay-order-with-output",
    1791             :       merchant_url,
    1792             :       MHD_HTTP_OK,
    1793             :       "create-order-with-output",
    1794             :       "withdraw-coin-1",
    1795             :       "EUR:5",
    1796             :       "EUR:4.99",
    1797             :       NULL,
    1798             :       0,
    1799             :       NULL),
    1800           2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1801             :       "create-order-with-input-and-output",
    1802           2 :       cred.cfg,
    1803             :       merchant_url,
    1804             :       MHD_HTTP_OK,
    1805             :       "subscription-1",
    1806             :       "A choice in the contract",
    1807             :       NULL,
    1808             :       1,
    1809             :       1,
    1810             :       "5-input-output",
    1811           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1812           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1813             :       "EUR:0.0"),
    1814           2 :     TALER_TESTING_cmd_merchant_pay_order_choices (
    1815             :       "pay-order-with-input-and-output",
    1816             :       merchant_url,
    1817             :       MHD_HTTP_OK,
    1818             :       "create-order-with-input-and-output",
    1819             :       "",
    1820             :       "EUR:0",
    1821             :       "EUR:0",
    1822             :       NULL,
    1823             :       0,
    1824             :       "pay-order-with-output"),
    1825             :     // TALER_TESTING_cmd_merchant_pay_order_choices ("idempotent-pay-order-with-input-and-output",
    1826             :     //                                               merchant_url,
    1827             :     //                                               MHD_HTTP_OK,
    1828             :     //                                               "create-order-with-input-and-output",
    1829             :     //                                               "",
    1830             :     //                                               "EUR:0",
    1831             :     //                                               "EUR:0",
    1832             :     //                                               NULL,
    1833             :     //                                               0,
    1834             :     //                                               "pay-order-with-output"),
    1835           2 :     TALER_TESTING_cmd_merchant_post_orders_choices (
    1836             :       "create-another-order-with-input-and-output",
    1837           2 :       cred.cfg,
    1838             :       merchant_url,
    1839             :       MHD_HTTP_OK,
    1840             :       "subscription-1",
    1841             :       "A choice in the contract",
    1842             :       NULL,
    1843             :       1,
    1844             :       1,
    1845             :       "5-input-output-2",
    1846           2 :       GNUNET_TIME_UNIT_ZERO_TS,
    1847           2 :       GNUNET_TIME_UNIT_FOREVER_TS,
    1848             :       "EUR:0.0"),
    1849           2 :     TALER_TESTING_cmd_merchant_pay_order_choices ("double-spend-token",
    1850             :                                                   merchant_url,
    1851             :                                                   MHD_HTTP_CONFLICT,
    1852             :                                                   "create-another-order-with-input-and-output",
    1853             :                                                   "",
    1854             :                                                   "EUR:0",
    1855             :                                                   "EUR:0",
    1856             :                                                   NULL,
    1857             :                                                   0,
    1858             :                                                   "pay-order-with-output"),
    1859           2 :     TALER_TESTING_cmd_end ()
    1860             :   };
    1861             : 
    1862             :   #ifdef HAVE_DONAU_DONAU_SERVICE_H
    1863             :   const struct DONAU_BearerToken bearer = {
    1864             :     .token = NULL
    1865             :   };
    1866             : 
    1867             :   struct TALER_TESTING_Command donau[] = {
    1868             :     TALER_TESTING_cmd_set_var (
    1869             :       "donau",
    1870             :       TALER_TESTING_cmd_get_donau ("get-donau",
    1871             :                                    cred.cfg,
    1872             :                                    true)),
    1873             :     TALER_TESTING_cmd_charity_post_merchant ("post-charity",
    1874             :                                              "example",
    1875             :                                              "example.com",
    1876             :                                              "EUR:50", // max_per_year
    1877             :                                              "EUR:0", // receipts_to_date
    1878             :                                              2025, // current year
    1879             :                                              &bearer,
    1880             :                                              "create-another-order-with-input-and-output",
    1881             :                                              // reusing the merchant_reference for merchant_pub
    1882             :                                              MHD_HTTP_CREATED),
    1883             :     TALER_TESTING_cmd_merchant_post_donau_instance (
    1884             :       "post-donau-instance",
    1885             :       merchant_url,
    1886             :       "create-another-order-with-input-and-output", // reusing the merchant_reference
    1887             :       MHD_HTTP_NO_CONTENT),
    1888             :     TALER_TESTING_cmd_sleep (
    1889             :       "In this time donaukeyupdate must fetch the keys from the donau",
    1890             :       1),
    1891             :     TALER_TESTING_cmd_merchant_get_donau_instances (
    1892             :       "get-donau-instance",
    1893             :       merchant_url,
    1894             :       1,
    1895             :       MHD_HTTP_OK),
    1896             :     TALER_TESTING_cmd_merchant_post_orders_donau (
    1897             :       "create-donau-order",
    1898             :       cred.cfg,
    1899             :       merchant_url,
    1900             :       MHD_HTTP_OK,
    1901             :       "donau",
    1902             :       GNUNET_TIME_UNIT_ZERO_TS,
    1903             :       GNUNET_TIME_UNIT_FOREVER_TS,
    1904             :       "EUR:1"),
    1905             :     TALER_TESTING_cmd_merchant_pay_order_donau (
    1906             :       "pay-donau-order",
    1907             :       merchant_url,
    1908             :       MHD_HTTP_OK,
    1909             :       "create-donau-order",
    1910             :       "withdraw-coin-3",
    1911             :       "EUR:1", /* full amount */
    1912             :       "EUR:0.99", /* amount without fees */
    1913             :       "EUR:1", /* donation amount */
    1914             :       NULL,
    1915             :       0,
    1916             :       "post-charity",
    1917             :       2025,
    1918             :       "7560001010000",
    1919             :       "1234"
    1920             :       ),
    1921             :     TALER_TESTING_cmd_merchant_delete_donau_instance (
    1922             :       "delete-donau-instance",
    1923             :       merchant_url,
    1924             :       1,
    1925             :       MHD_HTTP_NO_CONTENT),
    1926             :     TALER_TESTING_cmd_merchant_get_donau_instances (
    1927             :       "get-donau-instances-after-delete",
    1928             :       merchant_url,
    1929             :       0,
    1930             :       MHD_HTTP_OK),
    1931             :     TALER_TESTING_cmd_end ()
    1932             :   };
    1933             :   #endif
    1934             : 
    1935             :   struct TALER_TESTING_Command commands[] = {
    1936             :     /* general setup */
    1937           2 :     TALER_TESTING_cmd_run_fakebank (
    1938             :       "run-fakebank",
    1939           2 :       cred.cfg,
    1940             :       "exchange-account-exchange"),
    1941             :     #ifdef HAVE_DONAU_DONAU_SERVICE_H
    1942             :     TALER_TESTING_cmd_system_start (
    1943             :       "start-taler",
    1944             :       config_file,
    1945             :       "-emaDZ",
    1946             :       "-u", "exchange-account-exchange",
    1947             :       "-r", "merchant-exchange-test",
    1948             :       NULL),
    1949             :     #else
    1950           2 :     TALER_TESTING_cmd_system_start (
    1951             :       "start-taler",
    1952             :       config_file,
    1953             :       "-ema",
    1954             :       "-u", "exchange-account-exchange",
    1955             :       "-r", "merchant-exchange-test",
    1956             :       NULL),
    1957             :     #endif
    1958           2 :     TALER_TESTING_cmd_get_exchange (
    1959             :       "get-exchange",
    1960           2 :       cred.cfg,
    1961             :       NULL,
    1962             :       true,
    1963             :       true),
    1964           2 :     TALER_TESTING_cmd_batch (
    1965             :       "orders-id",
    1966             :       get_private_order_id),
    1967           2 :     TALER_TESTING_cmd_config (
    1968             :       "config",
    1969             :       merchant_url,
    1970             :       MHD_HTTP_OK),
    1971           2 :     TALER_TESTING_cmd_merchant_get_instances (
    1972             :       "instances-empty",
    1973             :       merchant_url,
    1974             :       MHD_HTTP_OK,
    1975             :       NULL),
    1976           2 :     TALER_TESTING_cmd_merchant_post_instances (
    1977             :       "instance-create-default-setup",
    1978             :       merchant_url,
    1979             :       "admin",
    1980             :       MHD_HTTP_NO_CONTENT),
    1981           2 :     TALER_TESTING_cmd_merchant_post_account (
    1982             :       "instance-create-default-account",
    1983             :       merchant_url,
    1984             :       merchant_payto,
    1985             :       NULL, NULL,
    1986             :       MHD_HTTP_OK),
    1987           2 :     TALER_TESTING_cmd_merchant_post_instances (
    1988             :       "instance-create-i1",
    1989             :       merchant_url,
    1990             :       "i1",
    1991             :       MHD_HTTP_NO_CONTENT),
    1992           2 :     TALER_TESTING_cmd_merchant_get_instances (
    1993             :       "instances-get-i1",
    1994             :       merchant_url,
    1995             :       MHD_HTTP_OK,
    1996             :       "instance-create-i1",
    1997             :       "instance-create-default-setup",
    1998             :       NULL),
    1999           2 :     TALER_TESTING_cmd_merchant_get_instance (
    2000             :       "instances-get-i1",
    2001             :       merchant_url,
    2002             :       "i1",
    2003             :       MHD_HTTP_OK,
    2004             :       "instance-create-i1"),
    2005           2 :     TALER_TESTING_cmd_merchant_patch_instance (
    2006             :       "instance-patch-i1",
    2007             :       merchant_url,
    2008             :       "i1",
    2009             :       "bob-the-merchant",
    2010             :       json_pack ("{s:s}",
    2011             :                  "street",
    2012             :                  "bobstreet"),
    2013             :       json_pack ("{s:s}",
    2014             :                  "street",
    2015             :                  "bobjuryst"),
    2016             :       true,
    2017             :       GNUNET_TIME_UNIT_MINUTES,
    2018             :       GNUNET_TIME_UNIT_MINUTES,
    2019             :       MHD_HTTP_NO_CONTENT),
    2020           2 :     TALER_TESTING_cmd_merchant_get_instance (
    2021             :       "instances-get-i1-2",
    2022             :       merchant_url,
    2023             :       "i1",
    2024             :       MHD_HTTP_OK,
    2025             :       "instance-patch-i1"),
    2026           2 :     TALER_TESTING_cmd_merchant_get_instance (
    2027             :       "instances-get-i2-nx",
    2028             :       merchant_url,
    2029             :       "i2",
    2030             :       MHD_HTTP_NOT_FOUND,
    2031             :       NULL),
    2032           2 :     TALER_TESTING_cmd_merchant_post_instances2 (
    2033             :       "instance-create-ACL",
    2034             :       merchant_url,
    2035             :       "i-acl",
    2036             :       "controlled instance",
    2037             :       json_pack ("{s:s}", "city",
    2038             :                  "shopcity"),
    2039             :       json_pack ("{s:s}", "city",
    2040             :                  "lawyercity"),
    2041             :       true,
    2042             :       GNUNET_TIME_UNIT_MINUTES,
    2043             :       GNUNET_TIME_UNIT_MINUTES,
    2044             :       // FIXME: change this back once
    2045             :       // we have a update auth test CMD
    2046             :       // RFC_8959_PREFIX "EXAMPLE",
    2047             :       NULL,
    2048             :       MHD_HTTP_NO_CONTENT),
    2049           2 :     TALER_TESTING_cmd_merchant_patch_instance (
    2050             :       "instance-patch-ACL",
    2051             :       merchant_url,
    2052             :       "i-acl",
    2053             :       "controlled instance",
    2054             :       json_pack ("{s:s}",
    2055             :                  "street",
    2056             :                  "bobstreet"),
    2057             :       json_pack ("{s:s}",
    2058             :                  "street",
    2059             :                  "bobjuryst"),
    2060             :       true,
    2061             :       GNUNET_TIME_UNIT_MINUTES,
    2062             :       GNUNET_TIME_UNIT_MINUTES,
    2063             :       MHD_HTTP_NO_CONTENT),
    2064           2 :     TALER_TESTING_cmd_merchant_post_instances (
    2065             :       "instance-create-i2",
    2066             :       merchant_url,
    2067             :       "i2",
    2068             :       MHD_HTTP_NO_CONTENT),
    2069           2 :     TALER_TESTING_cmd_merchant_post_instances (
    2070             :       "instance-create-i2-idem",
    2071             :       merchant_url,
    2072             :       "i2",
    2073             :       MHD_HTTP_NO_CONTENT),
    2074           2 :     TALER_TESTING_cmd_merchant_delete_instance (
    2075             :       "instance-delete-i2",
    2076             :       merchant_url,
    2077             :       "i2",
    2078             :       MHD_HTTP_NO_CONTENT),
    2079           2 :     TALER_TESTING_cmd_merchant_get_instance (
    2080             :       "instances-get-i2-post-deletion",
    2081             :       merchant_url,
    2082             :       "i2",
    2083             :       MHD_HTTP_NOT_FOUND,
    2084             :       NULL),
    2085           2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2086             :       "instance-delete-then-purge-i2",
    2087             :       merchant_url,
    2088             :       "i2",
    2089             :       MHD_HTTP_NO_CONTENT),
    2090           2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2091             :       "instance-purge-i1",
    2092             :       merchant_url,
    2093             :       "i1",
    2094             :       MHD_HTTP_NO_CONTENT),
    2095           2 :     TALER_TESTING_cmd_merchant_delete_instance (
    2096             :       "instance-purge-then-delete-i1",
    2097             :       merchant_url,
    2098             :       "i1",
    2099             :       MHD_HTTP_NOT_FOUND),
    2100           2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2101             :       "instance-purge-i-acl-middle",
    2102             :       merchant_url,
    2103             :       "i-acl",
    2104             :       MHD_HTTP_NO_CONTENT),
    2105           2 :     TALER_TESTING_cmd_merchant_purge_instance (
    2106             :       "instance-purge-default-middle",
    2107             :       merchant_url,
    2108             :       "admin",
    2109             :       MHD_HTTP_NO_CONTENT),
    2110           2 :     TALER_TESTING_cmd_merchant_post_instances (
    2111             :       "instance-create-default-after-purge",
    2112             :       merchant_url,
    2113             :       "admin",
    2114             :       MHD_HTTP_NO_CONTENT),
    2115           2 :     TALER_TESTING_cmd_merchant_post_account (
    2116             :       "instance-create-default-account-after-purge",
    2117             :       merchant_url,
    2118             :       merchant_payto,
    2119             :       NULL, NULL,
    2120             :       MHD_HTTP_OK),
    2121           2 :     TALER_TESTING_cmd_merchant_get_products (
    2122             :       "get-products-empty",
    2123             :       merchant_url,
    2124             :       MHD_HTTP_OK,
    2125             :       NULL),
    2126           2 :     TALER_TESTING_cmd_merchant_post_products (
    2127             :       "post-products-p1",
    2128             :       merchant_url,
    2129             :       "product-1",
    2130             :       "a product",
    2131             :       "EUR:1",
    2132             :       MHD_HTTP_NO_CONTENT),
    2133           2 :     TALER_TESTING_cmd_merchant_post_products (
    2134             :       "post-products-p1-idem",
    2135             :       merchant_url,
    2136             :       "product-1",
    2137             :       "a product",
    2138             :       "EUR:1",
    2139             :       MHD_HTTP_NO_CONTENT),
    2140           2 :     TALER_TESTING_cmd_merchant_post_products (
    2141             :       "post-products-p1-non-idem",
    2142             :       merchant_url,
    2143             :       "product-1",
    2144             :       "a different product",
    2145             :       "EUR:1",
    2146             :       MHD_HTTP_CONFLICT),
    2147           2 :     TALER_TESTING_cmd_merchant_get_products (
    2148             :       "get-products-p1",
    2149             :       merchant_url,
    2150             :       MHD_HTTP_OK,
    2151             :       "post-products-p1",
    2152             :       NULL),
    2153           2 :     TALER_TESTING_cmd_merchant_get_product (
    2154             :       "get-product-p1",
    2155             :       merchant_url,
    2156             :       "product-1",
    2157             :       MHD_HTTP_OK,
    2158             :       "post-products-p1"),
    2159           2 :     TALER_TESTING_cmd_merchant_post_products (
    2160             :       "post-products-p2",
    2161             :       merchant_url,
    2162             :       "product-2",
    2163             :       "a product",
    2164             :       "EUR:1",
    2165             :       MHD_HTTP_NO_CONTENT),
    2166           2 :     TALER_TESTING_cmd_merchant_patch_product (
    2167             :       "patch-products-p2",
    2168             :       merchant_url,
    2169             :       "product-2",
    2170             :       "another product",
    2171             :       json_pack ("{s:s}", "en", "text"),
    2172             :       "kg",
    2173             :       "EUR:1",
    2174             :       "data:image/jpeg;base64,RAWDATA",
    2175             :       json_array (),
    2176             :       40,
    2177             :       0,
    2178             :       json_pack ("{s:s}",
    2179             :                  "street",
    2180             :                  "pstreet"),
    2181             :       GNUNET_TIME_relative_to_timestamp (
    2182             :         GNUNET_TIME_UNIT_MINUTES),
    2183             :       MHD_HTTP_NO_CONTENT),
    2184           2 :     TALER_TESTING_cmd_merchant_get_product (
    2185             :       "get-product-p2",
    2186             :       merchant_url,
    2187             :       "product-2",
    2188             :       MHD_HTTP_OK,
    2189             :       "patch-products-p2"),
    2190           2 :     TALER_TESTING_cmd_merchant_get_product (
    2191             :       "get-product-nx",
    2192             :       merchant_url,
    2193             :       "product-nx",
    2194             :       MHD_HTTP_NOT_FOUND,
    2195             :       NULL),
    2196           2 :     TALER_TESTING_cmd_merchant_patch_product (
    2197             :       "patch-products-p3-nx",
    2198             :       merchant_url,
    2199             :       "product-3",
    2200             :       "nx updated 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_NOT_FOUND),
    2214           2 :     TALER_TESTING_cmd_merchant_delete_product (
    2215             :       "get-products-empty",
    2216             :       merchant_url,
    2217             :       "p1",
    2218             :       MHD_HTTP_NOT_FOUND),
    2219           2 :     TALER_TESTING_cmd_merchant_delete_product (
    2220             :       "get-products-empty",
    2221             :       merchant_url,
    2222             :       "product-1",
    2223             :       MHD_HTTP_NO_CONTENT),
    2224           2 :     TALER_TESTING_cmd_merchant_lock_product (
    2225             :       "lock-product-p2",
    2226             :       merchant_url,
    2227             :       "product-2",
    2228             :       GNUNET_TIME_UNIT_MINUTES,
    2229             :       2,
    2230             :       MHD_HTTP_NO_CONTENT),
    2231           2 :     TALER_TESTING_cmd_merchant_lock_product (
    2232             :       "lock-product-nx",
    2233             :       merchant_url,
    2234             :       "product-nx",
    2235             :       GNUNET_TIME_UNIT_MINUTES,
    2236             :       2,
    2237             :       MHD_HTTP_NOT_FOUND),
    2238           2 :     TALER_TESTING_cmd_merchant_lock_product (
    2239             :       "lock-product-too-much",
    2240             :       merchant_url,
    2241             :       "product-2",
    2242             :       GNUNET_TIME_UNIT_MINUTES,
    2243             :       39,
    2244             :       MHD_HTTP_GONE),
    2245           2 :     TALER_TESTING_cmd_merchant_delete_product (
    2246             :       "delete-product-locked",
    2247             :       merchant_url,
    2248             :       "product-2",
    2249             :       MHD_HTTP_CONFLICT),
    2250           2 :     TALER_TESTING_cmd_batch ("pay",
    2251             :                              pay),
    2252           2 :     TALER_TESTING_cmd_batch ("double-spending",
    2253             :                              double_spending),
    2254           2 :     TALER_TESTING_cmd_batch ("pay-again",
    2255             :                              pay_again),
    2256           2 :     TALER_TESTING_cmd_batch ("pay-abort",
    2257             :                              pay_abort),
    2258           2 :     TALER_TESTING_cmd_batch ("refund",
    2259             :                              refund),
    2260           2 :     TALER_TESTING_cmd_batch ("templates",
    2261             :                              templates),
    2262           2 :     TALER_TESTING_cmd_batch ("webhooks",
    2263             :                              webhooks),
    2264           2 :     TALER_TESTING_cmd_batch ("auth",
    2265             :                              auth),
    2266           2 :     TALER_TESTING_cmd_batch ("repurchase",
    2267             :                              repurchase),
    2268           2 :     TALER_TESTING_cmd_batch ("tokens",
    2269             :                              tokens),
    2270             : 
    2271             :     #ifdef HAVE_DONAU_DONAU_SERVICE_H
    2272             :     TALER_TESTING_cmd_batch ("donau",
    2273             :                              donau),
    2274             :     #endif
    2275             : 
    2276           2 :     TALER_TESTING_cmd_merchant_get_statisticsamount ("stats-refund",
    2277             :                                                      merchant_url,
    2278             :                                                      "refunds-granted", 6, 0,
    2279             :                                                      MHD_HTTP_OK),
    2280           2 :     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-issued",
    2281             :                                                       merchant_url,
    2282             :                                                       "tokens-issued", 6, 0,
    2283             :                                                       MHD_HTTP_OK),
    2284           2 :     TALER_TESTING_cmd_merchant_get_statisticscounter ("stats-tokens-used",
    2285             :                                                       merchant_url,
    2286             :                                                       "tokens-used", 6, 0,
    2287             :                                                       MHD_HTTP_OK),
    2288             : 
    2289             :     /**
    2290             :      * End the suite.
    2291             :      */
    2292           2 :     TALER_TESTING_cmd_end ()
    2293             :   };
    2294             : 
    2295           2 :   TALER_TESTING_run (is,
    2296             :                      commands);
    2297           2 : }
    2298             : 
    2299             : 
    2300             : int
    2301           2 : main (int argc,
    2302             :       char *const *argv)
    2303             : {
    2304             :   {
    2305             :     char *cipher;
    2306             : 
    2307           2 :     cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
    2308           2 :     GNUNET_assert (NULL != cipher);
    2309           2 :     GNUNET_asprintf (&config_file,
    2310             :                      "test_merchant_api-%s.conf",
    2311             :                      cipher);
    2312           2 :     GNUNET_free (cipher);
    2313             :   }
    2314           2 :   payer_payto.full_payto =
    2315             :     (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME
    2316             :     "?receiver-name=" USER_ACCOUNT_NAME;
    2317           2 :   exchange_payto.full_payto =
    2318             :     (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
    2319             :     "?receiver-name="
    2320             :     EXCHANGE_ACCOUNT_NAME;
    2321           2 :   merchant_payto.full_payto =
    2322             :     (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
    2323             :     "?receiver-name=" MERCHANT_ACCOUNT_NAME;
    2324           2 :   merchant_url = "http://localhost:8080/";
    2325           2 :   GNUNET_asprintf (&merchant_url_i1a,
    2326             :                    "%sinstances/i1a/",
    2327             :                    merchant_url);
    2328           2 :   return TALER_TESTING_main (argv,
    2329             :                              "INFO",
    2330             :                              config_file,
    2331             :                              "exchange-account-exchange",
    2332             :                              TALER_TESTING_BS_FAKEBANK,
    2333             :                              &cred,
    2334             :                              &run,
    2335             :                              NULL);
    2336             : }
    2337             : 
    2338             : 
    2339             : /* end of test_merchant_api.c */

Generated by: LCOV version 1.16