<!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>[13019] CalendarServer/branches/users/sagen/move2who-4/txdav/who/test/test_delegates.py</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/13019">13019</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-03-27 20:33:30 -0700 (Thu, 27 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix test_delegates.py</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavwhotesttest_delegatespy">CalendarServer/branches/users/sagen/move2who-4/txdav/who/test/test_delegates.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagenmove2who4txdavwhotesttest_delegatespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/test/test_delegates.py (13018 => 13019)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/test/test_delegates.py        2014-03-28 03:22:54 UTC (rev 13018)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/test/test_delegates.py        2014-03-28 03:33:30 UTC (rev 13019)
</span><span class="lines">@@ -20,11 +20,10 @@
</span><span class="cx">
</span><span class="cx"> from txdav.who.delegates import (
</span><span class="cx"> addDelegate, removeDelegate, delegatesOf, delegatedTo,
</span><del>- DirectoryService, RecordType as DelegateRecordType
</del><ins>+ RecordType as DelegateRecordType
</ins><span class="cx"> )
</span><span class="cx"> from txdav.who.groups import GroupCacher
</span><span class="cx"> from twext.who.idirectory import RecordType
</span><del>-from twext.who.test.test_xml import xmlService
</del><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx"> from twistedcaldav.test.util import StoreTestCase
</span><span class="cx">
</span><span class="lines">@@ -35,69 +34,63 @@
</span><span class="cx"> def setUp(self):
</span><span class="cx"> yield super(DelegationTest, self).setUp()
</span><span class="cx"> self.store = self.storeUnderTest()
</span><del>- self.xmlService = xmlService(self.mktemp(), xmlData=testXMLConfig)
- self.groupCacher = GroupCacher(self.xmlService)
- self.delegateService = DirectoryService(
- self.xmlService.realmName,
- self.store
- )
- self.delegateService.setMasterDirectory(self.xmlService)
</del><ins>+ self.groupCacher = GroupCacher(self.directory)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_directDelegation(self):
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx">
</span><del>- delegator = yield self.xmlService.recordWithUID(u"__wsanchez__")
- delegate1 = yield self.xmlService.recordWithUID(u"__sagen__")
- delegate2 = yield self.xmlService.recordWithUID(u"__cdaboo__")
</del><ins>+ delegator = yield self.directory.recordWithUID(u"__wsanchez1__")
+ delegate1 = yield self.directory.recordWithUID(u"__sagen1__")
+ delegate2 = yield self.directory.recordWithUID(u"__cdaboo1__")
</ins><span class="cx">
</span><span class="cx"> # Add 1 delegate
</span><span class="cx"> yield addDelegate(txn, delegator, delegate1, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True))
</span><del>- self.assertEquals(["__sagen__"], [d.uid for d in delegates])
</del><ins>+ self.assertEquals([u"__sagen1__"], [d.uid for d in delegates])
</ins><span class="cx"> delegators = (yield delegatedTo(txn, delegate1, True))
</span><del>- self.assertEquals(["__wsanchez__"], [d.uid for d in delegators])
</del><ins>+ self.assertEquals([u"__wsanchez1__"], [d.uid for d in delegators])
</ins><span class="cx">
</span><span class="cx"> yield txn.commit() # So delegateService will see the changes
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx">
</span><span class="cx"> # The "proxy-write" pseudoGroup will have one member
</span><del>- pseudoGroup = yield self.delegateService.recordWithShortName(
</del><ins>+ pseudoGroup = yield self.directory.recordWithShortName(
</ins><span class="cx"> DelegateRecordType.writeDelegateGroup,
</span><del>- u"__wsanchez__"
</del><ins>+ u"__wsanchez1__"
</ins><span class="cx"> )
</span><del>- self.assertEquals(pseudoGroup.uid, u"__wsanchez__#calendar-proxy-write")
</del><ins>+ self.assertEquals(pseudoGroup.uid, u"__wsanchez1__#calendar-proxy-write")
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> [r.uid for r in (yield pseudoGroup.members())],
</span><del>- [u"__sagen__"]
</del><ins>+ [u"__sagen1__"]
</ins><span class="cx"> )
</span><span class="cx"> # The "proxy-read" pseudoGroup will have no members
</span><del>- pseudoGroup = yield self.delegateService.recordWithShortName(
</del><ins>+ pseudoGroup = yield self.directory.recordWithShortName(
</ins><span class="cx"> DelegateRecordType.readDelegateGroup,
</span><del>- u"__wsanchez__"
</del><ins>+ u"__wsanchez1__"
</ins><span class="cx"> )
</span><del>- self.assertEquals(pseudoGroup.uid, u"__wsanchez__#calendar-proxy-read")
</del><ins>+ self.assertEquals(pseudoGroup.uid, u"__wsanchez1__#calendar-proxy-read")
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> [r.uid for r in (yield pseudoGroup.members())],
</span><span class="cx"> []
</span><span class="cx"> )
</span><span class="cx"> # The "proxy-write-for" pseudoGroup will have one member
</span><del>- pseudoGroup = yield self.delegateService.recordWithShortName(
</del><ins>+ pseudoGroup = yield self.directory.recordWithShortName(
</ins><span class="cx"> DelegateRecordType.writeDelegatorGroup,
</span><del>- u"__sagen__"
</del><ins>+ u"__sagen1__"
</ins><span class="cx"> )
</span><del>- self.assertEquals(pseudoGroup.uid, u"__sagen__#calendar-proxy-write-for")
</del><ins>+ self.assertEquals(pseudoGroup.uid, u"__sagen1__#calendar-proxy-write-for")
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> [r.uid for r in (yield pseudoGroup.members())],
</span><del>- [u"__wsanchez__"]
</del><ins>+ [u"__wsanchez1__"]
</ins><span class="cx"> )
</span><span class="cx"> # The "proxy-read-for" pseudoGroup will have no members
</span><del>- pseudoGroup = yield self.delegateService.recordWithShortName(
</del><ins>+ pseudoGroup = yield self.directory.recordWithShortName(
</ins><span class="cx"> DelegateRecordType.readDelegatorGroup,
</span><del>- u"__sagen__"
</del><ins>+ u"__sagen1__"
</ins><span class="cx"> )
</span><del>- self.assertEquals(pseudoGroup.uid, u"__sagen__#calendar-proxy-read-for")
</del><ins>+ self.assertEquals(pseudoGroup.uid, u"__sagen1__#calendar-proxy-read-for")
</ins><span class="cx"> self.assertEquals(
</span><span class="cx"> [r.uid for r in (yield pseudoGroup.members())],
</span><span class="cx"> []
</span><span class="lines">@@ -107,16 +100,16 @@
</span><span class="cx"> yield addDelegate(txn, delegator, delegate2, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx"> delegators = (yield delegatedTo(txn, delegate2, True))
</span><del>- self.assertEquals(["__wsanchez__"], [d.uid for d in delegators])
</del><ins>+ self.assertEquals([u"__wsanchez1__"], [d.uid for d in delegators])
</ins><span class="cx">
</span><span class="cx"> # Remove 1 delegate
</span><span class="cx"> yield removeDelegate(txn, delegator, delegate1, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True))
</span><del>- self.assertEquals(["__cdaboo__"], [d.uid for d in delegates])
</del><ins>+ self.assertEquals([u"__cdaboo1__"], [d.uid for d in delegates])
</ins><span class="cx"> delegators = (yield delegatedTo(txn, delegate1, True))
</span><span class="cx"> self.assertEquals(0, len(delegators))
</span><span class="cx">
</span><span class="lines">@@ -130,9 +123,9 @@
</span><span class="cx"> yield txn.commit() # So delegateService will see the changes
</span><span class="cx">
</span><span class="cx"> # Now set delegate assignments by using pseudoGroup.setMembers()
</span><del>- pseudoGroup = yield self.delegateService.recordWithShortName(
</del><ins>+ pseudoGroup = yield self.directory.recordWithShortName(
</ins><span class="cx"> DelegateRecordType.writeDelegateGroup,
</span><del>- u"__wsanchez__"
</del><ins>+ u"__wsanchez1__"
</ins><span class="cx"> )
</span><span class="cx"> yield pseudoGroup.setMembers([delegate1, delegate2])
</span><span class="cx">
</span><span class="lines">@@ -140,7 +133,7 @@
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx"> yield txn.commit()
</span><span class="lines">@@ -152,7 +145,7 @@
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__cdaboo__"]),
</del><ins>+ set([u"__cdaboo1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx"> yield txn.commit()
</span><span class="lines">@@ -162,10 +155,10 @@
</span><span class="cx"> def test_indirectDelegation(self):
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx">
</span><del>- delegator = yield self.xmlService.recordWithUID(u"__wsanchez__")
- delegate1 = yield self.xmlService.recordWithUID(u"__sagen__")
- group1 = yield self.xmlService.recordWithUID(u"__top_group_1__")
- group2 = yield self.xmlService.recordWithUID(u"__sub_group_1__")
</del><ins>+ delegator = yield self.directory.recordWithUID(u"__wsanchez1__")
+ delegate1 = yield self.directory.recordWithUID(u"__sagen1__")
+ group1 = yield self.directory.recordWithUID(u"__top_group_1__")
+ group2 = yield self.directory.recordWithUID(u"__sub_group_1__")
</ins><span class="cx">
</span><span class="cx"> # Add group delegate, but before the group membership has been
</span><span class="cx"> # pulled in
</span><span class="lines">@@ -186,11 +179,11 @@
</span><span class="cx"> yield self.groupCacher.refreshGroup(txn, group2.uid)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__", "__glyph__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__", u"__glyph1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx"> delegators = (yield delegatedTo(txn, delegate1, True))
</span><del>- self.assertEquals(["__wsanchez__"], [d.uid for d in delegators])
</del><ins>+ self.assertEquals([u"__wsanchez1__"], [d.uid for d in delegators])
</ins><span class="cx">
</span><span class="cx"> # Verify we can ask for all delegated-to groups
</span><span class="cx"> yield addDelegate(txn, delegator, group2, True)
</span><span class="lines">@@ -203,15 +196,15 @@
</span><span class="cx"> yield addDelegate(txn, delegator, delegate1, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__", "__glyph__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__", u"__glyph1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> # Add a member to the group; they become a delegate
</span><span class="cx"> newSet = set()
</span><del>- for name in (u"wsanchez", u"cdaboo", u"sagen", u"glyph", u"dre"):
</del><ins>+ for name in (u"wsanchez1", u"cdaboo1", u"sagen1", u"glyph1", u"dre1"):
</ins><span class="cx"> record = (
</span><del>- yield self.xmlService.recordWithShortName(RecordType.user, name)
</del><ins>+ yield self.directory.recordWithShortName(RecordType.user, name)
</ins><span class="cx"> )
</span><span class="cx"> newSet.add(record.uid)
</span><span class="cx"> groupID, name, membershipHash = (yield txn.groupByUID(group1.uid))
</span><span class="lines">@@ -220,7 +213,7 @@
</span><span class="cx"> )
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__", "__glyph__", "__dre__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__", u"__glyph1__", u"__dre1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx">
</span><span class="lines">@@ -228,7 +221,7 @@
</span><span class="cx"> yield removeDelegate(txn, delegator, group1, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__", "__cdaboo__"]),
</del><ins>+ set([u"__sagen1__", u"__cdaboo1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx">
</span><span class="lines">@@ -236,89 +229,7 @@
</span><span class="cx"> yield removeDelegate(txn, delegator, group2, True)
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><span class="cx"> self.assertEquals(
</span><del>- set(["__sagen__"]),
</del><ins>+ set([u"__sagen1__"]),
</ins><span class="cx"> set([d.uid for d in delegates])
</span><span class="cx"> )
</span><span class="cx"> yield txn.commit()
</span><del>-
-
-
-
-
-testXMLConfig = """<?xml version="1.0" encoding="utf-8"?>
-
-<directory realm="xyzzy">
-
- <record type="user">
- <uid>__wsanchez__</uid>
- <guid>3BDCB954-84D5-4F6D-8035-EAC19A6D6E1F</guid>
- <short-name>wsanchez</short-name>
- <short-name>wilfredo_sanchez</short-name>
- <full-name>Wilfredo Sanchez</full-name>
- <password>zehcnasw</password>
- <email>wsanchez@bitbucket.calendarserver.org</email>
- <email>wsanchez@devnull.twistedmatrix.com</email>
- </record>
-
- <record type="user">
- <uid>__glyph__</uid>
- <guid>9064DF91-1DBC-4E07-9C2B-6839B0953876</guid>
- <short-name>glyph</short-name>
- <full-name>Glyph Lefkowitz</full-name>
- <password>hpylg</password>
- <email>glyph@bitbucket.calendarserver.org</email>
- <email>glyph@devnull.twistedmatrix.com</email>
- </record>
-
- <record type="user">
- <uid>__sagen__</uid>
- <guid>4AD155CB-AE9B-475F-986C-E08A7537893E</guid>
- <short-name>sagen</short-name>
- <full-name>Morgen Sagen</full-name>
- <password>negas</password>
- <email>sagen@bitbucket.calendarserver.org</email>
- <email>shared@example.com</email>
- </record>
-
- <record type="user">
- <uid>__cdaboo__</uid>
- <guid>7D45CB10-479E-456B-B54D-528958C5734B</guid>
- <short-name>cdaboo</short-name>
- <full-name>Cyrus Daboo</full-name>
- <password>suryc</password>
- <email>cdaboo@bitbucket.calendarserver.org</email>
- </record>
-
- <record type="user">
- <uid>__dre__</uid>
- <guid>CFC88493-DBFF-42B9-ADC7-9B3DA0B0769B</guid>
- <short-name>dre</short-name>
- <full-name>Andre LaBranche</full-name>
- <password>erd</password>
- <email>dre@bitbucket.calendarserver.org</email>
- <email>shared@example.com</email>
- </record>
-
- <record type="group">
- <uid>__top_group_1__</uid>
- <guid>49B350C6-9611-477B-94D9-5516B13856AB</guid>
- <short-name>top-group-1</short-name>
- <full-name>Top Group 1</full-name>
- <email>topgroup1@example.com</email>
- <member-uid>__wsanchez__</member-uid>
- <member-uid>__glyph__</member-uid>
- <member-uid>__sub_group_1__</member-uid>
- </record>
-
- <record type="group">
- <uid>__sub_group_1__</uid>
- <guid>86144F73-345A-4097-82F1-B782672087C7</guid>
- <short-name>sub-group-1</short-name>
- <full-name>Sub Group 1</full-name>
- <email>subgroup1@example.com</email>
- <member-uid>__sagen__</member-uid>
- <member-uid>__cdaboo__</member-uid>
- </record>
-
-</directory>
-"""
</del></span></pre>
</div>
</div>
</body>
</html>