[CalendarServer-changes] [14948] CalendarServer/trunk/txdav/who
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jul 6 15:07:51 PDT 2015
Revision: 14948
http://trac.calendarserver.org//changeset/14948
Author: sagen at apple.com
Date: 2015-07-06 15:07:50 -0700 (Mon, 06 Jul 2015)
Log Message:
-----------
Set a timeout when making Wiki requests; return 'no access', just like any other Wiki error
Modified Paths:
--------------
CalendarServer/trunk/txdav/who/test/test_wiki.py
CalendarServer/trunk/txdav/who/wiki.py
Modified: CalendarServer/trunk/txdav/who/test/test_wiki.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_wiki.py 2015-07-06 15:19:22 UTC (rev 14947)
+++ CalendarServer/trunk/txdav/who/test/test_wiki.py 2015-07-06 22:07:50 UTC (rev 14948)
@@ -23,7 +23,7 @@
from twisted.trial import unittest
-from twisted.internet.defer import inlineCallbacks, succeed
+from twisted.internet.defer import inlineCallbacks, succeed, TimeoutError
from twistedcaldav.test.util import StoreTestCase
from ..wiki import (
@@ -94,6 +94,8 @@
def stubAccessForUserToWiki(self, *args, **kwds):
+ if hasattr(self, "raiseTimeout"):
+ raise TimeoutError
return succeed(self.access)
@@ -117,8 +119,14 @@
access = yield record.accessForRecord(None)
self.assertEquals(access, WikiAccessLevel.write)
+ self.access = "write"
+ self.raiseTimeout = True
+ access = yield record.accessForRecord(None)
+ self.assertEquals(access, WikiAccessLevel.none)
+
+
# Test getWikiACL()
# Currently stubs out enough functionality to test that an unauthenticated
# request can support read access when generating an ACL element
Modified: CalendarServer/trunk/txdav/who/wiki.py
===================================================================
--- CalendarServer/trunk/txdav/who/wiki.py 2015-07-06 15:19:22 UTC (rev 14947)
+++ CalendarServer/trunk/txdav/who/wiki.py 2015-07-06 22:07:50 UTC (rev 14948)
@@ -33,9 +33,11 @@
from twext.who.idirectory import FieldName as BaseFieldName
from twext.who.util import ConstantsContainer
from twisted.internet import reactor
-from twisted.internet.defer import inlineCallbacks, returnValue, succeed
+from twisted.internet.defer import (
+ inlineCallbacks, returnValue, succeed, TimeoutError
+)
from twisted.python.constants import Names, NamedConstant
-from twisted.web.client import HTTPPageGetter, HTTPClientFactory
+from twisted.web.client import HTTPClientFactory
from twisted.web.error import Error as WebError
from txdav.who.directory import CalendarDirectoryRecordMixin
from txdav.who.idirectory import FieldName
@@ -218,6 +220,12 @@
)
returnValue(WikiAccessLevel.none)
+ except TimeoutError as e:
+ self.log.error(
+ "Wiki request timed out"
+ )
+ returnValue(WikiAccessLevel.none)
+
try:
returnValue({
"no-access": WikiAccessLevel.none,
@@ -439,7 +447,6 @@
otherwise a twisted.web.error.Error is the result.
"""
point = endpoints.clientFromString(reactor, descriptor)
- factory = HTTPClientFactory(url)
- factory.protocol = HTTPPageGetter
+ factory = HTTPClientFactory(url, timeout=10)
point.connect(factory)
return factory.deferred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150706/ac9528c6/attachment.html>
More information about the calendarserver-changes
mailing list