[prev in list] [next in list] [prev in thread] [next in thread]
List: calendarserver-changes
Subject: [CalendarServer-changes] [2359]
From: source_changes () macosforge ! org
Date: 2008-04-30 23:16:08
Message-ID: 20080430231608.2C720161D903 () beta ! macosforge ! org
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Revision: 2359
http://trac.macosforge.org/projects/calendarserver/changeset/2359
Author: dreid@apple.com
Date: 2008-04-30 16:16:07 -0700 (Wed, 30 Apr 2008)
Log Message:
-----------
Start of a resource that caches responses
Modified Paths:
--------------
CalendarServer/branches/propfind-cache/twistedcaldav/cache.py
CalendarServer/branches/propfind-cache/twistedcaldav/root.py
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py
Modified: CalendarServer/branches/propfind-cache/twistedcaldav/cache.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/cache.py 2008-04-28 17:35:23 \
UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/cache.py 2008-04-30 23:16:07 \
UTC (rev 2359) @@ -15,12 +15,15 @@
##
import uuid
+import time
+import os
+from twisted.python.filepath import FilePath
from twisted.web2.dav import davxml
from twisted.web2.http import HTTPError
+from twisted.web2.dav.xattrprops import xattrPropertyStore
-
class CacheTokensProperty(davxml.WebDAVTextElement):
namespace = davxml.twisted_private_namespace
name = "cacheTokens"
@@ -102,3 +105,75 @@
return True
return False
+
+
+
+class PropfindCachingResource(object):
+ CACHE_TIMEOUT = 60*60 # 1 hour
+
+ propertyStoreFactory = xattrPropertyStore
+ observerFactory = CacheChangeObserver
+
+ def __init__(self, docroot, timeFunc=time.time):
+ self._docroot = docroot
+ self._responses = {}
+ self._observers = {}
+ self._timeFunc = timeFunc
+
+
+ def _tokenPathForURI(self, uri):
+ tokenPath = self._docroot
+
+ for childName in uri.split('/')[:4]:
+ tokenPath = tokenPath.child(childName)
+
+ return tokenPath
+
+
+ def _observerForURI(self, uri):
+ class FauxStaticResource(object):
+ def __init__(self, fp):
+ self.fp = fp
+
+ propertyStore = self.propertyStoreFactory(
+ FauxStaticResource(self._tokenPathForURI(uri)))
+
+ return self.observerFactory(propertyStore)
+
+
+ def _cacheResponse(self, response, request):
+ if getattr(request, 'cacheRequest', False):
+ if request.uri not in self._observers:
+ self._observers[request.uri] = self._observerForURI(request.uri)
+
+ self._responses[(request.method,
+ request.uri,
+ request.authnUser)] = (self._timeFunc(),
+ response)
+
+ return response
+
+
+ def renderHTTP(self, request):
+ key = (request.method, request.uri, request.authnUser)
+
+ if key in self._responses:
+ cacheTime, cachedResponse = self._responses[key]
+ if cacheTime + CACHE_TIMEOUT <= self._timeFunc():
+ if (request.uri in self._observers and
+ self._observers[request.uri]()):
+
+ return cachedResponse
+
+ def _renderResource(resource, request):
+ request.addResponseFilter(self._cacheResponse)
+ return resource.renderHTTP(request)
+
+ request.notInCache = True
+ d = request.locateResource(request.uri)
+ d.addCallback(_renderResource, request)
+ return d
+
+
+ def locateChild(self, request, segments):
+ return self, []
Modified: CalendarServer/branches/propfind-cache/twistedcaldav/root.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/root.py 2008-04-28 17:35:23 \
UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/root.py 2008-04-30 23:16:07 \
UTC (rev 2359) @@ -86,19 +86,19 @@
# Figure out the "username" from the davxml.Principal object
request.checkingSACL = True
d = request.locateResource(authzUser.children[0].children[0].data)
-
+
def _checkedSACLCb(principal):
delattr(request, "checkingSACL")
username = principal.record.shortName
-
+
if RootResource.CheckSACL(username, self.saclService) != 0:
log.msg("User '%s' is not enabled with the '%s' SACL" % \
(username, self.saclService,)) return Failure(HTTPError(403))
-
+
# Mark SACL's as having been checked so we can avoid doing it \
multiple times request.checkedSACL = True
return True
-
+
d.addCallback(_checkedSACLCb)
return d
Modified: CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py 2008-04-28 \
17:35:23 UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py 2008-04-30 \
23:16:07 UTC (rev 2359) @@ -18,9 +18,12 @@
from twisted.trial.unittest import TestCase
+from twisted.python.filepath import FilePath
+
from twistedcaldav.cache import CacheChangeNotifier
from twistedcaldav.cache import CacheTokensProperty
from twistedcaldav.cache import CacheChangeObserver
+from twistedcaldav.cache import PropfindCachingResource
from twistedcaldav.test.util import InMemoryPropertyStore
@@ -147,3 +150,22 @@
self.assertEquals(self.observer.dataHasChanged(), True)
self.assertEquals(self.observer.propertiesHaveChanged(), False)
+
+
+
+class PropfindCachingResourceTests(TestCase):
+ # _tokenPathForURI tests
+ def test_tokenPathForURI(self):
+ pcr = PropfindCachingResource(FilePath('/root'))
+ paths = [
+ ('/principals/__uids__/557C330A-06E2-403B-BC24-CE3A253CDB5B/',
+ '/root/principals/__uids__/557C330A-06E2-403B-BC24-CE3A253CDB5B'),
+ ('/calendars/users/dreid/', '/root/calendars/users/dreid'),
+ ('/calendars/users/dreid/calendar', '/root/calendars/users/dreid')]
+
+ for inPath, outPath in paths:
+ self.assertEquals(pcr._tokenPathForURI(inPath).path, outPath)
+
+
+ def test_observerForURI(self):
+ pcr = PropfindCachingResource(FilePath('/root'))
Modified: CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py 2008-04-28 \
17:35:23 UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py 2008-04-30 \
23:16:07 UTC (rev 2359) @@ -64,11 +64,11 @@
'/principals/',
directory)
- # Otherwise the tests that never touch the root resource will
+ # Otherwise the tests that never touch the root resource will
# fail on teardown.
principals.provision()
- root = RootResource(self.docroot,
+ root = RootResource(self.docroot,
principalCollections=[principals])
root.putChild('principals',
@@ -78,8 +78,8 @@
portal.registerChecker(directory)
self.root = auth.AuthenticationWrapper(
- root,
- portal,
+ root,
+ portal,
credentialFactories=(basic.BasicCredentialFactory("Test realm"),),
loginInterfaces=(auth.IPrincipal,))
@@ -88,7 +88,7 @@
def test_noSacls(self):
"""
Test the behaviour of locateChild when SACLs are not enabled.
-
+
should return a valid resource
"""
self.root.resource.useSacls = False
@@ -111,7 +111,7 @@
def test_inSacls(self):
"""
- Test the behavior of locateChild when SACLs are enabled and the
+ Test the behavior of locateChild when SACLs are enabled and the
user is in the SACL group
should return a valid resource
@@ -125,7 +125,7 @@
headers=http_headers.Headers({
'Authorization': ['basic', '%s' % (
'dreid:dierd'.encode('base64'),)]}))
-
+
resrc, segments = self.root.locateChild(request,
['principals'])
@@ -137,10 +137,10 @@
self.assertEquals(segments, [])
- self.assertEquals(request.authzUser,
+ self.assertEquals(request.authzUser,
davxml.Principal(
\
davxml.HRef('/principals/__uids__/5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1/')))
-
+
d = defer.maybeDeferred(resrc.locateChild, request, ['principals'])
d.addCallback(_Cb)
@@ -150,7 +150,7 @@
"""
Test the behavior of locateChild when SACLs are enabled and the
user is not in the SACL group
-
+
should return a 403 forbidden response
"""
self.root.resource.useSacls = True
@@ -162,14 +162,14 @@
headers=http_headers.Headers({
'Authorization': ['basic', '%s' % (
'wsanchez:zehcnasw'.encode('base64'),)]}))
-
+
resrc, segments = self.root.locateChild(request,
['principals'])
def _Eb(failure):
failure.trap(HTTPError)
self.assertEquals(failure.value.response.code, 403)
-
+
d = defer.maybeDeferred(resrc.locateChild, request, ['principals'])
d.addErrback(_Eb)
@@ -179,7 +179,7 @@
"""
Test the behavior of locateChild when SACLs are enabled and the request
is unauthenticated
-
+
should return a 401 UnauthorizedResponse
"""
@@ -208,7 +208,7 @@
def test_badCredentials(self):
"""
- Test the behavior of locateChild when SACLS are enabled, and
+ Test the behavior of locateChild when SACLS are enabled, and
incorrect credentials are given.
should return a 401 UnauthorizedResponse
@@ -222,14 +222,14 @@
headers=http_headers.Headers({
'Authorization': ['basic', '%s' % (
'dreid:dreid'.encode('base64'),)]}))
-
+
resrc, segments = self.root.locateChild(request,
['principals'])
def _Eb(failure):
failure.trap(HTTPError)
self.assertEquals(failure.value.response.code, 401)
-
+
d = defer.maybeDeferred(resrc.locateChild, request, ['principals'])
d.addErrback(_Eb)
@@ -241,7 +241,7 @@
if response.code != responsecode.FORBIDDEN:
self.fail("Incorrect response for DELETE /: %s" % (response.code,))
-
+
request = SimpleRequest(self.site, "DELETE", "/")
return self.send(request, do_test)
@@ -251,7 +251,7 @@
if response.code != responsecode.FORBIDDEN:
self.fail("Incorrect response for COPY /: %s" % (response.code,))
-
+
request = SimpleRequest(
self.site,
"COPY",
@@ -266,7 +266,7 @@
if response.code != responsecode.FORBIDDEN:
self.fail("Incorrect response for MOVE /: %s" % (response.code,))
-
+
request = SimpleRequest(
self.site,
"MOVE",
@@ -274,4 +274,3 @@
headers=http_headers.Headers({"Destination":"/copy/"})
)
return self.send(request, do_test)
-
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style \
type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: \
6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; \
padding: 6px; } #msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<title>[2359] CalendarServer/branches/propfind-cache/twistedcaldav</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a \
href="http://trac.macosforge.org/projects/calendarserver/changeset/2359">2359</a></dd>
<dt>Author</dt> <dd>dreid@apple.com</dd>
<dt>Date</dt> <dd>2008-04-30 16:16:07 -0700 (Wed, 30 Apr 2008)</dd>
</dl>
<h3>Log Message</h3>
<pre>Start of a resource that caches responses</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchespropfindcachetwistedcaldavcachepy">CalendarServer/branches/propfind-cache/twistedcaldav/cache.py</a></li>
<li><a href="#CalendarServerbranchespropfindcachetwistedcaldavrootpy">CalendarServer/branches/propfind-cache/twistedcaldav/root.py</a></li>
<li><a href="#CalendarServerbranchespropfindcachetwistedcaldavtesttest_cachepy">CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py</a></li>
<li><a href="#CalendarServerbranchespropfindcachetwistedcaldavtesttest_rootpy">CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchespropfindcachetwistedcaldavcachepy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/propfind-cache/twistedcaldav/cache.py (2358 => 2359)</h4> \
<pre class="diff"><span> <span class="info">--- \
CalendarServer/branches/propfind-cache/twistedcaldav/cache.py 2008-04-28 17:35:23 UTC \
(rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/cache.py 2008-04-30 23:16:07 \
UTC (rev 2359) </span><span class="lines">@@ -15,12 +15,15 @@
</span><span class="cx"> ##
</span><span class="cx">
</span><span class="cx"> import uuid
</span><ins>+import time
+import os
</ins><span class="cx">
</span><ins>+from twisted.python.filepath import FilePath
</ins><span class="cx">
</span><span class="cx"> from twisted.web2.dav import davxml
</span><span class="cx"> from twisted.web2.http import HTTPError
</span><ins>+from twisted.web2.dav.xattrprops import xattrPropertyStore
</ins><span class="cx">
</span><del>-
</del><span class="cx"> class CacheTokensProperty(davxml.WebDAVTextElement):
</span><span class="cx"> namespace = davxml.twisted_private_namespace
</span><span class="cx"> name = "cacheTokens"
</span><span class="lines">@@ -102,3 +105,75 @@
</span><span class="cx"> return True
</span><span class="cx">
</span><span class="cx"> return False
</span><ins>+
+
+
+class PropfindCachingResource(object):
+ CACHE_TIMEOUT = 60*60 # 1 hour
+
+ propertyStoreFactory = xattrPropertyStore
+ observerFactory = CacheChangeObserver
+
+ def __init__(self, docroot, timeFunc=time.time):
+ self._docroot = docroot
+ self._responses = {}
+ self._observers = {}
+ self._timeFunc = timeFunc
+
+
+ def _tokenPathForURI(self, uri):
+ tokenPath = self._docroot
+
+ for childName in uri.split('/')[:4]:
+ tokenPath = tokenPath.child(childName)
+
+ return tokenPath
+
+
+ def _observerForURI(self, uri):
+ class FauxStaticResource(object):
+ def __init__(self, fp):
+ self.fp = fp
+
+ propertyStore = self.propertyStoreFactory(
+ FauxStaticResource(self._tokenPathForURI(uri)))
+
+ return self.observerFactory(propertyStore)
+
+
+ def _cacheResponse(self, response, request):
+ if getattr(request, 'cacheRequest', False):
+ if request.uri not in self._observers:
+ self._observers[request.uri] = self._observerForURI(request.uri)
+
+ self._responses[(request.method,
+ request.uri,
+ request.authnUser)] = (self._timeFunc(),
+ response)
+
+ return response
+
+
+ def renderHTTP(self, request):
+ key = (request.method, request.uri, request.authnUser)
+
+ if key in self._responses:
+ cacheTime, cachedResponse = self._responses[key]
+ if cacheTime + CACHE_TIMEOUT <= self._timeFunc():
+ if (request.uri in self._observers and
+ self._observers[request.uri]()):
+
+ return cachedResponse
+
+ def _renderResource(resource, request):
+ request.addResponseFilter(self._cacheResponse)
+ return resource.renderHTTP(request)
+
+ request.notInCache = True
+ d = request.locateResource(request.uri)
+ d.addCallback(_renderResource, request)
+ return d
+
+
+ def locateChild(self, request, segments):
+ return self, []
</ins></span></pre></div>
<a id="CalendarServerbranchespropfindcachetwistedcaldavrootpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/propfind-cache/twistedcaldav/root.py (2358 => 2359)</h4> <pre \
class="diff"><span> <span class="info">--- \
CalendarServer/branches/propfind-cache/twistedcaldav/root.py 2008-04-28 17:35:23 UTC \
(rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/root.py 2008-04-30 23:16:07 \
UTC (rev 2359) </span><span class="lines">@@ -86,19 +86,19 @@
</span><span class="cx"> # Figure out the "username" from the \
davxml.Principal object </span><span class="cx"> request.checkingSACL = \
True </span><span class="cx"> d = \
request.locateResource(authzUser.children[0].children[0].data) </span><del>- \
</del><ins>+
</ins><span class="cx"> def _checkedSACLCb(principal):
</span><span class="cx"> delattr(request, "checkingSACL")
</span><span class="cx"> username = principal.record.shortName
</span><del>-
</del><ins>+
</ins><span class="cx"> if RootResource.CheckSACL(username, \
self.saclService) != 0: </span><span class="cx"> \
log.msg("User '%s' is not enabled with the '%s' SACL" % (username, \
self.saclService,)) </span><span class="cx"> return \
Failure(HTTPError(403)) </span><del>-
</del><ins>+
</ins><span class="cx"> # Mark SACL's as having been checked so we \
can avoid doing it multiple times </span><span class="cx"> \
request.checkedSACL = True </span><span class="cx"> return True
</span><del>-
</del><ins>+
</ins><span class="cx"> d.addCallback(_checkedSACLCb)
</span><span class="cx"> return d
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchespropfindcachetwistedcaldavtesttest_cachepy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py (2358 => \
2359)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py 2008-04-28 \
17:35:23 UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/test/test_cache.py 2008-04-30 \
23:16:07 UTC (rev 2359) </span><span class="lines">@@ -18,9 +18,12 @@
</span><span class="cx">
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><span class="cx">
</span><ins>+from twisted.python.filepath import FilePath
+
</ins><span class="cx"> from twistedcaldav.cache import CacheChangeNotifier
</span><span class="cx"> from twistedcaldav.cache import CacheTokensProperty
</span><span class="cx"> from twistedcaldav.cache import CacheChangeObserver
</span><ins>+from twistedcaldav.cache import PropfindCachingResource
</ins><span class="cx">
</span><span class="cx"> from twistedcaldav.test.util import InMemoryPropertyStore
</span><span class="cx">
</span><span class="lines">@@ -147,3 +150,22 @@
</span><span class="cx">
</span><span class="cx"> self.assertEquals(self.observer.dataHasChanged(), \
True) </span><span class="cx"> \
self.assertEquals(self.observer.propertiesHaveChanged(), False) </span><ins>+
+
+
+class PropfindCachingResourceTests(TestCase):
+ # _tokenPathForURI tests
+ def test_tokenPathForURI(self):
+ pcr = PropfindCachingResource(FilePath('/root'))
+ paths = [
+ ('/principals/__uids__/557C330A-06E2-403B-BC24-CE3A253CDB5B/',
+ '/root/principals/__uids__/557C330A-06E2-403B-BC24-CE3A253CDB5B'),
+ ('/calendars/users/dreid/', '/root/calendars/users/dreid'),
+ ('/calendars/users/dreid/calendar', '/root/calendars/users/dreid')]
+
+ for inPath, outPath in paths:
+ self.assertEquals(pcr._tokenPathForURI(inPath).path, outPath)
+
+
+ def test_observerForURI(self):
+ pcr = PropfindCachingResource(FilePath('/root'))
</ins></span></pre></div>
<a id="CalendarServerbranchespropfindcachetwistedcaldavtesttest_rootpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py (2358 => \
2359)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py 2008-04-28 \
17:35:23 UTC (rev 2358)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/test/test_root.py 2008-04-30 \
23:16:07 UTC (rev 2359) </span><span class="lines">@@ -64,11 +64,11 @@
</span><span class="cx"> '/principals/',
</span><span class="cx"> directory)
</span><span class="cx">
</span><del>- # Otherwise the tests that never touch the root resource will
</del><ins>+ # Otherwise the tests that never touch the root resource will
</ins><span class="cx"> # fail on teardown.
</span><span class="cx"> principals.provision()
</span><span class="cx">
</span><del>- root = RootResource(self.docroot,
</del><ins>+ root = RootResource(self.docroot,
</ins><span class="cx"> \
principalCollections=[principals]) </span><span class="cx">
</span><span class="cx"> root.putChild('principals',
</span><span class="lines">@@ -78,8 +78,8 @@
</span><span class="cx"> portal.registerChecker(directory)
</span><span class="cx">
</span><span class="cx"> self.root = auth.AuthenticationWrapper(
</span><del>- root,
- portal,
</del><ins>+ root,
+ portal,
</ins><span class="cx"> \
credentialFactories=(basic.BasicCredentialFactory("Test realm"),), \
</span><span class="cx"> loginInterfaces=(auth.IPrincipal,)) </span><span \
class="cx"> </span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx"> def test_noSacls(self):
</span><span class="cx"> """
</span><span class="cx"> Test the behaviour of locateChild when SACLs are not \
enabled. </span><del>-
</del><ins>+
</ins><span class="cx"> should return a valid resource
</span><span class="cx"> """
</span><span class="cx"> self.root.resource.useSacls = False
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx">
</span><span class="cx"> def test_inSacls(self):
</span><span class="cx"> """
</span><del>- Test the behavior of locateChild when SACLs are enabled and the
</del><ins>+ Test the behavior of locateChild when SACLs are enabled and the
</ins><span class="cx"> user is in the SACL group
</span><span class="cx">
</span><span class="cx"> should return a valid resource
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx"> headers=http_headers.Headers({
</span><span class="cx"> 'Authorization': ['basic', '%s' % (
</span><span class="cx"> \
'dreid:dierd'.encode('base64'),)]})) </span><del>-
</del><ins>+
</ins><span class="cx"> resrc, segments = self.root.locateChild(request,
</span><span class="cx"> ['principals'])
</span><span class="cx">
</span><span class="lines">@@ -137,10 +137,10 @@
</span><span class="cx">
</span><span class="cx"> self.assertEquals(segments, [])
</span><span class="cx">
</span><del>- self.assertEquals(request.authzUser,
</del><ins>+ self.assertEquals(request.authzUser,
</ins><span class="cx"> davxml.Principal(
</span><span class="cx"> \
davxml.HRef('/principals/__uids__/5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1/'))) \
</span><del>- </del><ins>+
</ins><span class="cx"> d = defer.maybeDeferred(resrc.locateChild, request, \
['principals']) </span><span class="cx"> d.addCallback(_Cb)
</span><span class="cx">
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx"> """
</span><span class="cx"> Test the behavior of locateChild when SACLs are \
enabled and the </span><span class="cx"> user is not in the SACL group
</span><del>-
</del><ins>+
</ins><span class="cx"> should return a 403 forbidden response
</span><span class="cx"> """
</span><span class="cx"> self.root.resource.useSacls = True
</span><span class="lines">@@ -162,14 +162,14 @@
</span><span class="cx"> headers=http_headers.Headers({
</span><span class="cx"> 'Authorization': ['basic', '%s' % (
</span><span class="cx"> \
'wsanchez:zehcnasw'.encode('base64'),)]})) </span><del>-
</del><ins>+
</ins><span class="cx"> resrc, segments = self.root.locateChild(request,
</span><span class="cx"> ['principals'])
</span><span class="cx">
</span><span class="cx"> def _Eb(failure):
</span><span class="cx"> failure.trap(HTTPError)
</span><span class="cx"> self.assertEquals(failure.value.response.code, \
403) </span><del>-
</del><ins>+
</ins><span class="cx"> d = defer.maybeDeferred(resrc.locateChild, request, \
['principals']) </span><span class="cx"> d.addErrback(_Eb)
</span><span class="cx">
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> """
</span><span class="cx"> Test the behavior of locateChild when SACLs are \
enabled and the request </span><span class="cx"> is unauthenticated
</span><del>-
</del><ins>+
</ins><span class="cx"> should return a 401 UnauthorizedResponse
</span><span class="cx"> """
</span><span class="cx">
</span><span class="lines">@@ -208,7 +208,7 @@
</span><span class="cx">
</span><span class="cx"> def test_badCredentials(self):
</span><span class="cx"> """
</span><del>- Test the behavior of locateChild when SACLS are enabled, and
</del><ins>+ Test the behavior of locateChild when SACLS are enabled, and
</ins><span class="cx"> incorrect credentials are given.
</span><span class="cx">
</span><span class="cx"> should return a 401 UnauthorizedResponse
</span><span class="lines">@@ -222,14 +222,14 @@
</span><span class="cx"> headers=http_headers.Headers({
</span><span class="cx"> 'Authorization': ['basic', '%s' % (
</span><span class="cx"> \
'dreid:dreid'.encode('base64'),)]})) </span><del>-
</del><ins>+
</ins><span class="cx"> resrc, segments = self.root.locateChild(request,
</span><span class="cx"> ['principals'])
</span><span class="cx">
</span><span class="cx"> def _Eb(failure):
</span><span class="cx"> failure.trap(HTTPError)
</span><span class="cx"> self.assertEquals(failure.value.response.code, \
401) </span><del>-
</del><ins>+
</ins><span class="cx"> d = defer.maybeDeferred(resrc.locateChild, request, \
['principals']) </span><span class="cx"> d.addErrback(_Eb)
</span><span class="cx">
</span><span class="lines">@@ -241,7 +241,7 @@
</span><span class="cx">
</span><span class="cx"> if response.code != responsecode.FORBIDDEN:
</span><span class="cx"> self.fail("Incorrect response for \
DELETE /: %s" % (response.code,)) </span><del>-
</del><ins>+
</ins><span class="cx"> request = SimpleRequest(self.site, \
"DELETE", "/") </span><span class="cx"> return \
self.send(request, do_test) </span><span class="cx">
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">
</span><span class="cx"> if response.code != responsecode.FORBIDDEN:
</span><span class="cx"> self.fail("Incorrect response for COPY \
/: %s" % (response.code,)) </span><del>-
</del><ins>+
</ins><span class="cx"> request = SimpleRequest(
</span><span class="cx"> self.site,
</span><span class="cx"> "COPY",
</span><span class="lines">@@ -266,7 +266,7 @@
</span><span class="cx">
</span><span class="cx"> if response.code != responsecode.FORBIDDEN:
</span><span class="cx"> self.fail("Incorrect response for MOVE \
/: %s" % (response.code,)) </span><del>-
</del><ins>+
</ins><span class="cx"> request = SimpleRequest(
</span><span class="cx"> self.site,
</span><span class="cx"> "MOVE",
</span><span class="lines">@@ -274,4 +274,3 @@
</span><span class="cx"> \
headers=http_headers.Headers({"Destination":"/copy/"}) \
</span><span class="cx"> ) </span><span class="cx"> return \
self.send(request, do_test) </span><del>-
</del></span></pre>
</div>
</div>
</body>
</html>
_______________________________________________
calendarserver-changes mailing list
calendarserver-changes@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo/calendarserver-changes
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic