#NEWLINE# def test_authorization( self , href , perms , h2_text ) : #NEWLINE# #INDENT# 'Check permissions required to access an administration panel.\n\n        :param href: the relative href of the administration panel\n        :param perms: list or tuple of permissions required to access\n                      the administration panel\n        :param h2_text: the body of the h2 heading on the administration\n                        panel' #NEWLINE# self . _tester . go_to_front ( ) #NEWLINE# self . _tester . logout ( ) #NEWLINE# self . _tester . login ( 'user' ) #NEWLINE# if isinstance ( perms , basestring ) : #NEWLINE# #INDENT# perms = ( perms , ) #NEWLINE# #UNINDENT# h2 = '<h2>[ \\t\\n]*%s[ \\t\\n]*( <span class="trac-count">\\(\\d+\\)</span>)?[ \\t\\n]*</h2>' #NEWLINE# try : #NEWLINE# #INDENT# for perm in perms : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# tc . go ( href ) #NEWLINE# tc . find ( 'No administration panels available' ) #NEWLINE# self . _testenv . grant_perm ( 'user' , perm ) #NEWLINE# tc . go ( href ) #NEWLINE# tc . find ( ( h2 % h2_text ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . _testenv . revoke_perm ( 'user' , perm ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# tc . go ( href ) #NEWLINE# tc . find ( 'No administration panels available' ) #NEWLINE# self . _testenv . enable_authz_permpolicy ( { #NEWLINE# #INDENT# href . strip ( '/' ) . replace ( '/' , ':' , 1 ) : { #NEWLINE# #INDENT# 'user' : perm , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# tc . go ( href ) #NEWLINE# tc . find ( ( h2 % h2_text ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . _testenv . disable_authz_permpolicy ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# self . _tester . go_to_front ( ) #NEWLINE# self . _tester . logout ( ) #NEWLINE# self . _tester . login ( 'admin' )