user/path value check: adjust test cases
This commit is contained in:
@@ -111,7 +111,7 @@ class TestBaseAuthRequests(BaseTest):
|
||||
|
||||
def test_htpasswd_plain_unicode(self) -> None:
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
@@ -120,7 +120,7 @@ class TestBaseAuthRequests(BaseTest):
|
||||
"""user with unicode chars is not permitted"""
|
||||
self.configure({"server": {"validate_user_value": "strict"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
@@ -129,7 +129,7 @@ class TestBaseAuthRequests(BaseTest):
|
||||
"""user with unicode chars is permitted"""
|
||||
self.configure({"server": {"validate_user_value": "minimal"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
@@ -142,9 +142,9 @@ class TestBaseAuthRequests(BaseTest):
|
||||
|
||||
def test_htpasswd_unicode_plain_unicode(self) -> None:
|
||||
"""user with unicode symbols is not permitted"""
|
||||
self.configure({"server": {"validate_user_value": "unicodeletter"}})
|
||||
self.configure({"server": {"validate_user_value": "unicode-letter"}})
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 401
|
||||
self._test_htpasswd("plain", "😀:🔑", "unicode", check=check)
|
||||
@@ -157,7 +157,7 @@ class TestBaseAuthRequests(BaseTest):
|
||||
|
||||
def test_htpasswd_md5_unicode(self):
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd(
|
||||
@@ -216,7 +216,7 @@ class TestBaseAuthRequests(BaseTest):
|
||||
@pytest.mark.skipif(has_bcrypt == 0, reason="No bcrypt module installed")
|
||||
def test_htpasswd_bcrypt_unicode(self) -> None:
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check = 500
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("bcrypt", "😀:$2y$10$Oyz5aHV4MD9eQJbk6GPemOs4T6edK6U9Sqlzr.W1mMVCS8wJUftnW", "unicode", check=check)
|
||||
@@ -335,8 +335,8 @@ class TestBaseAuthRequests(BaseTest):
|
||||
|
||||
def test_htpasswd_whitespace_user(self) -> None:
|
||||
for user in (" tmp", "tmp ", " tmp "):
|
||||
if not pathutils.path_supports_trailing_whitespace(self.colpath) and user.endswith(' '):
|
||||
check = 500
|
||||
if not pathutils.path_supports_trailing_whitespace(self.colpath) and (user.endswith(' ') or user.startswith(' ')):
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "%s:bepo" % user, (
|
||||
@@ -346,19 +346,19 @@ class TestBaseAuthRequests(BaseTest):
|
||||
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
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
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"}})
|
||||
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
|
||||
else:
|
||||
check = 401
|
||||
else:
|
||||
check = 207
|
||||
self._test_htpasswd("plain", "%s:bepo" % user, (
|
||||
(user, "bepo", True), ("tmp", "bepo", False)), check=check)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import defusedxml.ElementTree as DefusedET
|
||||
import pytest
|
||||
import vobject
|
||||
|
||||
from radicale import storage, utils, xmlutils
|
||||
from radicale import pathutils, storage, utils, xmlutils
|
||||
from radicale.tests import RESPONSES, BaseTest
|
||||
from radicale.tests.helpers import get_file_content
|
||||
|
||||
@@ -629,11 +629,23 @@ permissions: RrWw""")
|
||||
event = get_file_content("event1.ics")
|
||||
path1 = "/calendar.ics/event😀1.ics"
|
||||
path2 = "/calendar.ics/event😁2.ics"
|
||||
self.put(path1, event)
|
||||
self.request("MOVE", path1, check=201,
|
||||
if not pathutils.path_supports_unicode(self.colpath):
|
||||
check_put = 400
|
||||
check_move = 400
|
||||
check_get1 = 400
|
||||
check_get2 = 400
|
||||
else:
|
||||
check_put = 201
|
||||
check_move = 201
|
||||
check_get1 = 200
|
||||
check_get2 = 404
|
||||
self.put(path1, event, check=check_put)
|
||||
self.get(path1, check=check_get1)
|
||||
self.get(path2, check=check_get2)
|
||||
self.request("MOVE", path1, check=check_move,
|
||||
HTTP_DESTINATION="http://127.0.0.1/"+path2)
|
||||
self.get(path1, check=404)
|
||||
self.get(path2)
|
||||
self.get(path1, check=check_get2)
|
||||
self.get(path2, check=check_get1)
|
||||
|
||||
def test_move_strict_unicode_dst(self) -> None:
|
||||
"""Move a item."""
|
||||
|
||||
@@ -24,11 +24,13 @@ import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from typing import Dict, Sequence, Tuple, Union
|
||||
|
||||
from radicale import sharing, xmlutils
|
||||
from radicale import pathutils, sharing, xmlutils
|
||||
from radicale.tests import BaseTest
|
||||
from radicale.tests.helpers import get_file_content
|
||||
|
||||
@@ -5541,6 +5543,7 @@ permissions: RrWw""")
|
||||
description = self._propfind_calendar_description(path_shared_r, login="user:userpw")
|
||||
assert description == description_user
|
||||
|
||||
@pytest.mark.skipif(not pathutils.path_supports_unicode(tempfile.mkdtemp()), reason="TEMP is not supporting unicode")
|
||||
def test_sharing_api_map_user_unicode(self) -> None:
|
||||
"""share-by-map API usage tests related to properties overlay using unicode."""
|
||||
self.configure({"auth": {"type": "htpasswd",
|
||||
@@ -5590,6 +5593,7 @@ permissions: RrWw""")
|
||||
json_dict['PathOrToken'] = path_shared_r
|
||||
_, headers, answer = self._sharing_api_json("map", "enable", check=200, login="us😀er:user😀pw", json_dict=json_dict)
|
||||
|
||||
@pytest.mark.skipif(not pathutils.path_supports_unicode(tempfile.mkdtemp()), reason="TEMP is not supporting unicode")
|
||||
def test_sharing_api_map_path_unicode(self) -> None:
|
||||
"""share-by-map API usage tests related to properties overlay using unicode."""
|
||||
self.configure({"auth": {"type": "htpasswd",
|
||||
|
||||
Reference in New Issue
Block a user