Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2020-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 testing/test_exchange_management_api.c
21 : * @brief testcase to test exchange's HTTP /management/ API
22 : * @author Christian Grothoff
23 : */
24 : #include "platform.h"
25 : #include "taler_util.h"
26 : #include "taler_exchange_service.h"
27 : #include <gnunet/gnunet_util_lib.h>
28 : #include <gnunet/gnunet_testing_lib.h>
29 : #include <microhttpd.h>
30 : #include "taler_testing_lib.h"
31 :
32 : /**
33 : * Configuration file we use. One (big) configuration is used
34 : * for the various components for this test.
35 : */
36 : static char *config_file;
37 :
38 : /**
39 : * Our credentials.
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 2 : run (void *cls,
52 : struct TALER_TESTING_Interpreter *is)
53 : {
54 : struct TALER_TESTING_Command commands[] = {
55 2 : TALER_TESTING_cmd_system_start ("start-taler",
56 : config_file,
57 : "-u", "exchange-account-2",
58 : "-ae",
59 : NULL),
60 2 : TALER_TESTING_cmd_get_exchange ("get-exchange",
61 2 : cred.cfg,
62 : NULL,
63 : true,
64 : true),
65 2 : TALER_TESTING_cmd_get_auditor ("get-auditor",
66 2 : cred.cfg,
67 : true),
68 2 : TALER_TESTING_cmd_auditor_del ("del-auditor-FROM-SETUP",
69 : MHD_HTTP_NO_CONTENT,
70 : false),
71 2 : TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
72 : MHD_HTTP_FORBIDDEN,
73 : true),
74 2 : TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
75 : MHD_HTTP_NO_CONTENT,
76 : false),
77 2 : TALER_TESTING_cmd_auditor_add ("add-auditor-OK-idempotent",
78 : MHD_HTTP_NO_CONTENT,
79 : false),
80 2 : TALER_TESTING_cmd_auditor_del ("del-auditor-BAD-SIG",
81 : MHD_HTTP_FORBIDDEN,
82 : true),
83 2 : TALER_TESTING_cmd_auditor_del ("del-auditor-OK",
84 : MHD_HTTP_NO_CONTENT,
85 : false),
86 2 : TALER_TESTING_cmd_auditor_del ("del-auditor-IDEMPOTENT",
87 : MHD_HTTP_NO_CONTENT,
88 : false),
89 2 : TALER_TESTING_cmd_set_wire_fee ("set-fee",
90 : "foo-method",
91 : "EUR:1",
92 : "EUR:5",
93 : MHD_HTTP_NO_CONTENT,
94 : false),
95 2 : TALER_TESTING_cmd_set_wire_fee ("set-fee-conflicting",
96 : "foo-method",
97 : "EUR:1",
98 : "EUR:1",
99 : MHD_HTTP_CONFLICT,
100 : false),
101 2 : TALER_TESTING_cmd_set_wire_fee ("set-fee-bad-signature",
102 : "bar-method",
103 : "EUR:1",
104 : "EUR:1",
105 : MHD_HTTP_FORBIDDEN,
106 : true),
107 2 : TALER_TESTING_cmd_set_wire_fee ("set-fee-other-method",
108 : "bar-method",
109 : "EUR:1",
110 : "EUR:1",
111 : MHD_HTTP_NO_CONTENT,
112 : false),
113 2 : TALER_TESTING_cmd_set_wire_fee ("set-fee-idempotent",
114 : "bar-method",
115 : "EUR:1",
116 : "EUR:1",
117 : MHD_HTTP_NO_CONTENT,
118 : false),
119 2 : TALER_TESTING_cmd_wire_add ("add-wire-account",
120 : cred.user42_payto,
121 : MHD_HTTP_NO_CONTENT,
122 : false),
123 2 : TALER_TESTING_cmd_wire_add ("add-wire-account-idempotent",
124 : cred.user42_payto,
125 : MHD_HTTP_NO_CONTENT,
126 : false),
127 2 : TALER_TESTING_cmd_wire_add ("add-wire-account-another",
128 : cred.user43_payto,
129 : MHD_HTTP_NO_CONTENT,
130 : false),
131 2 : TALER_TESTING_cmd_wire_add ("add-wire-account-bad-signature",
132 : cred.user44_payto,
133 : MHD_HTTP_FORBIDDEN,
134 : true),
135 2 : TALER_TESTING_cmd_wire_del ("del-wire-account-not-found",
136 : cred.user44_payto,
137 : MHD_HTTP_NOT_FOUND,
138 : false),
139 2 : TALER_TESTING_cmd_wire_del ("del-wire-account-bad-signature",
140 : cred.user43_payto,
141 : MHD_HTTP_FORBIDDEN,
142 : true),
143 2 : TALER_TESTING_cmd_wire_del ("del-wire-account-ok",
144 : cred.user43_payto,
145 : MHD_HTTP_NO_CONTENT,
146 : false),
147 2 : TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",
148 : config_file),
149 2 : TALER_TESTING_cmd_get_exchange ("get-exchange-1",
150 2 : cred.cfg,
151 : "get-exchange",
152 : true,
153 : true),
154 2 : TALER_TESTING_cmd_get_exchange ("get-exchange-2",
155 2 : cred.cfg,
156 : NULL,
157 : true,
158 : true),
159 2 : TALER_TESTING_cmd_end ()
160 : };
161 :
162 : (void) cls;
163 2 : TALER_TESTING_run (is,
164 : commands);
165 2 : }
166 :
167 :
168 : int
169 2 : main (int argc,
170 : char *const *argv)
171 : {
172 : (void) argc;
173 : {
174 : char *cipher;
175 :
176 2 : cipher = GNUNET_STRINGS_get_suffix_from_binary_name (argv[0]);
177 2 : GNUNET_assert (NULL != cipher);
178 2 : GNUNET_asprintf (&config_file,
179 : "test_exchange_api-%s.conf",
180 : cipher);
181 2 : GNUNET_free (cipher);
182 : }
183 2 : return TALER_TESTING_main (argv,
184 : "INFO",
185 : config_file,
186 : "exchange-account-2",
187 : TALER_TESTING_BS_FAKEBANK,
188 : &cred,
189 : &run,
190 : NULL);
191 : }
192 :
193 :
194 : /* end of test_exchange_management_api.c */
|