<!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" />
<title>[14885] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14885">14885</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2015-06-05 16:37:48 -0700 (Fri, 05 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Switch to using endpoint for talking to wiki server</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarserverprovisionrootpy">CalendarServer/trunk/calendarserver/provision/root.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretestutilpy">CalendarServer/trunk/txdav/common/datastore/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_utilpy">CalendarServer/trunk/txdav/who/test/test_util.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_wikipy">CalendarServer/trunk/txdav/who/test/test_wiki.py</a></li>
<li><a href="#CalendarServertrunktxdavwhoutilpy">CalendarServer/trunk/txdav/who/util.py</a></li>
<li><a href="#CalendarServertrunktxdavwhowikipy">CalendarServer/trunk/txdav/who/wiki.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarserverprovisionrootpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/provision/root.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx">                     )
</span><span class="cx"> 
</span><span class="cx">                     try:
</span><del>-                        uid = yield uidForAuthToken(token)
</del><ins>+                        uid = yield uidForAuthToken(token, wikiConfig[&quot;EndpointDescriptor&quot;])
</ins><span class="cx">                         if uid == &quot;unauthenticated&quot;:
</span><span class="cx">                             uid = None
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -392,8 +392,7 @@
</span><span class="cx">         &quot;Wiki&quot;: {
</span><span class="cx">             &quot;Enabled&quot;: False,
</span><span class="cx">             &quot;Cookie&quot;: &quot;cc.collabd_session_guid&quot;,
</span><del>-            &quot;CollabHost&quot;: &quot;localhost&quot;,
-            &quot;CollabPort&quot;: 4444,
</del><ins>+            &quot;EndpointDescriptor&quot;: &quot;http://localhost:4444/&quot;
</ins><span class="cx">         },
</span><span class="cx">     },
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -791,8 +791,7 @@
</span><span class="cx">     wikiServiceInfo = ConfigDict(
</span><span class="cx">         {
</span><span class="cx">             &quot;Enabled&quot;: True,
</span><del>-            &quot;CollabHost&quot;: &quot;localhost&quot;,
-            &quot;CollabPort&quot;: 4444,
</del><ins>+            &quot;EndpointDescriptor&quot;: &quot;http://localhost:4444/&quot;,
</ins><span class="cx">         }
</span><span class="cx">     )
</span><span class="cx">     directory = buildDirectory(
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_utilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_util.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -79,8 +79,7 @@
</span><span class="cx">                 &quot;Authentication&quot;: {
</span><span class="cx">                     &quot;Wiki&quot;: {
</span><span class="cx">                         &quot;Enabled&quot;: True,
</span><del>-                        &quot;CollabHost&quot;: &quot;localhost&quot;,
-                        &quot;CollabPort&quot;: 4444,
</del><ins>+                        &quot;EndpointDescriptor&quot;: &quot;http://localhost:4444/&quot;,
</ins><span class="cx">                     },
</span><span class="cx">                 },
</span><span class="cx">                 &quot;DirectoryService&quot;: {
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_wikipy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_wiki.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def test_service(self):
</span><del>-        service = DirectoryService(&quot;realm&quot;, &quot;localhost&quot;, 4444)
</del><ins>+        service = DirectoryService(&quot;realm&quot;, &quot;http://localhost:4444/&quot;)
</ins><span class="cx">         record = yield service.recordWithUID(u&quot;wiki-test&quot;)
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             record.shortNames[0],
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhoutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/util.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -278,8 +278,7 @@
</span><span class="cx">         aggregatedServices.append(
</span><span class="cx">             WikiDirectoryService(
</span><span class="cx">                 userDirectory.realmName,
</span><del>-                wikiServiceInfo.CollabHost,
-                wikiServiceInfo.CollabPort
</del><ins>+                wikiServiceInfo.EndpointDescriptor,
</ins><span class="cx">             )
</span><span class="cx">         )
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhowikipy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/wiki.py (14884 => 14885)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -24,8 +24,6 @@
</span><span class="cx"> ]
</span><span class="cx"> 
</span><span class="cx"> import json
</span><del>-from twext.internet.adaptendpoint import connect
-from twext.internet.gaiendpoint import GAIEndpoint
</del><span class="cx"> from twext.internet.gaiendpoint import MultiFailure
</span><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> from twext.who.directory import (
</span><span class="lines">@@ -46,8 +44,8 @@
</span><span class="cx"> from txweb2.auth.wrapper import UnauthorizedResponse
</span><span class="cx"> from txweb2.dav.resource import TwistedACLInheritable
</span><span class="cx"> from txweb2.http import HTTPError, StatusResponse
</span><ins>+from twisted.internet import endpoints
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> log = Logger()
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -80,10 +78,9 @@
</span><span class="cx">     ))
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def __init__(self, realmName, wikiHost, wikiPort):
</del><ins>+    def __init__(self, realmName, endpointDescriptor):
</ins><span class="cx">         BaseDirectoryService.__init__(self, realmName)
</span><del>-        self.wikiHost = wikiHost
-        self.wikiPort = wikiPort
</del><ins>+        self.endpointDescriptor = endpointDescriptor
</ins><span class="cx">         self._recordsByName = {}
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -181,8 +178,7 @@
</span><span class="cx">             )
</span><span class="cx">             access = yield accessForUserToWiki(
</span><span class="cx">                 uid.encode(&quot;utf-8&quot;), self.shortNames[0].encode(&quot;utf-8&quot;),
</span><del>-                host=self.service.wikiHost,
-                port=self.service.wikiPort,
</del><ins>+                self.service.endpointDescriptor
</ins><span class="cx">             )
</span><span class="cx">             self.log.debug(
</span><span class="cx">                 &quot;Wiki access result: {wiki}, {user}, {access}&quot;,
</span><span class="lines">@@ -380,7 +376,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> @inlineCallbacks
</span><del>-def uidForAuthToken(token, host=&quot;localhost&quot;, port=80):
</del><ins>+def uidForAuthToken(token, descriptor):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Send a GET request to the web auth service to retrieve the user record
</span><span class="cx">     uid associated with the provided auth token.
</span><span class="lines">@@ -391,8 +387,8 @@
</span><span class="cx">     @return: deferred returning a uid (C{str}) if successful, or
</span><span class="cx">         will raise WebAuthError otherwise.
</span><span class="cx">     &quot;&quot;&quot;
</span><del>-    url = &quot;http://%s:%d/auth/verify?auth_token=%s&quot; % (host, port, token,)
-    jsonResponse = (yield _getPage(url, host, port))
</del><ins>+    url = &quot;http://localhost/auth/verify?auth_token={}&quot;.format(token)
+    jsonResponse = (yield _getPage(url, descriptor))
</ins><span class="cx">     try:
</span><span class="cx">         response = json.loads(jsonResponse)
</span><span class="cx">     except Exception, e:
</span><span class="lines">@@ -408,7 +404,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-def accessForUserToWiki(user, wiki, host=&quot;localhost&quot;, port=4444):
</del><ins>+def accessForUserToWiki(user, wiki, descriptor):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Send a GET request to the wiki collabd service to retrieve the access level
</span><span class="cx">     the given user (uid) has to the given wiki (in wiki short-name
</span><span class="lines">@@ -423,29 +419,27 @@
</span><span class="cx">         status FORBIDDEN will errBack; an unknown wiki will have a status
</span><span class="cx">         of NOT_FOUND
</span><span class="cx">     &quot;&quot;&quot;
</span><del>-    url = &quot;http://%s:%s/cal/accessLevelForUserWikiCalendar/%s/%s&quot; % (
-        host, port, user, wiki
</del><ins>+    url = &quot;http://localhost/cal/accessLevelForUserWikiCalendar/{}/{}&quot;.format(
+        user, wiki
</ins><span class="cx">     )
</span><del>-    return _getPage(url, host, port)
</del><ins>+    return _getPage(url, descriptor)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-# FIXME: Why don't we use twisted.web.
-def _getPage(url, host, port):
</del><ins>+def _getPage(url, descriptor):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Fetch the body of the given url via HTTP, connecting to the given host
</span><span class="cx">     and port.
</span><span class="cx"> 
</span><span class="cx">     @param url: The URL to GET
</span><span class="cx">     @type url: C{str}
</span><del>-    @param host: The hostname to connect to
-    @type host: C{str}
-    @param port: The port number to connect to
-    @type port: C{int}
</del><ins>+    @param descriptor: The endpoint descriptor to use
+    @type descriptor: C{str}
</ins><span class="cx">     @return: A deferred; upon 200 success the body of the response is returned,
</span><span class="cx">         otherwise a twisted.web.error.Error is the result.
</span><span class="cx">     &quot;&quot;&quot;
</span><ins>+    point = endpoints.clientFromString(reactor, descriptor)
</ins><span class="cx">     factory = HTTPClientFactory(url)
</span><span class="cx">     factory.protocol = HTTPPageGetter
</span><del>-    connect(GAIEndpoint(reactor, host, port), factory)
</del><ins>+    point.connect(factory)
</ins><span class="cx">     return factory.deferred
</span></span></pre>
</div>
</div>

</body>
</html>