#NEWLINE# def test_decorator( self ) : #NEWLINE# #INDENT# logging . debug ( '' ) #NEWLINE# logging . debug ( 'test_decorator' ) #NEWLINE# obj = Object ( ) #NEWLINE# methods = [ name for name in dir ( obj ) if inspect . ismethod ( getattr ( obj , name ) ) ] #NEWLINE# methods . remove ( 'no_rbac' ) #NEWLINE# self . assertEqual ( sorted ( rbac_methods ( obj ) ) , sorted ( methods ) ) #NEWLINE# normal_value = object ( ) #NEWLINE# proxy_value = ProxyRequired ( ) #NEWLINE# dummy = AccessController ( ) #NEWLINE# self . assertFalse ( need_proxy ( obj . no_rbac , proxy_value , dummy ) ) #NEWLINE# self . assertFalse ( need_proxy ( obj . single_role , normal_value , dummy ) ) #NEWLINE# self . assertFalse ( need_proxy ( obj . proxy_result , normal_value , dummy ) ) #NEWLINE# self . assertTrue ( need_proxy ( obj . proxy_result , proxy_value , dummy ) ) #NEWLINE# assert_raises ( self , "check_role('owner', obj.no_rbac)" , globals ( ) , locals ( ) , RoleError , 'No RBAC for function!' ) #NEWLINE# assert_raises ( methods , "check_role('xyzzy', obj.single_role)" , globals ( ) , locals ( ) , RoleError , "No access for role 'xyzzy'" ) #NEWLINE# check_role ( 'owner' , obj . multi_role ) #NEWLINE# check_role ( 'user' , obj . multi_role ) #NEWLINE# check_role ( 'xyzzy' , obj . role_pattern )