Blocking server also blocks subdomains
This commit is contained in:
parent
e8fcf5a9a2
commit
a337b32bcd
4 changed files with 32 additions and 5 deletions
19
tests/test_utils.py
Normal file
19
tests/test_utils.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from app.utils.url import is_hostname_blocked
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"hostname,should_be_blocked",
|
||||
[
|
||||
("example.com", True),
|
||||
("subdomain.example.com", True),
|
||||
("example.xyz", False),
|
||||
],
|
||||
)
|
||||
def test_is_hostname_blocked(hostname: str, should_be_blocked: bool) -> None:
|
||||
with mock.patch("app.utils.url.BLOCKED_SERVERS", ["example.com"]):
|
||||
is_hostname_blocked.cache_clear()
|
||||
assert is_hostname_blocked(hostname) is should_be_blocked
|
Loading…
Add table
Add a link
Reference in a new issue