Skip to content

Commit

Permalink
Add path match without backend method to HTTPRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
averevki committed Dec 4, 2023
1 parent 024bbb1 commit 0c93a68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion testsuite/openshift/objects/gateway_api/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ def remove_all_hostnames(self):
self.model.spec.hostnames = []

@modify
def set_match(self, backend: "Httpbin", path_prefix: str = None):
def set_path_match(self, path_prefix: str):
"""Limits HTTPRoute to a certain path"""
self.model.spec.rules.append({"matches": [{"path": {"value": path_prefix, "type": "PathPrefix"}}]})

@modify
def set_backend_match(self, backend: "Httpbin", path_prefix: str = None):
"""Limits HTTPRoute to a certain path to backend"""
match = {}
if path_prefix:
match["path"] = {"value": path_prefix, "type": "PathPrefix"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_matches(client, backend, route, resilient_request):
response = client.get("/get")
assert response.status_code == 200

route.set_match(backend, path_prefix="/anything")
route.set_backend_match(backend, path_prefix="/anything")

response = resilient_request("/get", expected_status=404)
assert response.status_code == 404, "Matches were not reconciled"
Expand Down

0 comments on commit 0c93a68

Please sign in to comment.