def test_token_auth():
 precomptoken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoibXkgZGF0YSIsInVzZXIiOiJUaW1vdGh5In0.8QqdQMJUTq0Dq7vHlnDjdoCKFPDAlvxGCpc_8XF41nI'
 @hug.authentication.token
 def token_authentication(token):
  if (token == precomptoken):
   return 'Timothy'
 @hug.get(requires=token_authentication)
 def hello_world():
  return 'Hello World!'
 assert (hug.test.get(api, 'hello_world', headers={'Authorization': precomptoken}).data == 'Hello World!')
 assert ('401' in hug.test.get(api, 'hello_world').status)
 assert ('401' in hug.test.get(api, 'hello_world', headers={'Authorization': 'eyJhbGci'}).status)

def test_token_auth ( ) : precomptoken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoibXkgZGF0YSIsInVzZXIiOiJUaW1vdGh5In0.8QqdQMJUTq0Dq7vHlnDjdoCKFPDAlvxGCpc_8XF41nI' @ hug . authentication . token def token_authentication ( token ) : if ( token == precomptoken ) : return 'Timothy' @ hug . get ( requires = token_authentication ) def hello_world ( ) : return 'Hello World!' assert ( hug . test . get ( api , 'hello_world' , headers = { 'Authorization' : precomptoken } ) . data == 'Hello World!' ) assert ( '401' in hug . test . get ( api , 'hello_world' ) . status ) assert ( '401' in hug . test . get ( api , 'hello_world' , headers = { 'Authorization' : 'eyJhbGci' } ) . status )
test json web token .