1 paula.plonepas package readme
2 =============================
4 Set things up (thx optilux)
5 ---------------------------
7 >>> from Products.Five.testbrowser import Browser
8 >>> browser = Browser()
9 >>> portal_url = self.portal.absolute_url()
11 The following is useful when writing and debugging testbrowser tests. It lets
12 us see error messages properly.
14 >>> browser.handleErrors = False
15 >>> self.portal.error_log._ignored_exceptions = ()
17 We then turn off the various portlets, because they sometimes duplicate links
18 and text (e.g. the navtree, the recent recent items listing) that we wish to
19 test for in our own views. Having no portlets makes things easier.
21 >>> from zope.component import getMultiAdapter, getUtility
22 >>> from plone.portlets.interfaces import IPortletManager
23 >>> from plone.portlets.interfaces import IPortletAssignmentMapping
25 >>> left_column = getUtility(IPortletManager, name=u"plone.leftcolumn")
26 >>> left_assignable = getMultiAdapter((self.portal, left_column), IPortletAssignmentMapping)
27 >>> for name in left_assignable.keys():
28 ... del left_assignable[name]
30 >>> right_column = getUtility(IPortletManager, name=u"plone.rightcolumn")
31 >>> right_assignable = getMultiAdapter((self.portal, right_column), IPortletAssignmentMapping)
32 >>> for name in right_assignable.keys():
33 ... del right_assignable[name]
39 Make sure all components have been registered
41 >>> from zope.app.security.interfaces import IAuthentication
42 >>> from paula.authentication.interfaces import ILocalAuthenticatorPlugin
43 >>> from paula.authentication.interfaces import \
44 ... ICredentialsFromMappingPlugin
45 >>> from paula.authentication.interfaces import IAuthProviders
46 >>> from paula.properties.interfaces import IPropertyProviders
47 >>> from paula.groups.interfaces import IMemberships
49 >>> pau = getUtility(IAuthentication, context=portal)
50 >>> pau.__parent__ = portal
52 <PluggableAuthentication at /plone/>
53 >>> ap = getUtility(ILocalAuthenticatorPlugin, context=portal,
54 ... name='Paula PAU AuthenticatorPlugin')
55 >>> ap.__parent__ = portal
57 <AuthenticatorPlugin at /plone/>
58 >>> cp = getUtility(ICredentialsFromMappingPlugin, context=portal,
59 ... name='Paula PAU CredentialsFromMappingPlugin')
60 >>> cp.__parent__ = portal
62 <CredentialsFromMappingPlugin at /plone/>
63 >>> apu = getUtility(IAuthProviders, context=portal)
64 >>> apu.__parent__ = portal
66 <RWAuthProviders at /plone/>
67 >>> ppu = getUtility(IPropertyProviders, context=portal)
68 >>> ppu.__parent__ = portal
70 <RWPropertyProviders at /plone/>
71 >>> mu = getUtility(IMemberships, context=portal)
72 >>> mu.__parent__ = portal
74 <RWMemberships at /plone/>
77 Add a user to the site
79 >>> from zope.component import createObject
80 >>> user = createObject('paula.ploneexamples.MinimalPloneUser', "user")
81 >>> user.title = u"user"
82 >>> user.password = u'password'
83 >>> user.email = u"foo@bar.com"
84 >>> user.realname = u"Foo Bar"
85 >>> portal['user'] = user
87 credentials for the user, for PAU/Paula testing
89 >>> from zope.publisher.interfaces import IRequest
90 >>> pau_req = UserDict(login="user", password="password")
91 >>> alsoProvides(pau_req, IRequest)
96 >>> g1 = createObject('paula.ploneexamples.BasicGroup', 'g1')
98 >>> g1.members = ('user',)
100 >>> g2 = createObject('paula.ploneexamples.BasicGroup', 'g2')
102 >>> g2.members = ('g1',)
104 >>> portal['g1'] = g1
105 >>> portal['g2'] = g2
108 Test PAU/Paula subsystem
110 >>> principal = pau.authenticate(pau_req)
116 >>> principal.realname
123 Paula PAS auth plugin
125 >>> p = portal.acl_users.paula_auth.authenticateCredentials(pau_req)
131 >>> from Products.PlonePAS.plugins.ufactory import PloneUser
132 >>> pu = PloneUser(p[1])
136 Paula PAS properties plugin
138 >>> psheet = portal.acl_users.paula_properties.getPropertiesForUser(pu)
139 >>> psheet.propertyItems()
140 [('email', u'foo@bar.com'), ('realname', u'Foo Bar')]
142 Paula PAS group plugin
144 >>> portal.acl_users.paula_groups.getGroupsForPrincipal(pu)
150 >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
151 >>> browser.getControl(name='__ac_name').value = u"user"
152 >>> browser.getControl(name='__ac_password').value = u"wrong"
153 >>> browser.getControl(name='submit').click()
154 >>> 'Login failed' in browser.contents
157 >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
158 >>> browser.getControl(name='__ac_name').value = u"user"
159 >>> browser.getControl(name='__ac_password').value = u"password"
160 >>> browser.getControl(name='submit').click()
161 >>> 'Login failed' in browser.contents