#NEWLINE# def test_protected_user_tests( ) : #NEWLINE# #INDENT# ( auth , app , user ) = get_flask_app ( roles = True ) #NEWLINE# client = app . test_client ( ) #NEWLINE# def echo( value , * args , **kwargs ) : #NEWLINE# #INDENT# return value #NEWLINE# #UNINDENT# user . echo = echo #NEWLINE# @ app . route ( '/yay/' ) #NEWLINE# @ auth . protected ( echo = True ) #NEWLINE# def yay( ) : #NEWLINE# #INDENT# return 'yay' #NEWLINE# #UNINDENT# @ app . route ( '/fail/' ) #NEWLINE# @ auth . protected ( echo = False ) #NEWLINE# def fail( ) : #NEWLINE# #INDENT# return 'fail' #NEWLINE# #UNINDENT# @ app . route ( '/foobar/' ) #NEWLINE# @ auth . protected ( unknown = False ) #NEWLINE# def foobar( ) : #NEWLINE# #INDENT# return 'foobar' #NEWLINE# #UNINDENT# resp = client . get ( '/yay/' ) #NEWLINE# assert ( resp . status == '303 SEE OTHER' ) #NEWLINE# client . get ( '/login/' ) #NEWLINE# resp = client . get ( '/yay/' ) #NEWLINE# assert ( app . status == '200 OK' ) #NEWLINE# resp = client . get ( '/fail/' ) #NEWLINE# assert ( resp . status == '403 FORBIDDEN' ) #NEWLINE# with pytest . raises ( AttributeError ) : #NEWLINE# #INDENT# resp = client . get ( '/foobar/' )