mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 06:46:16 +00:00
send digest-auth challenge if wrong authorization type sent
This commit is contained in:
@@ -306,6 +306,20 @@ class HttpbinTestCase(unittest.TestCase):
|
||||
for stale_after in (None, 1, 4) if algorithm else (None,) :
|
||||
self._test_digest_auth(username, password, qop, algorithm, body, stale_after)
|
||||
|
||||
def test_digest_auth_with_wrong_authorization_type(self):
|
||||
"""Sending an non-digest Authorization header to /digest-auth should return a 401"""
|
||||
auth_headers = (
|
||||
('Authorization', 'Basic 1234abcd'),
|
||||
('Authorization', ''),
|
||||
('', '')
|
||||
)
|
||||
for header in auth_headers:
|
||||
response = self.app.get(
|
||||
'/digest-auth/auth/myname/mysecret',
|
||||
headers={header[0]: header[1]}
|
||||
)
|
||||
self.assertEqual(response.status_code, 401)
|
||||
|
||||
def _test_digest_auth(self, username, password, qop, algorithm=None, body=None, stale_after=None):
|
||||
uri = self._digest_auth_create_uri(username, password, qop, algorithm, stale_after)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user