1 paula.pasplugins integration test
2 =================================
4 Supposed to test integration with Plone and PAU.
7 PAU is up and running with our real and fake plugins
8 ----------------------------------------------------
10 First of all, there should be a PAU and it should know about the credentials
13 >>> from zope.app.authentication.interfaces import \
14 ... IPluggableAuthentication
15 >>> from zope.app.authentication.interfaces import \
16 ... ICredentialsPlugin
17 >>> from paula.pasplugins.plugins.paucred import CREDPLUG_NAME
19 >>> pau = getUtility(IPluggableAuthentication)
20 >>> CREDPLUG_NAME in pau.credentialsPlugins
23 >>> credplug = getUtility(ICredentialsPlugin, name=CREDPLUG_NAME)
24 >>> credplugs = list( pau.getCredentialsPlugins() )
27 >>> credplugs[0][0] == CREDPLUG_NAME
29 >>> credplugs[0][1] is credplug
33 For further testing we use a fake authenticator plugin:
35 >>> from zope.app.authentication.interfaces import \
36 ... IAuthenticatorPlugin
37 >>> from paula.pasplugins.tests.fake_pau_ap import AUTHPLUG_NAME
38 >>> from paula.pasplugins.tests.fake_pau_ap import AuthenticatorPlugin
40 >>> len(pau.authenticatorPlugins)
43 >>> authplug = getUtility(IAuthenticatorPlugin, name=AUTHPLUG_NAME)
44 >>> pau.authenticatorPlugins = (AUTHPLUG_NAME,)
45 >>> authplugs = list( pau.getAuthenticatorPlugins() )
48 >>> authplugs[0][0] == AUTHPLUG_NAME
50 >>> authplugs[0][1] is authplug
54 Ok, it should be possible to authenticate with PAU, using the credentials
57 >>> pau.authenticate(None)
58 Traceback (most recent call last):
62 >>> pau.authenticate(UserDict(login='foo',password='foo')) is None
65 >>> from paula.pasplugins.tests.fake_pau_ap import FAKE_REQUEST
66 >>> principal = pau.authenticate(FAKE_REQUEST)
67 >>> principal.id is 'fakelogin'
70 The user carries groups and properties provided by our fake testing
75 >>> principal.realname
80 ['fakegroup1', 'fakegroup2']
83 The user should also be returned for a getPrincipal call:
85 >>> principal2 = pau.getPrincipal('fakelogin')
90 >>> principal2.realname
95 ['fakegroup1', 'fakegroup2']
98 PAU is working as expected.
104 >>> from paula.pasplugins.tests.fake_pau_ap import FAKE_CREDS
106 Paula PAS auth plugin
108 >>> p = portal.acl_users.paula_auth.authenticateCredentials(FAKE_CREDS)
110 ('fakelogin', 'fakelogin')
114 >>> from Products.PlonePAS.plugins.ufactory import PloneUser
115 >>> pu = PloneUser(p[1])
117 <PloneUser 'fakelogin'>
119 Paula PAS properties plugin - the order might be unstable
121 >>> psheet = portal.acl_users.paula_properties.getPropertiesForUser(pu)
122 >>> psheet.propertyItems()[0]
123 ('foo', u'foo value')
124 >>> psheet.propertyItems()[1]
125 ('email', u'foo@bar.com')
126 >>> psheet.propertyItems()[2]
127 ('realname', u'fake user')
129 Paula PAS group plugin
131 >>> portal.acl_users.paula_groups.getGroupsForPrincipal(pu)
132 ('fakegroup1', 'fakegroup2')
135 A login should be possible
136 --------------------------
144 #Set things up (thx optilux)
145 #---------------------------
147 # >>> from Products.Five.testbrowser import Browser
148 # >>> browser = Browser()
149 # >>> portal_url = self.portal.absolute_url()
151 #The following is useful when writing and debugging testbrowser tests. It lets
152 #us see error messages properly.
154 # >>> browser.handleErrors = False
155 # >>> self.portal.error_log._ignored_exceptions = ()
157 #We then turn off the various portlets, because they sometimes duplicate links
158 #and text (e.g. the navtree, the recent recent items listing) that we wish to
159 #test for in our own views. Having no portlets makes things easier.
161 # >>> from zope.component import getMultiAdapter, getUtility
162 # >>> from plone.portlets.interfaces import IPortletManager
163 # >>> from plone.portlets.interfaces import IPortletAssignmentMapping
165 # >>> left_column = getUtility(IPortletManager, name=u"plone.leftcolumn")
166 # >>> left_assignable = getMultiAdapter((self.portal, left_column), IPortletAssignmentMapping)
167 # >>> for name in left_assignable.keys():
168 # ... del left_assignable[name]
170 # >>> right_column = getUtility(IPortletManager, name=u"plone.rightcolumn")
171 # >>> right_assignable = getMultiAdapter((self.portal, right_column), IPortletAssignmentMapping)
172 # >>> for name in right_assignable.keys():
173 # ... del right_assignable[name]
183 # >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
184 # >>> browser.getControl(name='__ac_name').value = u"user"
185 # >>> browser.getControl(name='__ac_password').value = u"wrong"
186 # >>> browser.getControl(name='submit').click()
187 # >>> 'Login failed' in browser.contents
190 # >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
191 # >>> browser.getControl(name='__ac_name').value = u"user"
192 # >>> browser.getControl(name='__ac_password').value = u"password"
193 # >>> browser.getControl(name='submit').click()
194 # >>> 'Login failed' in browser.contents