Skip to content

Commit

Permalink
Add test case to demonstrate issue #336
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Apr 20, 2022
1 parent 2166120 commit fa68c33
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time

import hiro
from flask import Blueprint

from flask_limiter.constants import ConfigVars

Expand Down Expand Up @@ -182,3 +183,30 @@ def test():
assert cli.get("/test").status_code == 200
assert cli.get("/root").status_code == 200
assert cli.get("/test").status_code == 429


def test_endpoint_with_dot_but_not_blueprint(extension_factory):
"""
https://github.com/alisaifee/flask-limiter/issues/336
"""
app, limiter = extension_factory(default_limits=["2/day"])

def route():
return "42"

app.add_url_rule("/teapot/iam", "_teapot.iam", route)
bp = Blueprint("teapot", __name__, url_prefix="/teapot")

@bp.route("/")
def bp_route():
return "43"

app.register_blueprint(bp)
limiter.limit("1/day")(bp)

with app.test_client() as cli:
assert cli.get("/teapot/iam").status_code == 200
assert cli.get("/teapot/iam").status_code == 200
assert cli.get("/teapot/iam").status_code == 429
assert cli.get("/teapot/").status_code == 200
assert cli.get("/teapot/").status_code == 429

0 comments on commit fa68c33

Please sign in to comment.