Example #1
0
 def test_headers(self):
     details = "hmm"
     challenge = 'Bearer realm="https://example.com"'
     e1 = errors.UnauthenticatedError(details, challenge=challenge)
     e2 = errors.UnauthenticatedError(details, challenge=challenge)
     self.assertEqual(
         e1.headers,
         [("WWW-Authenticate", 'Bearer realm="https://example.com"')],
     )
     self.assertIsNot(e1.headers, e2.headers)
Example #2
0
 def app(request):
     raise errors.UnauthenticatedError(
         "who are you?", challenge='Digest realm="https://example.com"'
     )
Example #3
0
 def test_with_details(self):
     e = errors.UnauthenticatedError("don't you know who I am?",
                                     challenge="Digest")
     expected_msg = "Unauthenticated: don't you know who I am?"
     self.assertEqual(str(e), expected_msg)
Example #4
0
 def test_http_code(self):
     self.assertEqual(
         errors.UnauthenticatedError(challenge="Digest").http_code, 401)
Example #5
0
 def test_no_details(self):
     e = errors.UnauthenticatedError(challenge="Digest")
     expected_msg = "Unauthenticated"
     self.assertEqual(str(e), expected_msg)