Skip to content

Commit

Permalink
Add dnspolicy deletion test
Browse files Browse the repository at this point in the history
Signed-off-by: averevki <[email protected]>
  • Loading branch information
averevki committed Sep 11, 2024
1 parent 9558a7d commit 573e1b8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testsuite/gateway/gateway_api/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, hostname, tls_cert_getter: Callable[[], Certificate | bool] =

def client(self, **kwargs) -> KuadrantClient:
protocol = "http"
if self.tls_cert_getter is not None:
if self.tls_cert_getter is not None and self.tls_cert_getter() is not None:
protocol = "https"
kwargs.setdefault("verify", self.tls_cert_getter())
return KuadrantClient(base_url=f"{protocol}://{self.hostname}", **kwargs)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Test that Gateway will behave properly after attached DNSPolicy is deleted"""

import pytest

from testsuite.gateway.gateway_api.gateway import KuadrantGateway

pytestmark = [pytest.mark.kuadrant_only, pytest.mark.dnspolicy]


@pytest.fixture(scope="module")
def gateway(request, cluster, blame, wildcard_domain, module_label):
"""Create gateway without TLS enabled"""
gw = KuadrantGateway.create_instance(cluster, blame("gw"), wildcard_domain, {"app": module_label}, tls=False)
request.addfinalizer(gw.delete)
gw.commit()
gw.wait_for_ready()
return gw


@pytest.fixture(scope="module", autouse=True)
def commit(request, route, dns_policy): # pylint: disable=unused-argument
"""Commits dnspolicy"""
request.addfinalizer(dns_policy.delete)
dns_policy.commit()
dns_policy.wait_for_ready()


def test_dnspolicy_removal(gateway, dns_policy, client):
"""
Test that Gateway will behave properly after attached DNSPolicy is deleted
- Verify that Gateway is affected by DNSPolicy and requests are successful
- Delete attached DNSPolicy
- Verify that Gateway is no longer affected by DNSPolicy and requests are failing
"""
assert gateway.refresh().is_affected_by(dns_policy)
response = client.get("/get")
assert response.status_code == 200

dns_policy.delete()

assert not gateway.refresh().is_affected_by(dns_policy)
response = client.get("/get")
assert response.has_dns_error()

0 comments on commit 573e1b8

Please sign in to comment.