diff --git a/testsuite/tests/kuadrant/limitador/test_basic_limit.py b/testsuite/tests/kuadrant/limitador/test_basic_limit.py index d9da022a..f37aec29 100644 --- a/testsuite/tests/kuadrant/limitador/test_basic_limit.py +++ b/testsuite/tests/kuadrant/limitador/test_basic_limit.py @@ -1,6 +1,7 @@ """ Tests that a single limit is enforced as expected over one iteration """ +from time import sleep import pytest @@ -10,9 +11,9 @@ @pytest.fixture( scope="module", params=[ - pytest.param(Limit(2, 20), id="2 requests every 20 sec"), - pytest.param(Limit(5, 15), id="5 requests every 15 sec"), - pytest.param(Limit(3, 10), id="3 request every 10 sec"), + pytest.param(Limit(2, 15), id="2 requests every 15 sec"), + pytest.param(Limit(5, 10), id="5 requests every 10 sec"), + pytest.param(Limit(3, 5), id="3 request every 5 sec"), ], ) def limit(request): @@ -34,3 +35,11 @@ def test_limit(client, limit): r.status_code == 200 for r in responses ), f"Rate Limited resource unexpectedly rejected requests {responses}" assert client.get("/get").status_code == 429 + + +def test_limit_reset(client, limit): + """Tests if the rate limit resets after limit duration time (1 sec is grace period)""" + responses = client.get_many("/get", limit.limit + 1) + assert responses[-1].status_code == 429 + sleep(limit.duration + 1) + assert client.get("/get").status_code == 200