diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-09-11 00:32:07 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-09-11 00:46:34 +0200 |
commit | 0889cedc599a0d8b2f352f30a197261c3389e70c (patch) | |
tree | 373486f923966af3f378f3e672e8c98fec2bbb43 | |
parent | 4e27be9b6cd3ada3ed920781d1b8cd0eb50b2417 (diff) | |
download | exchange-0889cedc599a0d8b2f352f30a197261c3389e70c.tar.gz exchange-0889cedc599a0d8b2f352f30a197261c3389e70c.zip |
purge old _new bank-lib test
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | src/bank-lib/Makefile.am | 19 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_NEW.c | 262 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_new.c | 283 |
4 files changed, 169 insertions, 397 deletions
diff --git a/.gitignore b/.gitignore index a16392663..c472f73fa 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -40,6 +40,8 @@ src/bank-lib/taler-fakebank-run | |||
40 | src/bank-lib/test_bank_api | 40 | src/bank-lib/test_bank_api |
41 | src/bank-lib/test_bank_api_with_fakebank | 41 | src/bank-lib/test_bank_api_with_fakebank |
42 | src/bank-lib/test_bank_api_with_fakebank_twisted | 42 | src/bank-lib/test_bank_api_with_fakebank_twisted |
43 | src/bank-lib/test_bank_api_with_pybank_new | ||
44 | src/bank-lib/test_bank_api_with_pybank_twisted | ||
43 | src/lib/test_exchange_api | 45 | src/lib/test_exchange_api |
44 | src/lib/test_exchange_api_keys_cherry_picking_home/.local/share/taler/exchange/live-keys/ | 46 | src/lib/test_exchange_api_keys_cherry_picking_home/.local/share/taler/exchange/live-keys/ |
45 | src/lib/test_exchange_api_keys_cherry_picking_home/.local/share/taler/exchange/wirefees/ | 47 | src/lib/test_exchange_api_keys_cherry_picking_home/.local/share/taler/exchange/wirefees/ |
diff --git a/src/bank-lib/Makefile.am b/src/bank-lib/Makefile.am index 8b5d59a6e..50bf32abd 100644 --- a/src/bank-lib/Makefile.am +++ b/src/bank-lib/Makefile.am | |||
@@ -108,7 +108,7 @@ check_PROGRAMS += \ | |||
108 | 108 | ||
109 | 109 | ||
110 | test_bank_api_with_pybank_twisted_SOURCES = \ | 110 | test_bank_api_with_pybank_twisted_SOURCES = \ |
111 | test_bank_api_twisted_NEW.c | 111 | test_bank_api_twisted_new.c |
112 | test_bank_api_with_pybank_twisted_LDADD = \ | 112 | test_bank_api_with_pybank_twisted_LDADD = \ |
113 | $(top_builddir)/src/lib/libtalertesting.la \ | 113 | $(top_builddir)/src/lib/libtalertesting.la \ |
114 | libtalerbank.la \ | 114 | libtalerbank.la \ |
@@ -124,7 +124,7 @@ test_bank_api_with_pybank_twisted_LDADD = \ | |||
124 | 124 | ||
125 | 125 | ||
126 | test_bank_api_with_fakebank_twisted_SOURCES = \ | 126 | test_bank_api_with_fakebank_twisted_SOURCES = \ |
127 | test_bank_api_twisted_NEW.c | 127 | test_bank_api_twisted_new.c |
128 | test_bank_api_with_fakebank_twisted_LDADD = \ | 128 | test_bank_api_with_fakebank_twisted_LDADD = \ |
129 | $(top_builddir)/src/lib/libtalertesting.la \ | 129 | $(top_builddir)/src/lib/libtalertesting.la \ |
130 | libtalerbank.la \ | 130 | libtalerbank.la \ |
@@ -153,17 +153,6 @@ test_bank_api_LDADD = \ | |||
153 | -lgnunetutil \ | 153 | -lgnunetutil \ |
154 | -ljansson | 154 | -ljansson |
155 | 155 | ||
156 | test_bank_api_new_SOURCES = \ | ||
157 | test_bank_api_new.c | ||
158 | |||
159 | test_bank_api_new_LDADD = \ | ||
160 | $(top_builddir)/src/lib/libtalertesting.la \ | ||
161 | $(top_builddir)/src/json/libtalerjson.la \ | ||
162 | libtalerbanktesting.la \ | ||
163 | -ltalerexchange \ | ||
164 | -lgnunetutil \ | ||
165 | libtalerbank.la | ||
166 | |||
167 | test_bank_api_with_fakebank_SOURCES = \ | 156 | test_bank_api_with_fakebank_SOURCES = \ |
168 | test_bank_interpreter.c test_bank_interpreter.h \ | 157 | test_bank_interpreter.c test_bank_interpreter.h \ |
169 | test_bank_api_with_fakebank.c | 158 | test_bank_api_with_fakebank.c |
@@ -176,7 +165,7 @@ test_bank_api_with_fakebank_LDADD = \ | |||
176 | -ljansson | 165 | -ljansson |
177 | 166 | ||
178 | test_bank_api_with_pybank_new_SOURCES = \ | 167 | test_bank_api_with_pybank_new_SOURCES = \ |
179 | test_bank_api_NEW.c | 168 | test_bank_api_new.c |
180 | 169 | ||
181 | test_bank_api_with_pybank_new_LDADD = \ | 170 | test_bank_api_with_pybank_new_LDADD = \ |
182 | $(top_builddir)/src/lib/libtalertesting.la \ | 171 | $(top_builddir)/src/lib/libtalertesting.la \ |
@@ -186,7 +175,7 @@ test_bank_api_with_pybank_new_LDADD = \ | |||
186 | libtalerbank.la | 175 | libtalerbank.la |
187 | 176 | ||
188 | test_bank_api_with_fakebank_new_SOURCES = \ | 177 | test_bank_api_with_fakebank_new_SOURCES = \ |
189 | test_bank_api_NEW.c | 178 | test_bank_api_new.c |
190 | 179 | ||
191 | test_bank_api_with_fakebank_new_LDADD = \ | 180 | test_bank_api_with_fakebank_new_LDADD = \ |
192 | $(top_builddir)/src/lib/libtalertesting.la \ | 181 | $(top_builddir)/src/lib/libtalertesting.la \ |
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 */ | ||
diff --git a/src/bank-lib/test_bank_api_new.c b/src/bank-lib/test_bank_api_new.c index 17acac9bc..5c7920b76 100644 --- a/src/bank-lib/test_bank_api_new.c +++ b/src/bank-lib/test_bank_api_new.c | |||
@@ -3,14 +3,14 @@ | |||
3 | Copyright (C) 2016, 2017 GNUnet e.V. | 3 | Copyright (C) 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify | 5 | TALER is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | published by the Free Software Foundation; either version 3, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | TALER is distributed in the hope that it will be useful, but | 10 | TALER is distributed in the hope that it will be useful, |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public | 15 | You should have received a copy of the GNU General Public |
16 | License along with TALER; see the file COPYING. If not, | 16 | License along with TALER; see the file COPYING. If not, |
@@ -18,61 +18,43 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * @file bank/test_bank_api_new.c | 21 | * @file bank/test_bank_api_with_fakebank.c |
22 | * @brief testcase to test bank's HTTP API | 22 | * @brief testcase to test bank's HTTP API |
23 | * interface against the "real" bank | 23 | * interface against the fakebank |
24 | * @author Christian Grothoff | ||
25 | * @author Marcello Stanisci | 24 | * @author Marcello Stanisci |
25 | * @author Christian Grothoff | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "taler_util.h" | 29 | #include "taler_util.h" |
30 | #include "taler_signatures.h" | 30 | #include "taler_signatures.h" |
31 | #include "taler_bank_service.h" | 31 | #include "taler_bank_service.h" |
32 | #include "taler_exchange_service.h" | ||
32 | #include <gnunet/gnunet_util_lib.h> | 33 | #include <gnunet/gnunet_util_lib.h> |
33 | #include <gnunet/gnunet_curl_lib.h> | 34 | #include <gnunet/gnunet_curl_lib.h> |
34 | #include <microhttpd.h> | 35 | #include <microhttpd.h> |
35 | #include "taler_exchange_service.h" | ||
36 | #include "test_bank_interpreter.h" | 36 | #include "test_bank_interpreter.h" |
37 | #include "taler_testing_lib.h" | 37 | #include "taler_testing_lib.h" |
38 | #include "taler_testing_bank_lib.h" | 38 | #include "taler_testing_bank_lib.h" |
39 | 39 | ||
40 | |||
40 | #define CONFIG_FILE "bank.conf" | 41 | #define CONFIG_FILE "bank.conf" |
41 | 42 | ||
42 | /** | 43 | /** |
43 | * Add seconds. | 44 | * Fakebank URL. |
44 | * | ||
45 | * @param base absolute time to add seconds to. | ||
46 | * @param relative number of seconds to add. | ||
47 | * @return a new absolute time, modified according to @e relative. | ||
48 | */ | ||
49 | #define ADDSECS(base, secs) \ | ||
50 | GNUNET_TIME_absolute_add \ | ||
51 | (base, \ | ||
52 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ | ||
53 | secs)) | ||
54 | /** | ||
55 | * Subtract seconds. | ||
56 | * | ||
57 | * @param base absolute time to subtract seconds to. | ||
58 | * @param secs relative number of _seconds_ to subtract. | ||
59 | * @return a new absolute time, modified according to @e relative. | ||
60 | */ | 45 | */ |
61 | #define SUBSECS(base, secs) \ | 46 | static char *bank_url; |
62 | GNUNET_TIME_absolute_subtract \ | 47 | |
63 | (base, \ | ||
64 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ | ||
65 | secs)) | ||
66 | /** | 48 | /** |
67 | * Bank process. | 49 | * Handle to the Py-bank daemon. |
68 | */ | 50 | */ |
69 | struct GNUNET_OS_Process *bankd; | 51 | static struct GNUNET_OS_Process *bankd; |
70 | 52 | ||
71 | /** | 53 | /** |
72 | * Bank URL. | 54 | * Flag indicating whether the test is running against the |
55 | * Fakebank. Set up at runtime. | ||
73 | */ | 56 | */ |
74 | char *bank_url; | 57 | static int WITH_FAKEBANK; |
75 | |||
76 | 58 | ||
77 | /** | 59 | /** |
78 | * Main function that will tell the interpreter what commands to | 60 | * Main function that will tell the interpreter what commands to |
@@ -84,91 +66,120 @@ static void | |||
84 | run (void *cls, | 66 | run (void *cls, |
85 | struct TALER_TESTING_Interpreter *is) | 67 | struct TALER_TESTING_Interpreter *is) |
86 | { | 68 | { |
69 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
70 | "Bank serves at `%s'\n", | ||
71 | bank_url); | ||
87 | extern struct TALER_BANK_AuthenticationData AUTHS[]; | 72 | extern struct TALER_BANK_AuthenticationData AUTHS[]; |
88 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 73 | |
89 | struct TALER_TESTING_Command commands[] = { | 74 | struct TALER_TESTING_Command commands[] = { |
75 | |||
90 | TALER_TESTING_cmd_bank_history ("history-0", | 76 | TALER_TESTING_cmd_bank_history ("history-0", |
91 | bank_url, | 77 | bank_url, |
92 | EXCHANGE_ACCOUNT_NUMBER, | 78 | BANK_ACCOUNT_NUMBER, |
93 | TALER_BANK_DIRECTION_BOTH, | 79 | TALER_BANK_DIRECTION_BOTH, |
94 | GNUNET_NO, | 80 | GNUNET_YES, |
95 | NULL, /* start */ | 81 | NULL, |
96 | 5), | 82 | 1), |
97 | TALER_TESTING_cmd_bank_history_range_with_dates | 83 | |
98 | ("history-0-range", | 84 | /* WARNING: old API has expected http response code among |
99 | bank_url, | 85 | * the parameters, although it was always set as '200 OK' */ |
100 | EXCHANGE_ACCOUNT_NUMBER, | ||
101 | TALER_BANK_DIRECTION_BOTH, | ||
102 | GNUNET_NO, | ||
103 | SUBSECS (now, | ||
104 | 5), | ||
105 | ADDSECS (now, | ||
106 | 5)), | ||
107 | TALER_TESTING_cmd_fakebank_transfer_with_subject | ||
108 | ("deposit-1", | ||
109 | "KUDOS:5.01", | ||
110 | bank_url, | ||
111 | BANK_ACCOUNT_NUMBER, | ||
112 | EXCHANGE_ACCOUNT_NUMBER, | ||
113 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, | ||
114 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, | ||
115 | "subject 1", | ||
116 | "http://exchange.com/"), | ||
117 | /* bank gives to exchange */ | ||
118 | TALER_TESTING_cmd_fakebank_transfer_with_subject | 86 | TALER_TESTING_cmd_fakebank_transfer_with_subject |
119 | ("deposit-2", | 87 | ("debit-1", |
120 | "KUDOS:5.01", | 88 | "KUDOS:5.01", |
121 | bank_url, | 89 | bank_url, |
122 | BANK_ACCOUNT_NUMBER, | 90 | EXCHANGE_ACCOUNT_NUMBER, |
123 | EXCHANGE_ACCOUNT_NUMBER, | 91 | BANK_ACCOUNT_NUMBER, |
124 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, | 92 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, |
125 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, | 93 | AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, |
126 | "subject 2", | 94 | "subject 1", |
127 | "http://exchange.com/"), | 95 | "http://exchange.com/"), |
96 | |||
128 | TALER_TESTING_cmd_bank_history ("history-1c", | 97 | TALER_TESTING_cmd_bank_history ("history-1c", |
129 | bank_url, | 98 | bank_url, |
130 | EXCHANGE_ACCOUNT_NUMBER, | 99 | BANK_ACCOUNT_NUMBER, |
131 | TALER_BANK_DIRECTION_CREDIT, | 100 | TALER_BANK_DIRECTION_CREDIT, |
132 | GNUNET_YES, | 101 | GNUNET_YES, |
133 | NULL, | 102 | NULL, |
134 | 5), | 103 | 5), |
104 | |||
135 | TALER_TESTING_cmd_bank_history ("history-1d", | 105 | TALER_TESTING_cmd_bank_history ("history-1d", |
136 | bank_url, | 106 | bank_url, |
137 | EXCHANGE_ACCOUNT_NUMBER, | 107 | BANK_ACCOUNT_NUMBER, |
138 | TALER_BANK_DIRECTION_DEBIT, | 108 | TALER_BANK_DIRECTION_DEBIT, |
139 | GNUNET_YES, | 109 | GNUNET_YES, |
140 | NULL, | 110 | NULL, |
141 | 5), | 111 | 5), |
142 | TALER_TESTING_cmd_bank_history ("history-1dr", | 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", | ||
143 | bank_url, | 136 | bank_url, |
144 | EXCHANGE_ACCOUNT_NUMBER, | 137 | EXCHANGE_ACCOUNT_NUMBER, |
145 | TALER_BANK_DIRECTION_DEBIT, | 138 | TALER_BANK_DIRECTION_BOTH, |
146 | GNUNET_YES, | 139 | GNUNET_YES, |
147 | NULL, | 140 | NULL, |
148 | 5), | 141 | 5), |
149 | TALER_TESTING_cmd_bank_history ("history-2fwd", | 142 | |
143 | TALER_TESTING_cmd_bank_history ("history-2bi", | ||
150 | bank_url, | 144 | bank_url, |
151 | EXCHANGE_ACCOUNT_NUMBER, | 145 | EXCHANGE_ACCOUNT_NUMBER, |
152 | TALER_BANK_DIRECTION_DEBIT, | 146 | TALER_BANK_DIRECTION_BOTH, |
153 | GNUNET_YES, | 147 | GNUNET_YES, |
154 | "deposit-1", | 148 | "debit-1", |
155 | 5), | 149 | 5), |
156 | /** | 150 | |
157 | * Just check that the two transactions show up. | 151 | TALER_TESTING_cmd_fakebank_transfer_with_subject |
158 | */ | 152 | ("credit-for-reject-1", |
159 | TALER_TESTING_cmd_bank_history_range_with_dates | 153 | "KUDOS:1.01", |
160 | ("history-2-range", | 154 | bank_url, |
161 | bank_url, | 155 | BANK_ACCOUNT_NUMBER, |
162 | EXCHANGE_ACCOUNT_NUMBER, | 156 | EXCHANGE_ACCOUNT_NUMBER, |
163 | TALER_BANK_DIRECTION_BOTH, | 157 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, |
164 | GNUNET_NO, | 158 | AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, |
165 | SUBSECS (now, | 159 | "subject 3", |
166 | 50), | 160 | "http://exchange.net/"), |
167 | ADDSECS (now, | 161 | |
168 | 5)), | ||
169 | TALER_TESTING_cmd_bank_reject ("reject-1", | 162 | TALER_TESTING_cmd_bank_reject ("reject-1", |
170 | bank_url, | 163 | bank_url, |
171 | "deposit-1"), | 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 | |||
172 | /** | 183 | /** |
173 | * End the suite. Fixme: better to have a label for this | 184 | * End the suite. Fixme: better to have a label for this |
174 | * too, as it shows a "(null)" token on logs. | 185 | * too, as it shows a "(null)" token on logs. |
@@ -176,44 +187,76 @@ run (void *cls, | |||
176 | TALER_TESTING_cmd_end () | 187 | TALER_TESTING_cmd_end () |
177 | }; | 188 | }; |
178 | 189 | ||
179 | TALER_TESTING_run (is, commands); | 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); | ||
180 | } | 197 | } |
181 | 198 | ||
182 | |||
183 | /* Pacifies "make check" */ | ||
184 | int | 199 | int |
185 | main (int argc, | 200 | main (int argc, |
186 | char *const *argv) | 201 | char *const *argv) |
187 | { | 202 | { |
188 | unsigned int ret; | 203 | int rv; |
189 | /* These environment variables get in the way... */ | 204 | /* These environment variables get in the way... */ |
190 | unsetenv ("XDG_DATA_HOME"); | 205 | unsetenv ("XDG_DATA_HOME"); |
191 | unsetenv ("XDG_CONFIG_HOME"); | 206 | unsetenv ("XDG_CONFIG_HOME"); |
192 | GNUNET_log_setup ("test-bank-api-new", "DEBUG", NULL); | 207 | GNUNET_log_setup ("test-bank-api-with-(fake)bank-new", |
208 | "DEBUG", | ||
209 | NULL); | ||
193 | 210 | ||
194 | if (NULL == | 211 | WITH_FAKEBANK = TALER_TESTING_has_in_name (argv[0], |
195 | (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) | 212 | "_with_fakebank"); |
196 | return 77; | 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 | } | ||
197 | 233 | ||
198 | if (NULL == (bankd = | 234 | if (NULL == (bankd = TALER_TESTING_run_bank |
199 | TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) | 235 | (CONFIG_FILE, |
200 | return 77; | 236 | bank_url))) |
237 | { | ||
238 | GNUNET_break (0); | ||
239 | return 77; | ||
240 | } | ||
241 | } | ||
201 | 242 | ||
202 | ret = TALER_TESTING_setup (&run, | 243 | rv = (GNUNET_OK == TALER_TESTING_setup (&run, |
203 | NULL, | 244 | NULL, |
204 | CONFIG_FILE, | 245 | CONFIG_FILE, |
205 | NULL, | 246 | NULL, |
206 | GNUNET_NO); // means no exchange. | 247 | GNUNET_NO)) ? 0 : 1; |
248 | if (GNUNET_NO == WITH_FAKEBANK) | ||
249 | { | ||
207 | 250 | ||
208 | GNUNET_OS_process_kill (bankd, SIGKILL); | 251 | GNUNET_OS_process_kill (bankd, |
209 | GNUNET_OS_process_wait (bankd); | 252 | SIGKILL); |
210 | GNUNET_OS_process_destroy (bankd); | 253 | GNUNET_OS_process_wait (bankd); |
211 | GNUNET_free (bank_url); | 254 | GNUNET_OS_process_destroy (bankd); |
212 | 255 | GNUNET_free (bank_url); | |
213 | if (GNUNET_OK == ret) | 256 | } |
214 | return 0; | 257 | |
215 | 258 | return rv; | |
216 | return 1; | ||
217 | } | 259 | } |
218 | 260 | ||
219 | /* end of test_bank_api_new.c */ | 261 | |
262 | /* end of test_bank_api_with_fakebank_new.c */ | ||