Example #1
0
def test_url_matches():
    request = Request({
        "type": "http",
        "scheme": "http",
        "server": (b"example.com", 80),
        "query_string": b"csrf-token=TOKEN",
        "path": "/account/login",
        "headers": {},
    })
    assert request.url_matches(r"/account/login")
    assert request.url_matches(r".*ogin")
    assert request.url_matches(r"/account/*")
    assert not request.url_matches(r"/admin")
Example #2
0
 def should_check_token(self, request: Request) -> bool:
     return not any([
         request.method.lower() in self.safe_methods,
         request.url_matches(*self._exclude_urls),
         request.full_url_matches(*self._exclude_urls),
     ])