Hi,
for some reason, I get an Unauthorized exception when I instantiate the
HomePage
content type in my unit test (with the website, there is no problem). The
'needed' field of the exception is empty.
The rolemap.xml does get loaded (any syntax error there will stop the test),
and
Since I need to call setDefaultRoles('elmolino.backend: Add HomePage',
['Manager']) to prevent some other error from occurring, it seems that the
permission does exist within the security system.
Also, I tried to use installProduct(app, 'elmolino.backend') in setupZope but
calling this function returns an error message (could not install
elmolino.backend), could this be significant?
Any idea what could be the cause for Unauthorized?
Thanks
Maarten
This is my test:
class TestHomePage(unittest.TestCase):
layer = ELMOLINOBACKEND_INTEGRATION_TESTING
def test_structure(self):
testUtils = TestUtils(self)
testUtils.setManagerRole()
permission = 'elmolino.backend: Add HomePage'
self.assertTrue(permission in testUtils.portal.possible_permissions())
sm = getSecurityManager()
self.assertTrue(
sm.checkPermission(permission, testUtils.portal_workflow)
)
testUtils.portal.invokeFactory(
'HomePage',
'homePage',
title=u"Home page"
)
homePage = testUtils.portal['homePage']
This is my setupZope in the PloneSandboxLayer
def setUpZope(self, app, configurationContext):
# call to installProduct fails
# installProduct(app, 'elmolino.backend')
# Load ZCML
import elmolino.backend
xmlconfig.file('configure.zcml', elmolino.backend,
context=configurationContext)
# strange that this is needed, but seems to be needed
setDefaultRoles('elmolino.backend: Add HomePage', ['Manager'])
setDefaultRoles('elmolino.backend: Add InstantMessage', ['Manager'])
setDefaultRoles('elmolino.backend: Add Show', ['Manager'])
My roles map is this one (it gets loaded, because if I insert a syntax error
the
test does not run)
<?xml version="1.0"?>
<rolemap>
<permissions>
<permission name="elmolino.backend: Add InstantMessage" acquire="True">
<role name="Manager"/>
<role name="Owner"/>
<role name="Contributor"/>
</permission>
<permission name="elmolino.backend: Add Show" acquire="True">
<role name="Manager"/>
<role name="Owner"/>
<role name="Contributor"/>
</permission>
<permission name="elmolino.backend: Add HomePage" acquire="True">
<role name="Manager"/>
<role name="Owner"/>
<role name="Contributor"/>
</permission>
</permissions>
</rolemap>
This is my config.py
"""Common configuration constants
"""
from Products.Archetypes.atapi import DisplayList
PROJECTNAME = 'elmolino.backend'
ADD_PERMISSIONS = {
# -*- extra stuff goes here -*-
'ArtistsFolder': 'elmolino.backend: Add ArtistsFolder',
'ShowsFolder': 'elmolino.backend: Add ShowsFolder',
'Artist': 'elmolino.backend: Add Artist',
'HomePage': 'elmolino.backend: Add HomePage',
'Show': 'elmolino.backend: Add Show',
'InstantMessage': 'elmolino.backend: Add InstantMessage',
}
MESSAGE_PRIORITIES = DisplayList((
('high', 'High Priority'),
('normal', 'Normal Priority'),
('low', 'Low Priority'),
))
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers