Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ResourceRegistries.tests.testJSRegistry.TestResourcePermissions Class Reference
Inheritance diagram for ResourceRegistries.tests.testJSRegistry.TestResourcePermissions:
Inheritance graph
[legend]
Collaboration diagram for ResourceRegistries.tests.testJSRegistry.TestResourcePermissions:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testUnauthorizedGetItem
def testUnauthorizedTraversal
def testTestUnauthorizedTraversal
def testRaiseUnauthorizedOnPublish
def testRemovedFromResources
def testRemovedFromMergedResources
def testAuthorizedGetItem
def testAuthorizedTraversal
def testAuthorizedOnPublish

Public Attributes

 tool
 toolpath

Detailed Description

Definition at line 635 of file testJSRegistry.py.


Member Function Documentation

Definition at line 637 of file testJSRegistry.py.

00637 
00638     def afterSetUp(self):
00639         self.tool = getattr(self.portal, JSTOOLNAME)
00640         self.toolpath = '/' + self.tool.absolute_url(1)
00641         self.tool.clearResources()
00642         self.tool.registerScript('testroot.js', cookable=False)
00643         self.tool.registerScript('test_rr_1.js')
00644         self.setRoles(['Manager'])
00645         self.portal.invokeFactory('File',
00646                                    id='testroot.js',
00647                                    format='application/x-javascript',
00648                                    content_type='application/x-javascript',
00649                                    file="window.alert('red')")
00650 
00651         script = self.portal.restrictedTraverse('testroot.js')
00652 
00653         script.manage_permission('View',['Manager'], acquire=0)
00654         script.manage_permission('Access contents information',['Manager'], acquire=0)
00655         self.setRoles(['Member'])

Definition at line 712 of file testJSRegistry.py.

00712 
00713     def testAuthorizedGetItem(self):
00714         self.setRoles(['Manager'])
00715         try:
00716             content = str(self.tool['testroot.js'])
00717         except Unauthorized:
00718             self.fail()

Here is the call graph for this function:

Definition at line 726 of file testJSRegistry.py.

00726 
00727     def testAuthorizedOnPublish(self):
00728         authstr = "%s:%s" % (portal_owner, default_password)
00729         response = self.publish(self.toolpath + '/testroot.js', basic=authstr)
00730         self.failUnlessEqual(response.getStatus(), 200)

Definition at line 719 of file testJSRegistry.py.

00719 
00720     def testAuthorizedTraversal(self):
00721         self.setRoles(['Manager'])
00722         try:
00723             content = str(self.portal.restrictedTraverse('portal_css/testroot.js'))
00724         except Unauthorized:
00725             self.fail()

Here is the call graph for this function:

Definition at line 680 of file testJSRegistry.py.

00680 
00681     def testRaiseUnauthorizedOnPublish(self):
00682         response = self.publish(self.toolpath + '/testroot.js')
00683         #Will be 302 if CookieCrumbler is enabled
00684         self.failUnless(response.getStatus() in [302, 403, 401])

Definition at line 697 of file testJSRegistry.py.

00697 
00698     def testRemovedFromMergedResources(self):
00699         self.tool.unregisterResource('testroot.js')
00700         self.tool.registerScript('testroot.js')
00701         scripts = self.tool.getEvaluatedResources(self.portal)
00702         magicId = None
00703         for script in scripts:
00704             id = script.getId()
00705             if '-cachekey' in id:
00706                 magicId = id
00707         self.failUnless(magicId)
00708         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicId))
00709         self.failIf('red' in content)
00710         self.failUnless('not authorized' in content)
00711         self.failUnless('running' in content)

Here is the call graph for this function:

Definition at line 685 of file testJSRegistry.py.

00685 
00686     def testRemovedFromResources(self):
00687         # This test assumes that content is not merged or cached
00688         self.tool.unregisterResource('test_rr_1.js')
00689         self.tool.registerResource('test_rr_1.js', cookable=False, cacheable=False)
00690         scripts = self.tool.getEvaluatedResources(self.portal)
00691         ids = [item.getId() for item in scripts]
00692         self.failIf('testroot.js' in ids)
00693         self.failUnless('test_rr_1.js' in ids)
00694         # Return resources to normal (not sure if this is needed)
00695         self.tool.unregisterResource('test_rr_1.js')
00696         self.tool.registerScript('test_rr_1.js')

Here is the call graph for this function:

Definition at line 672 of file testJSRegistry.py.

00672 
00673     def testTestUnauthorizedTraversal(self):
00674         try:
00675             content = str(self.portal.restrictedTraverse('portal_javascripts/testroot.js'))
00676         except Unauthorized:
00677             return
00678 
00679         self.fail()

Here is the call graph for this function:

Definition at line 656 of file testJSRegistry.py.

00656 
00657     def testUnauthorizedGetItem(self):
00658         try:
00659             content = str(self.tool['testroot.js'])
00660         except Unauthorized:
00661             return
00662 
00663         self.fail()

Here is the call graph for this function:

Definition at line 664 of file testJSRegistry.py.

00664 
00665     def testUnauthorizedTraversal(self):
00666         try:
00667             content = str(self.portal.restrictedTraverse('portal_javascripts/testroot.js'))
00668         except Unauthorized:
00669             return
00670 
00671         self.fail()

Here is the call graph for this function:


Member Data Documentation

Definition at line 638 of file testJSRegistry.py.

Definition at line 639 of file testJSRegistry.py.


The documentation for this class was generated from the following file: