[CalendarServer-changes] [15390] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Dec 14 13:48:55 PST 2015
Revision: 15390
http://trac.calendarserver.org//changeset/15390
Author: cdaboo at apple.com
Date: 2015-12-14 13:48:55 -0800 (Mon, 14 Dec 2015)
Log Message:
-----------
Fix cases where non-ascii in HTTP requests result in no access log entries.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/accesslog.py
CalendarServer/trunk/calendarserver/test/test_accesslog.py
CalendarServer/trunk/txdav/dps/client.py
CalendarServer/trunk/txdav/dps/test/test_client.py
Modified: CalendarServer/trunk/calendarserver/accesslog.py
===================================================================
--- CalendarServer/trunk/calendarserver/accesslog.py 2015-12-14 20:48:17 UTC (rev 15389)
+++ CalendarServer/trunk/calendarserver/accesslog.py 2015-12-14 21:48:55 UTC (rev 15390)
@@ -262,6 +262,8 @@
if self.shouldRotate() and allowrotate:
self.flush()
self.rotate()
+ if isinstance(message, unicode):
+ message = message.encode("utf-8")
self.f.write(message + "\n")
Modified: CalendarServer/trunk/calendarserver/test/test_accesslog.py
===================================================================
--- CalendarServer/trunk/calendarserver/test/test_accesslog.py 2015-12-14 20:48:17 UTC (rev 15389)
+++ CalendarServer/trunk/calendarserver/test/test_accesslog.py 2015-12-14 21:48:55 UTC (rev 15390)
@@ -15,7 +15,9 @@
##
from twisted.trial.unittest import TestCase
-from calendarserver.accesslog import SystemMonitor
+from calendarserver.accesslog import SystemMonitor, \
+ RotatingFileAccessLoggingObserver
+from twistedcaldav.stdconfig import DEFAULT_CONFIG #@UnusedImport
class AccessLog(TestCase):
"""
@@ -36,3 +38,18 @@
monitor.stop()
self.assertNotEqual(monitor.items["cpu count"], 0)
+
+
+ def test_unicodeLog(self):
+ """
+ Make sure L{RotatingFileAccessLoggingObserver} handles non-ascii data properly.
+ """
+
+ logpath = self.mktemp()
+ observer = RotatingFileAccessLoggingObserver(logpath)
+ observer.start()
+ observer.accessLog(u"Can\u2019 log this")
+ observer.stop()
+
+ with open(logpath) as f:
+ self.assertIn("log this", f.read())
Modified: CalendarServer/trunk/txdav/dps/client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/client.py 2015-12-14 20:48:17 UTC (rev 15389)
+++ CalendarServer/trunk/txdav/dps/client.py 2015-12-14 21:48:55 UTC (rev 15390)
@@ -446,11 +446,13 @@
def verifyPlaintextPassword(self, password):
+ if isinstance(password, unicode):
+ password = password.encode("utf-8")
return self.service._call(
VerifyPlaintextPasswordCommand,
lambda x: x['authenticated'],
uid=self.uid.encode("utf-8"),
- password=password.encode("utf-8")
+ password=password,
)
Modified: CalendarServer/trunk/txdav/dps/test/test_client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/test/test_client.py 2015-12-14 20:48:17 UTC (rev 15389)
+++ CalendarServer/trunk/txdav/dps/test/test_client.py 2015-12-14 21:48:55 UTC (rev 15390)
@@ -340,7 +340,8 @@
def test_verifyPlaintextPassword(self):
expectations = (
(testPassword, True), # Correct
- ("wrong", False) # Incorrect
+ ("wrong", False), # Incorrect
+ ("wrong\xc3\xa5", False), # Incorrect
)
record = (
yield self.directory.recordWithShortName(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151214/78c80b37/attachment.html>
More information about the calendarserver-changes
mailing list