Hi,
I'm getting started with plone, and the functional testing tools look really
promising. However, I cannot open a document which I created in my test (and
for
which I set the permissions explicitly). I get an exception message:
Unauthorized: <strong>You are not authorized to access this resource.</strong>
The test code is this one (the failure occurs in the last line):
def test_getFilesInfo(self):
# setup
portal = self.layer['portal']
setRoles(portal, TEST_USER_ID, ('Manager',))
portal.invokeFactory('abb.types.strategycontainer',
'strategyContainer',
title=u"Strategy Container")
strategyContainer = portal['strategyContainer']
# here it gets interesting, creating a 'strategy' and setting
permissions
strategyContainer.invokeFactory('abb.types.strategy', 'strategy',
title=u"Strategy")
strategy = strategyContainer['strategy']
strategy.manage_permission('View', roles=['Manager', 'Owner'],
acquire=1)
# commit everything
import transaction; transaction.commit()
# try viewing the document in the browser
app = self.layer['app']
browser = Browser(app)
browser.handleErrors = False
browser.open(portal.absolute_url())
browser.getLink('Log in').click()
browser.getControl(name='__ac_name').value = TEST_USER_ID
browser.getControl(name='__ac_password').value = default_password
browser.getControl('Log in').click()
self.assertTrue("You are now logged in" in browser.contents)
# this line fails
browser.open(strategy.absolute_url())
When I use checkPermission in ipdb I get a NoInteraction exception:
from zope.security import checkPermission
checkPermission('View', strategy)
*** NoInteraction:
Any ideas why I cannot open the document? Any other ways to check that the
permissions are set correctly for TEST_USER_ID to open the document?
Thanks! (once again)
Maarten
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers