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