示例#1
0
  def test_login_required(self):
    h = HTTPAuth()
    h.get_verify_token_callback = verify_token
    self.assertEqual(h.login_required(lambda x: x)(1).status_code, 401)

    token = generate_user_token(self.u)
    with app.test_request_context('/', headers={'authorization': 'Bearer %s' % (token)}) as c:
      self.assertEqual(h.login_required(lambda x: x)(1),1)
示例#2
0
 def test_get_token(self):
   h = HTTPAuth()
   token = "test"
   with app.test_request_context('/', headers={'authorization': 'Bearer %s' % (token)}) as c:
     self.assertEqual(token, h.get_token())