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