Skip to content

Commit

Permalink
fixed tests to work with python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Apr 26, 2015
1 parent ef354fd commit 5e85b27
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test_httpauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_no_auth(self):
def test_basic_auth_prompt(self):
response = self.client.get('/basic')
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertEqual(response.headers['WWW-Authenticate'],
'Basic realm="Authentication Required"')

Expand All @@ -176,7 +176,7 @@ def test_basic_auth_ignore_options(self):
def test_basic_auth_prompt_with_custom_realm(self):
response = self.client.get('/basic-with-realm')
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertEqual(response.headers['WWW-Authenticate'],
'Basic realm="My Realm"')
self.assertEqual(response.data.decode('utf-8'), 'custom error')
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_basic_auth_login_invalid(self):
response = self.client.get(
'/basic-with-realm', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertEqual(response.headers['WWW-Authenticate'],
'Basic realm="My Realm"')

Expand All @@ -221,7 +221,7 @@ def test_basic_custom_auth_login_invalid(self):
response = self.client.get(
'/basic-custom', headers={"Authorization": "Basic " + creds})
self.assertEqual(response.status_code, 401)
self.assertIn("WWW-Authenticate", response.headers)
self.assertTrue("WWW-Authenticate" in response.headers)

def test_verify_auth_login_valid(self):
creds = base64.b64encode(b'susan:bye').decode('utf-8')
Expand All @@ -239,12 +239,12 @@ def test_verify_auth_login_invalid(self):
response = self.client.get(
'/basic-verify', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)

def test_digest_auth_prompt(self):
response = self.client.get('/digest')
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertTrue(re.match(r'^Digest realm="Authentication Required",'
r'nonce="[0-9a-f]+",opaque="[0-9a-f]+"$',
response.headers['WWW-Authenticate']))
Expand All @@ -257,7 +257,7 @@ def test_digest_auth_ignore_options(self):
def test_digest_auth_prompt_with_custom_realm(self):
response = self.client.get('/digest-with-realm')
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertTrue(re.match(r'^Digest realm="My Realm",nonce="[0-9a-f]+",'
r'opaque="[0-9a-f]+"$',
response.headers['WWW-Authenticate']))
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_digest_auth_login_bad_realm(self):
auth_response,
d['opaque'])})
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertTrue(re.match(r'^Digest realm="Authentication Required",'
r'nonce="[0-9a-f]+",opaque="[0-9a-f]+"$',
response.headers['WWW-Authenticate']))
Expand All @@ -347,7 +347,7 @@ def test_digest_auth_login_invalid(self):
'response="ca306c361a9055b968810067a37fb8cb",'
'opaque="5ccc069c403ebaf9f0171e9517f40e41"'})
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertTrue(re.match(r'^Digest realm="My Realm",nonce="[0-9a-f]+",'
r'opaque="[0-9a-f]+"$',
response.headers['WWW-Authenticate']))
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_digest_auth_login_invalid2(self):
auth_response,
d['opaque'])})
self.assertEqual(response.status_code, 401)
self.assertIn('WWW-Authenticate', response.headers)
self.assertTrue('WWW-Authenticate' in response.headers)
self.assertTrue(re.match(r'^Digest realm="Authentication Required",'
r'nonce="[0-9a-f]+",opaque="[0-9a-f]+"$',
response.headers['WWW-Authenticate']))
Expand Down

0 comments on commit 5e85b27

Please sign in to comment.