#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# app = Flask ( __name__ ) #NEWLINE# app . config [ 'SECRET_KEY' ] = 'my secret' #NEWLINE# token_auth = HTTPTokenAuth ( 'MyToken' ) #NEWLINE# @ token_auth . verify_token #NEWLINE# def verify_token( token ) : #NEWLINE# #INDENT# return ( token == 'this-is-the-token!' ) #NEWLINE# #UNINDENT# @ token_auth . error_handler #NEWLINE# def error_handler( ) : #NEWLINE# #INDENT# return ( 'error' , 401 , { #NEWLINE# #INDENT# 'WWW-Authenticate' : 'MyToken realm="Foo"' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# @ app . route ( '/' ) #NEWLINE# def index( ) : #NEWLINE# #INDENT# return 'index' #NEWLINE# #UNINDENT# @ app . route ( '/protected' ) #NEWLINE# @ token_auth . login_required #NEWLINE# def token_auth_route( ) : #NEWLINE# #INDENT# return 'token_auth' #NEWLINE# #UNINDENT# self . app = app #NEWLINE# self . token_auth = token_auth #NEWLINE# self . client = app . test_client ( )