test: add cases for user/path value check
This commit is contained in:
@@ -94,6 +94,14 @@ class TestBaseAuthRequests(BaseTest):
|
||||
def test_htpasswd_plain(self) -> None:
|
||||
self._test_htpasswd("plain", "tmp:bepo")
|
||||
|
||||
def test_htpasswd_blacklist_plain(self) -> None:
|
||||
self._test_htpasswd("plain", "tmp:be:po", (
|
||||
("tm" + chr(9) + "p", "be:po", True), ("tm" + chr(9) + "p", "bepo", False)), check=401)
|
||||
self._test_htpasswd("plain", "tmp:be:po", (
|
||||
("tm'p", "be:po", True), ("tm'p", "bepo", False)), check=401)
|
||||
self._test_htpasswd("plain", "tmp:be:po", (
|
||||
('tm"p', "be:po", True), ('tm"p', "bepo", False)), check=401)
|
||||
|
||||
def test_htpasswd_plain_autodetect(self) -> None:
|
||||
self._test_htpasswd("autodetect", "tmp:bepo")
|
||||
|
||||
@@ -108,6 +116,39 @@ class TestBaseAuthRequests(BaseTest):
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
|
||||
def test_htpasswd_strict_plain_unicode(self) -> None:
|
||||
"""user with unicode chars is not permitted"""
|
||||
self.configure({"server": {"validate_user_value": "strict"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
else:
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
|
||||
def test_htpasswd_minimal_plain_unicode(self) -> None:
|
||||
"""user with unicode chars is permitted"""
|
||||
self.configure({"server": {"validate_user_value": "minimal"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
|
||||
def test_htpasswd_minimal_plain_special(self) -> None:
|
||||
"""user with special chars is not permitted"""
|
||||
self.configure({"server": {"validate_user_value": "minimal"}})
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "*?*:bepo", "ascii", check=check)
|
||||
|
||||
def test_htpasswd_unicode_plain_unicode(self) -> None:
|
||||
"""user with unicode symbols is not permitted"""
|
||||
self.configure({"server": {"validate_user_value": "unicodeletter"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
else:
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
|
||||
def test_htpasswd_md5(self) -> None:
|
||||
self._test_htpasswd("md5", "tmp:$apr1$BI7VKCZh$GKW4vq2hqDINMr8uv7lDY/")
|
||||
|
||||
@@ -301,7 +342,8 @@ class TestBaseAuthRequests(BaseTest):
|
||||
self._test_htpasswd("plain", "%s:bepo" % user, (
|
||||
(user, "bepo", True), ("tmp", "bepo", False)), check=check)
|
||||
|
||||
def test_htpasswd_problem_user(self) -> None:
|
||||
def test_htpasswd_problem_user_none(self) -> None:
|
||||
self.configure({"server": {"validate_user_value": "none"}})
|
||||
for user in ("tm*p", "tm?p"):
|
||||
if not pathutils.path_supports_problematic_chars(self.colpath):
|
||||
check = 500
|
||||
@@ -310,6 +352,16 @@ class TestBaseAuthRequests(BaseTest):
|
||||
self._test_htpasswd("plain", "%s:bepo" % user, (
|
||||
(user, "bepo", True), ("tmp", "bepo", False)), check=check)
|
||||
|
||||
def test_htpasswd_problem_user_minimal(self) -> None:
|
||||
self.configure({"server": {"validate_user_value": "minimal"}})
|
||||
for user in ("tm*p", "tm?p"):
|
||||
if not pathutils.path_supports_problematic_chars(self.colpath):
|
||||
check = 500
|
||||
else:
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "%s:bepo" % user, (
|
||||
(user, "bepo", True), ("tmp", "bepo", False)), check=check)
|
||||
|
||||
def test_htpasswd_whitespace_password(self) -> None:
|
||||
for password in (" bepo", "bepo ", " bepo "):
|
||||
self._test_htpasswd("plain", "tmp:%s" % password, (
|
||||
|
||||
Reference in New Issue
Block a user