|
22 | 22 | create_items_from_yaml, |
23 | 23 | delete_items_from_yaml, |
24 | 24 | get_file_contents, |
| 25 | + get_pod_name_that_contains, |
25 | 26 | get_service_endpoint, |
26 | 27 | wait_before_test, |
27 | 28 | ) |
@@ -303,16 +304,14 @@ def test_ap_waf_policy_multi_logs( |
303 | 304 | Test waf policy logs |
304 | 305 | """ |
305 | 306 | src_syslog_yaml = f"{TEST_DATA}/ap-waf/syslog.yaml" |
306 | | - src_syslog_yaml_additional = f"{TEST_DATA}/ap-waf/syslog-1.yaml" |
| 307 | + src_syslog_yaml_additional = f"{TEST_DATA}/ap-waf/syslog2.yaml" |
307 | 308 | log_loc = f"/var/log/messages" |
308 | 309 | src_log_yaml_escape = f"{TEST_DATA}/ap-waf/logconf-esc.yaml" |
309 | 310 | log_esc_name = create_ap_logconf_from_yaml(kube_apis.custom_objects, src_log_yaml_escape, test_namespace) |
310 | 311 | create_items_from_yaml(kube_apis, src_syslog_yaml, test_namespace) |
311 | 312 | create_items_from_yaml(kube_apis, src_syslog_yaml_additional, test_namespace) |
312 | 313 | syslog_dst1 = f"syslog-svc.{test_namespace}" |
313 | | - syslog_dst2 = f"syslog-svc-1.{test_namespace}" |
314 | | - syslog_pod = kube_apis.v1.list_namespaced_pod(test_namespace, label_selector="app=syslog").items |
315 | | - syslog_esc_pod = kube_apis.v1.list_namespaced_pod(test_namespace, label_selector="app=syslog-1").items |
| 314 | + syslog_dst2 = f"syslog2-svc.{test_namespace}" |
316 | 315 | print(f"Create waf policy") |
317 | 316 | create_ap_multilog_waf_policy_from_yaml( |
318 | 317 | kube_apis.custom_objects, |
@@ -344,22 +343,22 @@ def test_ap_waf_policy_multi_logs( |
344 | 343 | headers={"host": virtual_server_setup.vs_host}, |
345 | 344 | ) |
346 | 345 | print(response.text) |
| 346 | + syslog_pod = get_pod_name_that_contains(kube_apis.v1, test_namespace, "syslog") |
| 347 | + syslog_esc_pod = get_pod_name_that_contains(kube_apis.v1, test_namespace, "syslog2") |
347 | 348 | log_contents = "" |
348 | 349 | retry = 0 |
349 | | - while "ASM:attack_type" not in log_contents and retry <= 30: |
350 | | - log_contents = get_file_contents(kube_apis.v1, log_loc, syslog_pod[0].metadata.name, test_namespace) |
| 350 | + while "ASM:attack_type" not in log_contents and retry <= 60: |
| 351 | + log_contents = get_file_contents(kube_apis.v1, log_loc, syslog_pod, test_namespace) |
351 | 352 | retry += 1 |
352 | 353 | wait_before_test(1) |
353 | | - print(log_contents) |
354 | 354 | print(f"Security log not updated, retrying... #{retry}") |
355 | 355 |
|
356 | 356 | log_esc_contents = "" |
357 | 357 | retry = 0 |
358 | | - while "attack_type" not in log_esc_contents and retry <= 30: |
359 | | - log_esc_contents = get_file_contents(kube_apis.v1, log_loc, syslog_esc_pod[0].metadata.name, test_namespace) |
| 358 | + while "attack_type" not in log_esc_contents and retry <= 60: |
| 359 | + log_esc_contents = get_file_contents(kube_apis.v1, log_loc, syslog_esc_pod, test_namespace) |
360 | 360 | retry += 1 |
361 | 361 | wait_before_test(1) |
362 | | - print(log_esc_contents) |
363 | 362 | print(f"Security log not updated, retrying... #{retry}") |
364 | 363 |
|
365 | 364 | delete_policy(kube_apis.custom_objects, "waf-policy", test_namespace) |
|
0 commit comments