]>
Commit | Line | Data |
---|---|---|
aee1def7 ML |
1 | use std::fs::File; |
2 | use std::io::BufReader; | |
3 | use std::process::Command; | |
4 | mod utils; | |
5 | ||
6 | #[test] | |
7 | fn before_queue_start_end_time_string() { | |
ef4e4370 ML |
8 | let output = Command::new("faketime") |
9 | .arg("2020-12-31 23:59:59") | |
10 | .arg(utils::log_tracker_path()) | |
aee1def7 ML |
11 | .arg("-vv") |
12 | .arg("-s") | |
13 | .arg("2020-12-18 15:00:00") | |
14 | .arg("-e") | |
15 | .arg("2020-12-18 15:40:00") | |
16 | .arg("-i") | |
17 | .arg("tests/test_input_mixed") | |
18 | .output() | |
19 | .expect("failed to execute pmg-log-tracker"); | |
20 | ||
77b430e0 FG |
21 | let expected_file = |
22 | File::open("tests/test_output_before_queue").expect("failed to open test_output"); | |
aee1def7 ML |
23 | |
24 | let expected_output = BufReader::new(&expected_file); | |
25 | let output_reader = BufReader::new(&output.stdout[..]); | |
20141d58 | 26 | utils::compare_output(output_reader, expected_output); |
aee1def7 ML |
27 | } |
28 | ||
29 | #[test] | |
30 | fn before_queue_start_end_timestamp() { | |
ef4e4370 ML |
31 | let output = Command::new("faketime") |
32 | .arg("2020-12-31 23:59:59") | |
33 | .arg(utils::log_tracker_path()) | |
aee1def7 ML |
34 | .arg("-vv") |
35 | .arg("-s") | |
36 | .arg("1608300000") | |
37 | .arg("-e") | |
38 | .arg("1608302400") | |
39 | .arg("-i") | |
40 | .arg("tests/test_input_mixed") | |
41 | .output() | |
42 | .expect("failed to execute pmg-log-tracker"); | |
43 | ||
77b430e0 FG |
44 | let expected_file = |
45 | File::open("tests/test_output_before_queue").expect("failed to open test_output"); | |
aee1def7 ML |
46 | |
47 | let expected_output = BufReader::new(&expected_file); | |
48 | let output_reader = BufReader::new(&output.stdout[..]); | |
20141d58 | 49 | utils::compare_output(output_reader, expected_output); |
aee1def7 ML |
50 | } |
51 | ||
52 | #[test] | |
53 | fn before_queue_qid() { | |
ef4e4370 ML |
54 | let output = Command::new("faketime") |
55 | .arg("2020-12-31 23:59:59") | |
56 | .arg(utils::log_tracker_path()) | |
aee1def7 ML |
57 | .arg("-vv") |
58 | .arg("-s") | |
59 | .arg("1608300000") | |
60 | .arg("-e") | |
61 | .arg("1608302400") | |
62 | .arg("-i") | |
63 | .arg("tests/test_input_mixed") | |
64 | .arg("-q") | |
65 | .arg("1C6B541C5D") | |
66 | .output() | |
67 | .expect("failed to execute pmg-log-tracker"); | |
68 | ||
77b430e0 FG |
69 | let expected_file = |
70 | File::open("tests/test_output_before_queue_qid").expect("failed to open test_output"); | |
aee1def7 ML |
71 | |
72 | let expected_output = BufReader::new(&expected_file); | |
73 | let output_reader = BufReader::new(&output.stdout[..]); | |
74 | utils::compare_output(output_reader, expected_output); | |
75 | } | |
76 | ||
77 | #[test] | |
78 | fn before_queue_host() { | |
ef4e4370 ML |
79 | let output = Command::new("faketime") |
80 | .arg("2020-12-31 23:59:59") | |
81 | .arg(utils::log_tracker_path()) | |
aee1def7 ML |
82 | .arg("-vv") |
83 | .arg("-s") | |
84 | .arg("1608300000") | |
85 | .arg("-e") | |
86 | .arg("1608302400") | |
87 | .arg("-i") | |
88 | .arg("tests/test_input_mixed") | |
89 | .arg("-h") | |
90 | .arg("localhost") | |
91 | .output() | |
92 | .expect("failed to execute pmg-log-tracker"); | |
93 | ||
77b430e0 FG |
94 | let expected_file = |
95 | File::open("tests/test_output_before_queue_host").expect("failed to open test_output"); | |
aee1def7 ML |
96 | |
97 | let expected_output = BufReader::new(&expected_file); | |
98 | let output_reader = BufReader::new(&output.stdout[..]); | |
20141d58 | 99 | utils::compare_output(output_reader, expected_output); |
aee1def7 ML |
100 | } |
101 | ||
102 | #[test] | |
103 | fn before_queue_search_string() { | |
ef4e4370 ML |
104 | let output = Command::new("faketime") |
105 | .arg("2020-12-31 23:59:59") | |
106 | .arg(utils::log_tracker_path()) | |
aee1def7 ML |
107 | .arg("-vv") |
108 | .arg("-s") | |
109 | .arg("1608300000") | |
110 | .arg("-e") | |
111 | .arg("1608302400") | |
112 | .arg("-i") | |
113 | .arg("tests/test_input_mixed") | |
114 | .arg("-x") | |
115 | .arg("reject") | |
116 | .output() | |
117 | .expect("failed to execute pmg-log-tracker"); | |
118 | ||
119 | let expected_file = File::open("tests/test_output_before_queue_search_string") | |
120 | .expect("failed to open test_output"); | |
121 | ||
122 | let expected_output = BufReader::new(&expected_file); | |
c409629f ML |
123 | let output_reader = BufReader::new(&output.stdout[..]); |
124 | utils::compare_output(output_reader, expected_output); | |
125 | } | |
126 | ||
127 | #[test] | |
128 | fn before_queue_search_string_case_insensitive() { | |
ef4e4370 ML |
129 | let output = Command::new("faketime") |
130 | .arg("2020-12-31 23:59:59") | |
131 | .arg(utils::log_tracker_path()) | |
c409629f ML |
132 | .arg("-vv") |
133 | .arg("-s") | |
134 | .arg("1608300000") | |
135 | .arg("-e") | |
136 | .arg("1608302400") | |
137 | .arg("-i") | |
138 | .arg("tests/test_input_mixed") | |
139 | .arg("-x") | |
140 | .arg("reJECT") | |
141 | .output() | |
142 | .expect("failed to execute pmg-log-tracker"); | |
143 | ||
144 | let expected_file = File::open("tests/test_output_before_queue_search_string") | |
145 | .expect("failed to open test_output"); | |
146 | ||
147 | let expected_output = BufReader::new(&expected_file); | |
aee1def7 | 148 | let output_reader = BufReader::new(&output.stdout[..]); |
20141d58 | 149 | utils::compare_output(output_reader, expected_output); |
aee1def7 | 150 | } |
85fdd484 ML |
151 | |
152 | #[test] | |
153 | fn before_queue_exclude_greylist_ndr() { | |
ef4e4370 ML |
154 | let output = Command::new("faketime") |
155 | .arg("2020-12-31 23:59:59") | |
156 | .arg(utils::log_tracker_path()) | |
85fdd484 ML |
157 | .arg("-vv") |
158 | .arg("-s") | |
159 | .arg("1608300000") | |
160 | .arg("-e") | |
161 | .arg("1608302400") | |
162 | .arg("-i") | |
163 | .arg("tests/test_input_mixed") | |
164 | .arg("-g") | |
165 | .arg("-n") | |
166 | .output() | |
167 | .expect("failed to execute pmg-log-tracker"); | |
168 | ||
77b430e0 FG |
169 | let expected_file = |
170 | File::open("tests/test_output_before_queue").expect("failed to open test_output"); | |
85fdd484 ML |
171 | |
172 | let expected_output = BufReader::new(&expected_file); | |
173 | let output_reader = BufReader::new(&output.stdout[..]); | |
20141d58 | 174 | utils::compare_output(output_reader, expected_output); |
85fdd484 | 175 | } |
093033c8 ML |
176 | |
177 | #[test] | |
178 | fn before_queue_to() { | |
ef4e4370 ML |
179 | let output = Command::new("faketime") |
180 | .arg("2020-12-31 23:59:59") | |
181 | .arg(utils::log_tracker_path()) | |
093033c8 ML |
182 | .arg("-vv") |
183 | .arg("-s") | |
184 | .arg("1608300000") | |
185 | .arg("-e") | |
186 | .arg("1608302400") | |
187 | .arg("-i") | |
188 | .arg("tests/test_input_mixed") | |
189 | .arg("-t") | |
190 | .arg("pmgtes2") | |
191 | .output() | |
192 | .expect("failed to execute pmg-log-tracker"); | |
193 | ||
77b430e0 FG |
194 | let expected_file = |
195 | File::open("tests/test_output_before_queue_to").expect("failed to open test_output"); | |
093033c8 ML |
196 | |
197 | let expected_output = BufReader::new(&expected_file); | |
198 | let output_reader = BufReader::new(&output.stdout[..]); | |
199 | utils::compare_output(output_reader, expected_output); | |
200 | } | |
d1dde9d3 SI |
201 | |
202 | #[test] | |
203 | fn before_queue_mixed_downstream() { | |
ef4e4370 ML |
204 | let output = Command::new("faketime") |
205 | .arg("2020-12-31 23:59:59") | |
206 | .arg(utils::log_tracker_path()) | |
d1dde9d3 SI |
207 | .arg("-v") |
208 | .arg("-s") | |
209 | .arg("1608303600") | |
210 | .arg("-e") | |
211 | .arg("1608304200") | |
212 | .arg("-i") | |
213 | .arg("tests/test_input_mixed") | |
214 | .output() | |
215 | .expect("failed to execute pmg-log-tracker"); | |
216 | ||
217 | let expected_file = File::open("tests/test_output_before_queue_mixed_downstream") | |
218 | .expect("failed to open test_output"); | |
219 | ||
220 | let expected_output = BufReader::new(&expected_file); | |
221 | let output_reader = BufReader::new(&output.stdout[..]); | |
222 | utils::compare_output(output_reader, expected_output); | |
223 | } | |
54a122d9 ML |
224 | |
225 | #[test] | |
226 | fn before_queue_from_to() { | |
ef4e4370 ML |
227 | let output = Command::new("faketime") |
228 | .arg("2020-12-31 23:59:59") | |
229 | .arg(utils::log_tracker_path()) | |
54a122d9 ML |
230 | .arg("-vv") |
231 | .arg("-s") | |
232 | .arg("1608300000") | |
233 | .arg("-e") | |
234 | .arg("1608302400") | |
235 | .arg("-i") | |
236 | .arg("tests/test_input_mixed") | |
237 | .arg("-f") | |
238 | .arg("mailtestsender3") | |
239 | .arg("-t") | |
240 | .arg("pmgtest") | |
241 | .output() | |
242 | .expect("failed to execute pmg-log-tracker"); | |
243 | ||
244 | let expected_file = | |
245 | File::open("tests/test_output_before_queue_from_to").expect("failed to open test_output"); | |
246 | ||
247 | let expected_output = BufReader::new(&expected_file); | |
248 | let output_reader = BufReader::new(&output.stdout[..]); | |
249 | utils::compare_output(output_reader, expected_output); | |
250 | } | |
5cce7a77 ML |
251 | |
252 | #[test] | |
253 | fn before_queue_mixed_accept_block_quarantine() { | |
ef4e4370 ML |
254 | let output = Command::new("faketime") |
255 | .arg("2020-12-31 23:59:59") | |
256 | .arg(utils::log_tracker_path()) | |
5cce7a77 ML |
257 | .arg("-vv") |
258 | .arg("-s") | |
259 | .arg("1588254000") | |
260 | .arg("-e") | |
261 | .arg("1588255200") | |
262 | .arg("-i") | |
263 | .arg("tests/test_input_mixed_accept_block_quarantine") | |
264 | .arg("-n") | |
265 | .output() | |
266 | .expect("failed to execute pmg-log-tracker"); | |
267 | ||
268 | let expected_file = File::open("tests/test_output_before_queue_mixed_accept_block_quarantine") | |
269 | .expect("failed to open test_output"); | |
270 | ||
271 | let expected_output = BufReader::new(&expected_file); | |
272 | let output_reader = BufReader::new(&output.stdout[..]); | |
273 | utils::compare_output(output_reader, expected_output); | |
274 | } | |
ff635f99 ML |
275 | |
276 | #[test] | |
277 | fn before_queue_to_search_string() { | |
ef4e4370 ML |
278 | let output = Command::new("faketime") |
279 | .arg("2020-12-31 23:59:59") | |
280 | .arg(utils::log_tracker_path()) | |
ff635f99 ML |
281 | .arg("-vv") |
282 | .arg("-s") | |
283 | .arg("1589810100") | |
284 | .arg("-e") | |
285 | .arg("1589812000") | |
286 | .arg("-i") | |
287 | .arg("tests/test_input_before_queue_to_search_string") | |
288 | .arg("-t") | |
289 | .arg("ferdl@example.proxmox.com") | |
290 | .arg("-x") | |
291 | .arg("ferdl@example.proxmox.com") | |
292 | .output() | |
293 | .expect("failed to execute pmg-log-tracker"); | |
294 | ||
295 | let expected_file = File::open("tests/test_output_before_queue_to_search_string") | |
296 | .expect("failed to open test_output"); | |
297 | ||
298 | let expected_output = BufReader::new(&expected_file); | |
299 | let output_reader = BufReader::new(&output.stdout[..]); | |
300 | utils::compare_output(output_reader, expected_output); | |
301 | } | |
dbab0bf5 ML |
302 | |
303 | #[test] | |
304 | fn before_queue_syntax_reject() { | |
ef4e4370 ML |
305 | let output = Command::new("faketime") |
306 | .arg("2020-12-31 23:59:59") | |
307 | .arg(utils::log_tracker_path()) | |
dbab0bf5 ML |
308 | .arg("-vv") |
309 | .arg("-s") | |
310 | .arg("2020-08-27 14:00:00") | |
311 | .arg("-e") | |
312 | .arg("2020-08-27 14:05:00") | |
313 | .arg("-i") | |
314 | .arg("tests/test_input_before_queue_syntax_reject") | |
315 | .output() | |
316 | .expect("failed to execute pmg-log-tracker"); | |
317 | ||
318 | let expected_file = File::open("tests/test_output_before_queue_syntax_reject") | |
319 | .expect("failed to open test_output"); | |
320 | ||
321 | let expected_output = BufReader::new(&expected_file); | |
322 | let output_reader = BufReader::new(&output.stdout[..]); | |
323 | utils::compare_output(output_reader, expected_output); | |
324 | } |