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

Generated by: LCOV version 1.16