Merge branch 'master' of github.com:Kozea/radicale
This commit is contained in:
commit
ecb8a99ed1
4
logging
4
logging
@ -53,8 +53,8 @@ formatter = full
|
|||||||
|
|
||||||
[formatter_simple]
|
[formatter_simple]
|
||||||
# Simple output format
|
# Simple output format
|
||||||
format = %(message)s
|
format = [%(thread)x] %(levelname)s: %(message)s
|
||||||
|
|
||||||
[formatter_full]
|
[formatter_full]
|
||||||
# Full output format
|
# Full output format
|
||||||
format = %(asctime)s - %(thread)d - %(levelname)s: %(message)s
|
format = %(asctime)s - [%(thread)x] %(levelname)s: %(message)s
|
||||||
|
@ -338,7 +338,7 @@ class Application:
|
|||||||
user = self.Auth.map_login_to_user(login)
|
user = self.Auth.map_login_to_user(login)
|
||||||
else:
|
else:
|
||||||
user = self.Auth.map_login_to_user(environ.get("REMOTE_USER", ""))
|
user = self.Auth.map_login_to_user(environ.get("REMOTE_USER", ""))
|
||||||
password = None
|
password = ""
|
||||||
|
|
||||||
# If "/.well-known" is not available, clients query "/"
|
# If "/.well-known" is not available, clients query "/"
|
||||||
if path == "/.well-known" or path.startswith("/.well-known/"):
|
if path == "/.well-known" or path.startswith("/.well-known/"):
|
||||||
@ -388,7 +388,7 @@ class Application:
|
|||||||
self.logger.info("%s refused" % (user or "Anonymous user"))
|
self.logger.info("%s refused" % (user or "Anonymous user"))
|
||||||
status = client.UNAUTHORIZED
|
status = client.UNAUTHORIZED
|
||||||
realm = self.configuration.get("server", "realm")
|
realm = self.configuration.get("server", "realm")
|
||||||
headers = headers.copy()
|
headers = dict(headers)
|
||||||
headers.update ({
|
headers.update ({
|
||||||
"WWW-Authenticate":
|
"WWW-Authenticate":
|
||||||
"Basic realm=\"%s\"" % realm})
|
"Basic realm=\"%s\"" % realm})
|
||||||
|
@ -56,7 +56,8 @@ def start(name="radicale", filename=None, debug=False):
|
|||||||
"Logging configuration file '%s' not found, using stderr." %
|
"Logging configuration file '%s' not found, using stderr." %
|
||||||
filename)
|
filename)
|
||||||
handler = logging.StreamHandler(sys.stderr)
|
handler = logging.StreamHandler(sys.stderr)
|
||||||
handler.setFormatter(logging.Formatter("%(message)s"))
|
handler.setFormatter(
|
||||||
|
logging.Formatter("[%(thread)x] %(levelname)s: %(message)s"))
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
if debug:
|
if debug:
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
@ -134,10 +134,12 @@ class Rights(BaseRights):
|
|||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"Test if '%s:%s' matches against '%s:%s' from section '%s'",
|
"Test if '%s:%s' matches against '%s:%s' from section '%s'",
|
||||||
user, sane_path, re_user, re_collection, section)
|
user, sane_path, re_user, re_collection, section)
|
||||||
user_match = re.fullmatch(re_user, user)
|
# Emulate fullmatch
|
||||||
|
user_match = re.match(r"(?:%s)\Z" % re_user, user)
|
||||||
if user_match:
|
if user_match:
|
||||||
re_collection = re_collection.format(*user_match.groups())
|
re_collection = re_collection.format(*user_match.groups())
|
||||||
if re.fullmatch(re_collection, sane_path):
|
# Emulate fullmatch
|
||||||
|
if re.match(r"(?:%s)\Z" % re_collection, sane_path):
|
||||||
self.logger.debug("Section '%s' matches", section)
|
self.logger.debug("Section '%s' matches", section)
|
||||||
return permission in regex.get(section, "permission")
|
return permission in regex.get(section, "permission")
|
||||||
else:
|
else:
|
||||||
|
@ -254,9 +254,6 @@ class BaseCollection:
|
|||||||
"""
|
"""
|
||||||
if item.collection.path == to_collection.path and item.href == to_href:
|
if item.collection.path == to_collection.path and item.href == to_href:
|
||||||
return
|
return
|
||||||
if to_collection.has(to_href):
|
|
||||||
to_collection.update(to_href, item.item)
|
|
||||||
else:
|
|
||||||
to_collection.upload(to_href, item.item)
|
to_collection.upload(to_href, item.item)
|
||||||
item.collection.delete(item.href)
|
item.collection.delete(item.href)
|
||||||
|
|
||||||
|
@ -766,6 +766,14 @@ class BaseRequestsMixIn:
|
|||||||
assert status == 207
|
assert status == 207
|
||||||
assert "href>/user/<" in answer
|
assert "href>/user/<" in answer
|
||||||
|
|
||||||
|
def test_authentication(self):
|
||||||
|
"""Test if server sends authentication request."""
|
||||||
|
self.configuration.set("rights", "type", "owner_only")
|
||||||
|
self.application = Application(self.configuration, self.logger)
|
||||||
|
status, headers, answer = self.request("MKCOL", "/user/")
|
||||||
|
assert status in (401, 403)
|
||||||
|
assert headers.get("WWW-Authenticate")
|
||||||
|
|
||||||
def test_principal_collection_creation(self):
|
def test_principal_collection_creation(self):
|
||||||
"""Verify existence of the principal collection."""
|
"""Verify existence of the principal collection."""
|
||||||
status, headers, answer = self.request(
|
status, headers, answer = self.request(
|
||||||
@ -836,6 +844,17 @@ class BaseRequestsMixIn:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def test_custom_headers(self):
|
||||||
|
if not self.configuration.has_section("headers"):
|
||||||
|
self.configuration.add_section("headers")
|
||||||
|
self.configuration.set("headers", "test", "123")
|
||||||
|
# Test if header is set on success
|
||||||
|
status, headers, answer = self.request("GET", "/")
|
||||||
|
assert headers.get("test") == "123"
|
||||||
|
# Test if header is set on failure
|
||||||
|
status, headers, answer = self.request("GET", "/.well-known/does not exist")
|
||||||
|
assert headers.get("test") == "123"
|
||||||
|
|
||||||
|
|
||||||
class BaseFileSystemTest(BaseTest):
|
class BaseFileSystemTest(BaseTest):
|
||||||
"""Base class for filesystem backend tests."""
|
"""Base class for filesystem backend tests."""
|
||||||
|
Loading…
Reference in New Issue
Block a user