[CalendarServer-changes] [14885] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 5 16:37:48 PDT 2015
Revision: 14885
http://trac.calendarserver.org//changeset/14885
Author: sagen at apple.com
Date: 2015-06-05 16:37:48 -0700 (Fri, 05 Jun 2015)
Log Message:
-----------
Switch to using endpoint for talking to wiki server
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/provision/root.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
CalendarServer/trunk/txdav/common/datastore/test/util.py
CalendarServer/trunk/txdav/who/test/test_util.py
CalendarServer/trunk/txdav/who/test/test_wiki.py
CalendarServer/trunk/txdav/who/util.py
CalendarServer/trunk/txdav/who/wiki.py
Modified: CalendarServer/trunk/calendarserver/provision/root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/root.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/calendarserver/provision/root.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -236,7 +236,7 @@
)
try:
- uid = yield uidForAuthToken(token)
+ uid = yield uidForAuthToken(token, wikiConfig["EndpointDescriptor"])
if uid == "unauthenticated":
uid = None
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -392,8 +392,7 @@
"Wiki": {
"Enabled": False,
"Cookie": "cc.collabd_session_guid",
- "CollabHost": "localhost",
- "CollabPort": 4444,
+ "EndpointDescriptor": "http://localhost:4444/"
},
},
Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/util.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -791,8 +791,7 @@
wikiServiceInfo = ConfigDict(
{
"Enabled": True,
- "CollabHost": "localhost",
- "CollabPort": 4444,
+ "EndpointDescriptor": "http://localhost:4444/",
}
)
directory = buildDirectory(
Modified: CalendarServer/trunk/txdav/who/test/test_util.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_util.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/txdav/who/test/test_util.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -79,8 +79,7 @@
"Authentication": {
"Wiki": {
"Enabled": True,
- "CollabHost": "localhost",
- "CollabPort": 4444,
+ "EndpointDescriptor": "http://localhost:4444/",
},
},
"DirectoryService": {
Modified: CalendarServer/trunk/txdav/who/test/test_wiki.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_wiki.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/txdav/who/test/test_wiki.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -39,7 +39,7 @@
@inlineCallbacks
def test_service(self):
- service = DirectoryService("realm", "localhost", 4444)
+ service = DirectoryService("realm", "http://localhost:4444/")
record = yield service.recordWithUID(u"wiki-test")
self.assertEquals(
record.shortNames[0],
Modified: CalendarServer/trunk/txdav/who/util.py
===================================================================
--- CalendarServer/trunk/txdav/who/util.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/txdav/who/util.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -278,8 +278,7 @@
aggregatedServices.append(
WikiDirectoryService(
userDirectory.realmName,
- wikiServiceInfo.CollabHost,
- wikiServiceInfo.CollabPort
+ wikiServiceInfo.EndpointDescriptor,
)
)
Modified: CalendarServer/trunk/txdav/who/wiki.py
===================================================================
--- CalendarServer/trunk/txdav/who/wiki.py 2015-06-05 17:14:58 UTC (rev 14884)
+++ CalendarServer/trunk/txdav/who/wiki.py 2015-06-05 23:37:48 UTC (rev 14885)
@@ -24,8 +24,6 @@
]
import json
-from twext.internet.adaptendpoint import connect
-from twext.internet.gaiendpoint import GAIEndpoint
from twext.internet.gaiendpoint import MultiFailure
from twext.python.log import Logger
from twext.who.directory import (
@@ -46,8 +44,8 @@
from txweb2.auth.wrapper import UnauthorizedResponse
from txweb2.dav.resource import TwistedACLInheritable
from txweb2.http import HTTPError, StatusResponse
+from twisted.internet import endpoints
-
log = Logger()
@@ -80,10 +78,9 @@
))
- def __init__(self, realmName, wikiHost, wikiPort):
+ def __init__(self, realmName, endpointDescriptor):
BaseDirectoryService.__init__(self, realmName)
- self.wikiHost = wikiHost
- self.wikiPort = wikiPort
+ self.endpointDescriptor = endpointDescriptor
self._recordsByName = {}
@@ -181,8 +178,7 @@
)
access = yield accessForUserToWiki(
uid.encode("utf-8"), self.shortNames[0].encode("utf-8"),
- host=self.service.wikiHost,
- port=self.service.wikiPort,
+ self.service.endpointDescriptor
)
self.log.debug(
"Wiki access result: {wiki}, {user}, {access}",
@@ -380,7 +376,7 @@
@inlineCallbacks
-def uidForAuthToken(token, host="localhost", port=80):
+def uidForAuthToken(token, descriptor):
"""
Send a GET request to the web auth service to retrieve the user record
uid associated with the provided auth token.
@@ -391,8 +387,8 @@
@return: deferred returning a uid (C{str}) if successful, or
will raise WebAuthError otherwise.
"""
- url = "http://%s:%d/auth/verify?auth_token=%s" % (host, port, token,)
- jsonResponse = (yield _getPage(url, host, port))
+ url = "http://localhost/auth/verify?auth_token={}".format(token)
+ jsonResponse = (yield _getPage(url, descriptor))
try:
response = json.loads(jsonResponse)
except Exception, e:
@@ -408,7 +404,7 @@
-def accessForUserToWiki(user, wiki, host="localhost", port=4444):
+def accessForUserToWiki(user, wiki, descriptor):
"""
Send a GET request to the wiki collabd service to retrieve the access level
the given user (uid) has to the given wiki (in wiki short-name
@@ -423,29 +419,27 @@
status FORBIDDEN will errBack; an unknown wiki will have a status
of NOT_FOUND
"""
- url = "http://%s:%s/cal/accessLevelForUserWikiCalendar/%s/%s" % (
- host, port, user, wiki
+ url = "http://localhost/cal/accessLevelForUserWikiCalendar/{}/{}".format(
+ user, wiki
)
- return _getPage(url, host, port)
+ return _getPage(url, descriptor)
-# FIXME: Why don't we use twisted.web.
-def _getPage(url, host, port):
+def _getPage(url, descriptor):
"""
Fetch the body of the given url via HTTP, connecting to the given host
and port.
@param url: The URL to GET
@type url: C{str}
- @param host: The hostname to connect to
- @type host: C{str}
- @param port: The port number to connect to
- @type port: C{int}
+ @param descriptor: The endpoint descriptor to use
+ @type descriptor: C{str}
@return: A deferred; upon 200 success the body of the response is returned,
otherwise a twisted.web.error.Error is the result.
"""
+ point = endpoints.clientFromString(reactor, descriptor)
factory = HTTPClientFactory(url)
factory.protocol = HTTPPageGetter
- connect(GAIEndpoint(reactor, host, port), factory)
+ point.connect(factory)
return factory.deferred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150605/21cd6169/attachment.html>
More information about the calendarserver-changes
mailing list