Skip to content

Commit

Permalink
e2e: fix rate limit tests for query (substring match, not exact match)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier-rbz committed Dec 21, 2020
1 parent 873f55b commit ba04fdd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,23 +577,25 @@ def test_ratelimit_scope_tags_exclude(self, target, ratelimit_config):
"Request #6 for non excluded tags should be denied"

def test_ratelimit_scope_query_include(self, target, ratelimit_config):
# if "QUERY" is a substring of the query, rate limiting applies
for i in range(1, 6):
assert target.is_reachable("/scope-query-include/included?QUERY"), \
f"Request #{i} for included query should be allowed"
assert not target.is_reachable("/scope-query-include/included?QUERY"), \
"Request #6 for included query should be denied"
for i in range(1, 7):
assert target.is_reachable("/scope-query-include/not-included?NOQUERY"), \
assert target.is_reachable("/scope-query-include/not-included?SOMETHINGELSE"), \
f"Request #{i} for non included query should be allowed"

def test_ratelimit_scope_query_exclude(self, target, ratelimit_config):
# if "QUERY" is a substring of the query, rate limiting does not apply
for i in range(1, 7):
assert target.is_reachable("/scope-query-exclude/excluded?QUERY"), \
f"Request #{i} for excluded query should be allowed"
for i in range(1, 6):
assert target.is_reachable("/scope-query-exclude/not-excluded?NOQUERY"), \
assert target.is_reachable("/scope-query-exclude/not-excluded?SOMETHINGELSE"), \
f"Request #{i} for non excluded query should be allowed"
assert not target.is_reachable("/scope-query-exclude/not-excluded?NOQUERY"), \
assert not target.is_reachable("/scope-query-exclude/not-excluded?SOMETHINGELSE"), \
"Request #6 for non excluded query should be denied"

def test_ratelimit_scope_authority_include(self, target, ratelimit_config):
Expand Down

0 comments on commit ba04fdd

Please sign in to comment.