<!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>[12968] CalendarServer/branches/users/sagen/move2who-4</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/12968">12968</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-03-18 19:32:52 -0700 (Tue, 18 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow recordsMatchingFields to restrict to a single recordType; fix other tests.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4confauthaccountstestxml">CalendarServer/branches/users/sagen/move2who-4/conf/auth/accounts-test.xml</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavmethodreportpy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/method/report.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavsharingpy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavdpsclientpy">CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavdpstesttestxml">CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test.xml</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavdpstesttest_clientpy">CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test_client.py</a></li>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavwhodirectorypy">CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagenmove2who4confauthaccountstestxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/conf/auth/accounts-test.xml (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/conf/auth/accounts-test.xml        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/conf/auth/accounts-test.xml        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -290,6 +290,76 @@
</span><span class="cx"> <email>user25@example.com</email>
</span><span class="cx"> </record>
</span><span class="cx">
</span><ins>+ <record type="user">
+ <short-name>public01</short-name>
+ <uid>public01</uid>
+ <password>public01</password>
+ <full-name>Public 01</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public02</short-name>
+ <uid>public02</uid>
+ <password>public02</password>
+ <full-name>Public 02</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public03</short-name>
+ <uid>public03</uid>
+ <password>public03</password>
+ <full-name>Public 03</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public04</short-name>
+ <uid>public04</uid>
+ <password>public04</password>
+ <full-name>Public 04</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public05</short-name>
+ <uid>public05</uid>
+ <password>public05</password>
+ <full-name>Public 05</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public06</short-name>
+ <uid>public06</uid>
+ <password>public06</password>
+ <full-name>Public 06</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public07</short-name>
+ <uid>public07</uid>
+ <password>public07</password>
+ <full-name>Public 07</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public08</short-name>
+ <uid>public08</uid>
+ <password>public08</password>
+ <full-name>Public 08</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public09</short-name>
+ <uid>public09</uid>
+ <password>public09</password>
+ <full-name>Public 09</full-name>
+ </record>
+
+ <record type="user">
+ <short-name>public10</short-name>
+ <uid>public10</uid>
+ <password>public10</password>
+ <full-name>Public 10</full-name>
+ </record>
+
</ins><span class="cx"> <record type="group">
</span><span class="cx"> <uid>group01</uid>
</span><span class="cx"> <short-name>group01</short-name>
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavmethodreportpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/method/report.py (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/method/report.py        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/method/report.py        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx">
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def http_REPORT(self, request):
</span><span class="cx"> """
</span><span class="lines">@@ -58,7 +59,7 @@
</span><span class="cx"> try:
</span><span class="cx"> doc = (yield davXMLFromStream(request.stream))
</span><span class="cx"> except ValueError, e:
</span><del>- log.error("Error while handling REPORT body: %s" % (e,))
</del><ins>+ log.error("Error while handling REPORT body: {err}", err=str(e))
</ins><span class="cx"> raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, str(e)))
</span><span class="cx">
</span><span class="cx"> if doc is None:
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4twistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/sharing.py (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/sharing.py        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/sharing.py        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -62,24 +62,25 @@
</span><span class="cx"> """
</span><span class="cx"> if config.Sharing.Enabled:
</span><span class="cx">
</span><ins>+ @inlineCallbacks
</ins><span class="cx"> def invitePropertyElement(invitation, includeUID=True):
</span><span class="cx">
</span><span class="cx"> userid = "urn:uuid:" + invitation.shareeUID
</span><del>- principal = self.principalForUID(invitation.shareeUID)
</del><ins>+ principal = yield self.principalForUID(invitation.shareeUID)
</ins><span class="cx"> cn = principal.displayName() if principal else invitation.shareeUID
</span><del>- return customxml.InviteUser(
</del><ins>+ returnValue(customxml.InviteUser(
</ins><span class="cx"> customxml.UID.fromString(invitation.uid) if includeUID else None,
</span><span class="cx"> element.HRef.fromString(userid),
</span><span class="cx"> customxml.CommonName.fromString(cn),
</span><span class="cx"> customxml.InviteAccess(invitationBindModeToXMLMap[invitation.mode]()),
</span><span class="cx"> invitationBindStatusToXMLMap[invitation.status](),
</span><del>- )
</del><ins>+ ))
</ins><span class="cx">
</span><span class="cx"> # See if this property is on the shared calendar
</span><span class="cx"> if self.isShared():
</span><span class="cx"> invitations = yield self.validateInvites(request)
</span><span class="cx"> returnValue(customxml.Invite(
</span><del>- *[invitePropertyElement(invitation) for invitation in invitations]
</del><ins>+ *[(yield invitePropertyElement(invitation)) for invitation in invitations]
</ins><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> # See if it is on the sharee calendar
</span><span class="lines">@@ -89,7 +90,7 @@
</span><span class="cx"> invitations = yield original.allInvitations()
</span><span class="cx"> invitations = yield self.validateInvites(request, invitations)
</span><span class="cx">
</span><del>- ownerPrincipal = self.principalForUID(self._newStoreObject.ownerHome().uid())
</del><ins>+ ownerPrincipal = yield self.principalForUID(self._newStoreObject.ownerHome().uid())
</ins><span class="cx"> # FIXME: use urn:uuid in all cases
</span><span class="cx"> if self.isCalendarCollection():
</span><span class="cx"> owner = ownerPrincipal.principalURL()
</span><span class="lines">@@ -102,7 +103,7 @@
</span><span class="cx"> element.HRef.fromString(owner),
</span><span class="cx"> customxml.CommonName.fromString(ownerCN),
</span><span class="cx"> ),
</span><del>- *[invitePropertyElement(invitation, includeUID=False) for invitation in invitations]
</del><ins>+ *[(yield invitePropertyElement(invitation, includeUID=False)) for invitation in invitations]
</ins><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> returnValue(None)
</span><span class="lines">@@ -266,8 +267,8 @@
</span><span class="cx"> any access at all.
</span><span class="cx"> """
</span><span class="cx"> if self._newStoreObject.direct():
</span><del>- owner = self.principalForUID(self._newStoreObject.ownerHome().uid())
- sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
</del><ins>+ owner = yield self.principalForUID(self._newStoreObject.ownerHome().uid())
+ sharee = yield self.principalForUID(self._newStoreObject.viewerHome().uid())
</ins><span class="cx"> if owner.record.recordType == WikiDirectoryService.recordType_wikis:
</span><span class="cx"> # Access level comes from what the wiki has granted to the
</span><span class="cx"> # sharee
</span><span class="lines">@@ -320,7 +321,7 @@
</span><span class="cx"> assert self._isShareeResource, "Only call this for a sharee resource"
</span><span class="cx"> assert self.isCalendarCollection() or self.isAddressBookCollection(), "Only call this for a address book or calendar resource"
</span><span class="cx">
</span><del>- sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
</del><ins>+ sharee = yield self.principalForUID(self._newStoreObject.viewerHome().uid())
</ins><span class="cx"> access = yield self._checkAccessControl()
</span><span class="cx">
</span><span class="cx"> if access == "original" and not self._newStoreObject.ownerHome().external():
</span><span class="lines">@@ -411,7 +412,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> # First try to resolve as a principal
</span><del>- principal = self.principalForCalendarUserAddress(userid)
</del><ins>+ principal = yield self.principalForCalendarUserAddress(userid)
</ins><span class="cx"> if principal:
</span><span class="cx"> if request:
</span><span class="cx"> ownerPrincipal = (yield self.ownerPrincipal(request))
</span><span class="lines">@@ -504,7 +505,7 @@
</span><span class="cx"> def inviteSingleUserToShare(self, userid, cn, ace, summary, request): #@UnusedVariable
</span><span class="cx">
</span><span class="cx"> # We currently only handle local users
</span><del>- sharee = self.principalForCalendarUserAddress(userid)
</del><ins>+ sharee = yield self.principalForCalendarUserAddress(userid)
</ins><span class="cx"> if not sharee:
</span><span class="cx"> returnValue(False)
</span><span class="cx">
</span><span class="lines">@@ -521,7 +522,7 @@
</span><span class="cx"> def uninviteSingleUserFromShare(self, userid, aces, request): #@UnusedVariable
</span><span class="cx">
</span><span class="cx"> # Cancel invites - we'll just use whatever userid we are given
</span><del>- sharee = self.principalForCalendarUserAddress(userid)
</del><ins>+ sharee = yield self.principalForCalendarUserAddress(userid)
</ins><span class="cx"> if not sharee:
</span><span class="cx"> returnValue(False)
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavdpsclientpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/dps/client.py        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -191,7 +191,7 @@
</span><span class="cx">
</span><span class="cx"> # MOVE2WHO, REMOVE THIS HACK TOO:
</span><span class="cx"> if not isinstance(shortName, unicode):
</span><del>- log.warn("Need to change shortName to unicode")
</del><ins>+ # log.warn("Need to change shortName to unicode")
</ins><span class="cx"> shortName = shortName.decode("utf-8")
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -206,7 +206,7 @@
</span><span class="cx"> def recordWithUID(self, uid):
</span><span class="cx"> # MOVE2WHO, REMOVE THIS:
</span><span class="cx"> if not isinstance(uid, unicode):
</span><del>- log.warn("Need to change uid to unicode")
</del><ins>+ # log.warn("Need to change uid to unicode")
</ins><span class="cx"> uid = uid.decode("utf-8")
</span><span class="cx">
</span><span class="cx"> return self._call(
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavdpstesttestxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test.xml (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test.xml        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test.xml        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -114,4 +114,10 @@
</span><span class="cx"> <member-uid>__alyssa__</member-uid>
</span><span class="cx"> </record>
</span><span class="cx">
</span><ins>+ <record type="location">
+ <uid>__sanchezoffice__</uid>
+ <short-name>sanchezoffice</short-name>
+ <full-name>Sanchez Office</full-name>
+ </record>
+
</ins><span class="cx"> </directory>
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavdpstesttest_clientpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test_client.py (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test_client.py        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/dps/test/test_client.py        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -16,6 +16,7 @@
</span><span class="cx">
</span><span class="cx"> import os
</span><span class="cx">
</span><ins>+from twext.who.expression import Operand, MatchType, MatchFlags
</ins><span class="cx"> from twext.who.idirectory import RecordType
</span><span class="cx"> from twisted.cred.credentials import calcResponse, calcHA1, calcHA2
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, succeed
</span><span class="lines">@@ -147,6 +148,41 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def test_recordsMatchingFields_anyType(self):
+ fields = (
+ (u"fullNames", "anche", MatchFlags.caseInsensitive, MatchType.contains),
+ )
+ records = (yield self.directory.recordsMatchingFields(
+ fields, operand=Operand.OR, recordType=None
+ ))
+ matchingShortNames = set()
+ for r in records:
+ for shortName in r.shortNames:
+ matchingShortNames.add(shortName)
+ self.assertTrue("dre" in matchingShortNames)
+ self.assertTrue("wsanchez" in matchingShortNames)
+ self.assertTrue("sanchezoffice" in matchingShortNames)
+
+
+ @inlineCallbacks
+ def test_recordsMatchingFields_oneType(self):
+ fields = (
+ (u"fullNames", "anche", MatchFlags.caseInsensitive, MatchType.contains),
+ )
+ records = (yield self.directory.recordsMatchingFields(
+ fields, operand=Operand.OR, recordType=RecordType.user
+ ))
+ matchingShortNames = set()
+ for r in records:
+ for shortName in r.shortNames:
+ matchingShortNames.add(shortName)
+ self.assertTrue("dre" in matchingShortNames)
+ self.assertTrue("wsanchez" in matchingShortNames)
+ # This location should *not* appear in the results
+ self.assertFalse("sanchezoffice" in matchingShortNames)
+
+
+ @inlineCallbacks
</ins><span class="cx"> def test_verifyPlaintextPassword(self):
</span><span class="cx"> expectations = (
</span><span class="cx"> (testPassword, True), # Correct
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py (12967 => 12968)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-19 01:26:08 UTC (rev 12967)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-19 02:32:52 UTC (rev 12968)
</span><span class="lines">@@ -142,6 +142,22 @@
</span><span class="cx"> subExpressions.append(subExpression)
</span><span class="cx">
</span><span class="cx"> expression = CompoundExpression(subExpressions, operand)
</span><ins>+
+ # AND in the recordType if passed in
+ if recordType is not None:
+ typeExpression = MatchExpression(
+ self.fieldName.recordType,
+ recordType,
+ MatchType.equals,
+ MatchFlags.none
+ )
+ expression = CompoundExpression(
+ [
+ expression,
+ typeExpression
+ ],
+ Operand.AND
+ )
</ins><span class="cx"> return self.recordsFromExpression(expression)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -289,7 +305,7 @@
</span><span class="cx"> self.__class__.__name__,
</span><span class="cx"> self.service.realmName,
</span><span class="cx"> self.recordType.name,
</span><del>- self.shortNames,
</del><ins>+ # self.shortNames, # MOVE2WHO FIXME: is this needed? it's not hashable
</ins><span class="cx"> self.uid,
</span><span class="cx"> self.hasCalendars,
</span><span class="cx"> ))
</span></span></pre>
</div>
</div>
</body>
</html>