Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2026 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 testing/test_exchange_api_cs_nonce.c
21 : * @brief regression test: the exchange must sign a Clause-Schnorr
22 : * planchet only under the nonce derived from the request's
23 : * blinding seed, not under a nonce the client chose.
24 : */
25 : #include "platform.h"
26 : #include "taler/taler_util.h"
27 : #include "taler/taler_json_lib.h"
28 : #include <gnunet/gnunet_util_lib.h>
29 : #include <microhttpd.h>
30 : #include "taler/taler_bank_service.h"
31 : #include "taler/taler_testing_lib.h"
32 :
33 : /**
34 : * Configuration file we use (CS denominations only).
35 : */
36 : #define CONFIG_FILE "test_exchange_api_cs_nonce-cs.conf"
37 :
38 : /**
39 : * Credentials for the test.
40 : */
41 : static struct TALER_TESTING_Credentials cred;
42 :
43 :
44 : /**
45 : * Main function that will tell the interpreter what commands to run.
46 : *
47 : * @param cls closure
48 : * @param is interpreter we use to run commands
49 : */
50 : static void
51 1 : run (void *cls,
52 : struct TALER_TESTING_Interpreter *is)
53 : {
54 : struct TALER_TESTING_Command commands[] = {
55 1 : TALER_TESTING_cmd_run_fakebank ("run-fakebank",
56 1 : cred.cfg,
57 : "exchange-account-2"),
58 1 : TALER_TESTING_cmd_system_start ("start-taler",
59 : CONFIG_FILE,
60 : "-e",
61 : NULL),
62 1 : TALER_TESTING_cmd_get_exchange ("get-exchange",
63 1 : cred.cfg,
64 : NULL,
65 : true,
66 : true),
67 1 : TALER_TESTING_cmd_admin_add_incoming ("create-reserve",
68 : "EUR:10.02",
69 : &cred.ba,
70 : cred.user42_payto),
71 1 : TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve",
72 : "EUR:10.02",
73 : cred.user42_payto,
74 : cred.exchange_payto,
75 : "create-reserve"),
76 1 : TALER_TESTING_cmd_exec_wirewatch2 ("wirewatch",
77 : CONFIG_FILE,
78 : "exchange-account-2"),
79 : /* Control: the nonce derived from the blinding seed is accepted. */
80 1 : TALER_TESTING_cmd_withdraw_cs_nonce ("withdraw-derived-nonce",
81 : "create-reserve",
82 : "EUR:5",
83 : true),
84 : /* Fails on the current exchange, which signs under the envelope's
85 : nonce without comparing it with the derived one. */
86 1 : TALER_TESTING_cmd_withdraw_cs_nonce ("withdraw-foreign-nonce",
87 : "create-reserve",
88 : "EUR:5",
89 : false),
90 1 : TALER_TESTING_cmd_end ()
91 : };
92 :
93 : (void) cls;
94 1 : TALER_TESTING_run (is,
95 : commands);
96 1 : }
97 :
98 :
99 : int
100 1 : main (int argc,
101 : char *const *argv)
102 : {
103 : (void) argc;
104 1 : return TALER_TESTING_main (argv,
105 : "INFO",
106 : CONFIG_FILE,
107 : "exchange-account-2",
108 : TALER_TESTING_BS_FAKEBANK,
109 : &cred,
110 : &run,
111 : NULL);
112 : }
113 :
114 :
115 : /* end of test_exchange_api_cs_nonce.c */
|