Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test to check server block inside VS yaml #2415

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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