Skip to content

Commit

Permalink
Add Test to check server block inside VS yaml (#2415)
Browse files Browse the repository at this point in the history
Co-authored-by: = <=>
  • Loading branch information
pasmant authored Mar 8, 2022
1 parent 96bde3e commit e79ca9f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/data/virtual-server-dos/virtual-server-block-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: dosapp
spec:
host: dos.example.com

upstreams:
- name: dosapp
service: dos-svc
port: 80
dos: dos-protected
routes:
- path: /
action:
pass: dosapp
29 changes: 29 additions & 0 deletions tests/suite/test_virtual_server_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,35 @@ def test_vs_with_dos_config(self, kube_apis, ingress_controller_prerequisites, c
for _ in conf_directives:
assert _ in result_conf

print("Remove Virtual Server in location block")
delete_virtual_server(kube_apis.custom_objects, virtual_server_setup_dos.vs_name, test_namespace)
print("Add Virtual Server in server block")

vs_source_server_block = f"{TEST_DATA}/virtual-server-dos/virtual-server-block-server.yaml"
create_virtual_server_from_yaml(kube_apis.custom_objects, vs_source_server_block, test_namespace)
wait_before_test(5)

print("\n confirm response for standard request")
resp = requests.get(virtual_server_setup_dos.backend_1_url,
headers={"host": virtual_server_setup_dos.vs_host})
assert resp.status_code == 200

result_conf = get_vs_nginx_template_conf(kube_apis.v1,
virtual_server_setup_dos.namespace,
virtual_server_setup_dos.vs_name,
pod_name,
"nginx-ingress")

for _ in conf_directives:
assert _ in result_conf

print("Clean up new VS server block")
delete_virtual_server(kube_apis.custom_objects, virtual_server_setup_dos.vs_name, test_namespace)

print("Return VS location block")
vs_source = f"{TEST_DATA}/virtual-server-dos/virtual-server.yaml"
create_virtual_server_from_yaml(kube_apis.custom_objects, vs_source, test_namespace)

@pytest.mark.skip
def test_vs_dos_under_attack_no_learning(
self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller_with_dos, virtual_server_setup_dos, dos_setup, test_namespace
Expand Down

0 comments on commit e79ca9f

Please sign in to comment.