diff options
Diffstat (limited to 'src/bank-lib/test_bank_api_NEW.c')
-rw-r--r-- | src/bank-lib/test_bank_api_NEW.c | 262 |
1 files changed, 0 insertions, 262 deletions
diff --git a/src/bank-lib/test_bank_api_NEW.c b/src/bank-lib/test_bank_api_NEW.c deleted file mode 100644 index 5c7920b76..000000000 --- a/src/bank-lib/test_bank_api_NEW.c +++ /dev/null | |||
@@ -1,262 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2016, 2017 GNUnet e.V. | ||
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, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | TALER is distributed in the hope that it will be useful, | ||
11 | but 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, | ||
17 | see <http://www.gnu.org/licenses/> | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file bank/test_bank_api_with_fakebank.c | ||
22 | * @brief testcase to test bank's HTTP API | ||
23 | * interface against the fakebank | ||
24 | * @author Marcello Stanisci | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include "taler_util.h" | ||
30 | #include "taler_signatures.h" | ||
31 | #include "taler_bank_service.h" | ||
32 | #include "taler_exchange_service.h" | ||
33 | #include <gnunet/gnunet_util_lib.h> | ||
34 | #include <gnunet/gnunet_curl_lib.h> | ||
35 | #include <microhttpd.h> | ||
36 | #include "test_bank_interpreter.h" | ||
37 | #include "taler_testing_lib.h" | ||
38 | #include "taler_testing_bank_lib.h" | ||
39 | |||
40 | |||
41 | #define CONFIG_FILE "bank.conf" | ||
42 | |||
43 | /** | ||
44 | * Fakebank URL. | ||
45 | */ | ||
46 | static char *bank_url; | ||
47 | |||
48 | /** | ||
49 | * Handle to the Py-bank daemon. | ||
50 | */ | ||
51 | static struct GNUNET_OS_Process *bankd; | ||
52 | |||
53 | /** | ||
54 | * Flag indicating whether the test is running against the | ||
55 | * Fakebank. Set up at runtime. | ||
56 | */ | ||
57 | static int WITH_FAKEBANK; | ||
58 | |||
59 | /** | ||
60 | * Main function that will tell the interpreter what commands to | ||
61 | * run. | ||
62 | * | ||
63 | * @param cls closure | ||
64 | */ | ||
65 | static void | ||
66 | run (void *cls, | ||
67 | struct TALER_TESTING_Interpreter *is) | ||
68 | { | ||
69 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
70 | "Bank serves at `%s'\n", | ||
71 | bank_url); | ||
72 | extern struct TALER_BANK_AuthenticationData AUTHS[]; | ||
73 | |||
74 | struct TALER_TESTING_Command commands[] = { | ||
75 | |||
76 | TALER_TESTING_cmd_bank_history ("history-0", | ||
77 | bank_url, | ||
78 | BANK_ACCOUNT_NUMBER, | ||
79 | TALER_BANK_DIRECTION_BOTH, | ||
80 | GNUNET_YES, | ||
81 | NULL, | ||
82 | 1), | ||
83 | |||
84 | /* WARNING: old API has expected http response code among | ||
85 | * the parameters, although it was always set as '200 OK' */ | ||
86 | TALER_TESTING_cmd_fakebank_transfer_with_subject | ||
87 | ("debit-1", | ||
88 | "KUDOS:5.01", | ||
89 | bank_url, | ||
90 | EXCHANGE_ACCOUNT_NUMBER, | ||
91 | BANK_ACCOUNT_NUMBER, | ||
92 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, | ||
93 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, | ||
94 | "subject 1", | ||
95 | "http://exchange.com/"), | ||
96 | |||
97 | TALER_TESTING_cmd_bank_history ("history-1c", | ||
98 | bank_url, | ||
99 | BANK_ACCOUNT_NUMBER, | ||
100 | TALER_BANK_DIRECTION_CREDIT, | ||
101 | GNUNET_YES, | ||
102 | NULL, | ||
103 | 5), | ||
104 | |||
105 | TALER_TESTING_cmd_bank_history ("history-1d", | ||
106 | bank_url, | ||
107 | BANK_ACCOUNT_NUMBER, | ||
108 | TALER_BANK_DIRECTION_DEBIT, | ||
109 | GNUNET_YES, | ||
110 | NULL, | ||
111 | 5), | ||
112 | |||
113 | TALER_TESTING_cmd_fakebank_transfer_with_subject | ||
114 | ("debit-2", | ||
115 | "KUDOS:3.21", | ||
116 | bank_url, | ||
117 | EXCHANGE_ACCOUNT_NUMBER, // debit account. | ||
118 | USER_ACCOUNT_NUMBER, | ||
119 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, | ||
120 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, | ||
121 | "subject 2", | ||
122 | "http://exchange.org/"), | ||
123 | |||
124 | TALER_TESTING_cmd_fakebank_transfer_with_subject | ||
125 | ("credit-2", | ||
126 | "KUDOS:3.22", | ||
127 | bank_url, | ||
128 | USER_ACCOUNT_NUMBER, // debit account. | ||
129 | EXCHANGE_ACCOUNT_NUMBER, | ||
130 | AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.username, | ||
131 | AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.password, | ||
132 | "credit 2", | ||
133 | "http://exchange.org/"), | ||
134 | |||
135 | TALER_TESTING_cmd_bank_history ("history-2b", | ||
136 | bank_url, | ||
137 | EXCHANGE_ACCOUNT_NUMBER, | ||
138 | TALER_BANK_DIRECTION_BOTH, | ||
139 | GNUNET_YES, | ||
140 | NULL, | ||
141 | 5), | ||
142 | |||
143 | TALER_TESTING_cmd_bank_history ("history-2bi", | ||
144 | bank_url, | ||
145 | EXCHANGE_ACCOUNT_NUMBER, | ||
146 | TALER_BANK_DIRECTION_BOTH, | ||
147 | GNUNET_YES, | ||
148 | "debit-1", | ||
149 | 5), | ||
150 | |||
151 | TALER_TESTING_cmd_fakebank_transfer_with_subject | ||
152 | ("credit-for-reject-1", | ||
153 | "KUDOS:1.01", | ||
154 | bank_url, | ||
155 | BANK_ACCOUNT_NUMBER, | ||
156 | EXCHANGE_ACCOUNT_NUMBER, | ||
157 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, | ||
158 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, | ||
159 | "subject 3", | ||
160 | "http://exchange.net/"), | ||
161 | |||
162 | TALER_TESTING_cmd_bank_reject ("reject-1", | ||
163 | bank_url, | ||
164 | "credit-for-reject-1"), | ||
165 | |||
166 | TALER_TESTING_cmd_bank_history ("history-r1", | ||
167 | bank_url, | ||
168 | BANK_ACCOUNT_NUMBER, | ||
169 | TALER_BANK_DIRECTION_BOTH, | ||
170 | GNUNET_YES, | ||
171 | NULL, | ||
172 | 5), | ||
173 | |||
174 | TALER_TESTING_cmd_bank_history ("history-r1c", | ||
175 | bank_url, | ||
176 | BANK_ACCOUNT_NUMBER, | ||
177 | TALER_BANK_DIRECTION_BOTH | ||
178 | | TALER_BANK_DIRECTION_CANCEL, | ||
179 | GNUNET_YES, | ||
180 | NULL, | ||
181 | 5), | ||
182 | |||
183 | /** | ||
184 | * End the suite. Fixme: better to have a label for this | ||
185 | * too, as it shows a "(null)" token on logs. | ||
186 | */ | ||
187 | TALER_TESTING_cmd_end () | ||
188 | }; | ||
189 | |||
190 | if (GNUNET_YES == WITH_FAKEBANK) | ||
191 | TALER_TESTING_run_with_fakebank (is, | ||
192 | commands, | ||
193 | bank_url); | ||
194 | else | ||
195 | TALER_TESTING_run (is, | ||
196 | commands); | ||
197 | } | ||
198 | |||
199 | int | ||
200 | main (int argc, | ||
201 | char *const *argv) | ||
202 | { | ||
203 | int rv; | ||
204 | /* These environment variables get in the way... */ | ||
205 | unsetenv ("XDG_DATA_HOME"); | ||
206 | unsetenv ("XDG_CONFIG_HOME"); | ||
207 | GNUNET_log_setup ("test-bank-api-with-(fake)bank-new", | ||
208 | "DEBUG", | ||
209 | NULL); | ||
210 | |||
211 | WITH_FAKEBANK = TALER_TESTING_has_in_name (argv[0], | ||
212 | "_with_fakebank"); | ||
213 | if (GNUNET_YES == WITH_FAKEBANK) | ||
214 | { | ||
215 | TALER_LOG_DEBUG ("Running against the Fakebank.\n"); | ||
216 | if (NULL == (bank_url = TALER_TESTING_prepare_fakebank | ||
217 | (CONFIG_FILE, | ||
218 | "account-1"))) | ||
219 | { | ||
220 | GNUNET_break (0); | ||
221 | return 77; | ||
222 | } | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | TALER_LOG_DEBUG ("Running against the Pybank.\n"); | ||
227 | if (NULL == (bank_url = TALER_TESTING_prepare_bank | ||
228 | (CONFIG_FILE))) | ||
229 | { | ||
230 | GNUNET_break (0); | ||
231 | return 77; | ||
232 | } | ||
233 | |||
234 | if (NULL == (bankd = TALER_TESTING_run_bank | ||
235 | (CONFIG_FILE, | ||
236 | bank_url))) | ||
237 | { | ||
238 | GNUNET_break (0); | ||
239 | return 77; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | rv = (GNUNET_OK == TALER_TESTING_setup (&run, | ||
244 | NULL, | ||
245 | CONFIG_FILE, | ||
246 | NULL, | ||
247 | GNUNET_NO)) ? 0 : 1; | ||
248 | if (GNUNET_NO == WITH_FAKEBANK) | ||
249 | { | ||
250 | |||
251 | GNUNET_OS_process_kill (bankd, | ||
252 | SIGKILL); | ||
253 | GNUNET_OS_process_wait (bankd); | ||
254 | GNUNET_OS_process_destroy (bankd); | ||
255 | GNUNET_free (bank_url); | ||
256 | } | ||
257 | |||
258 | return rv; | ||
259 | } | ||
260 | |||
261 | |||
262 | /* end of test_bank_api_with_fakebank_new.c */ | ||