Skip to content

Commit

Permalink
Merge pull request #287 from jsmolar/rate_limit_auth
Browse files Browse the repository at this point in the history
Added parametrization for limit tests to use both gateway and route as target_ref
  • Loading branch information
pehala authored Nov 21, 2023
2 parents 7cc3603 + dd456fe commit 024bbb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions testsuite/openshift/objects/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class Limit:


class RateLimitPolicy(OpenShiftObject):
"""RateLimitPolicy (or RLP for short) object, used for applying rate limiting rules to an Gateway/HTTPRoute"""
"""RateLimitPolicy (or RLP for short) object, used for applying rate limiting rules to a Gateway/HTTPRoute"""

@classmethod
def create_instance(cls, openshift: OpenShiftClient, name, route: Referencable, labels: dict[str, str] = None):
def create_instance(cls, openshift: OpenShiftClient, name, target: Referencable, labels: dict[str, str] = None):
"""Creates new instance of RateLimitPolicy"""
model = {
"apiVersion": "kuadrant.io/v1beta2",
"kind": "RateLimitPolicy",
"metadata": {"name": name, "labels": labels},
"spec": {
"targetRef": route.reference,
"targetRef": target.reference,
"limits": {},
},
}
Expand Down
14 changes: 5 additions & 9 deletions testsuite/tests/kuadrant/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ def authorization(authorino, kuadrant, oidc_provider, route, authorization_name,
return None


@pytest.fixture(scope="module")
def rate_limit_name(blame):
"""Name of the rate limit"""
return blame("limit")


@pytest.fixture(scope="module")
def rate_limit(kuadrant, openshift, rate_limit_name, route, module_label):
@pytest.fixture(scope="module", params=["route", "gateway"])
def rate_limit(kuadrant, openshift, blame, request, module_label):
"""Rate limit"""
if kuadrant:
return RateLimitPolicy.create_instance(openshift, rate_limit_name, route, labels={"testRun": module_label})
return RateLimitPolicy.create_instance(
openshift, blame("limit"), request.getfixturevalue(request.param), labels={"testRun": module_label}
)
return None


Expand Down

0 comments on commit 024bbb1

Please sign in to comment.