Skip to content

Commit

Permalink
removed extra strip() calls in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jan 16, 2015
1 parent 489f26d commit fc34cc5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test_httpauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,27 @@ def test_basic_auth_prompt_with_custom_realm(self):
self.assertEqual(response.data.decode('utf-8'), 'custom error')

def test_basic_auth_login_valid(self):
creds = base64.b64encode(b'john:hello').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:hello').decode('utf-8')
response = self.client.get(
'/basic', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.data.decode('utf-8'), 'basic_auth:john')

def test_basic_auth_login_valid_with_hash1(self):
creds = base64.b64encode(b'john:hello').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:hello').decode('utf-8')
response = self.client.get(
'/basic-custom', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.data.decode('utf-8'),
'basic_custom_auth:john')

def test_basic_auth_login_valid_with_hash2(self):
creds = base64.b64encode(b'john:hello').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:hello').decode('utf-8')
response = self.client.get(
'/basic-with-realm', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.data.decode('utf-8'),
'basic_auth_my_realm:john')

def test_basic_auth_login_invalid(self):
creds = base64.b64encode(b'john:bye').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:bye').decode('utf-8')
response = self.client.get(
'/basic-with-realm', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.status_code, 401)
Expand All @@ -188,26 +188,26 @@ def test_basic_auth_login_invalid(self):
'Basic realm="My Realm"')

def test_basic_custom_auth_login_valid(self):
creds = base64.b64encode(b'john:hello').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:hello').decode('utf-8')
response = self.client.get(
'/basic-custom', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.data, b'basic_custom_auth:john')

def test_basic_custom_auth_login_invalid(self):
creds = base64.b64encode(b'john:bye').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:bye').decode('utf-8')
response = self.client.get(
'/basic-custom', headers={"Authorization": "Basic " + creds})
self.assertEqual(response.status_code, 401)
self.assertIn("WWW-Authenticate", response.headers)

def test_verify_auth_login_valid(self):
creds = base64.b64encode(b'susan:bye').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'susan:bye').decode('utf-8')
response = self.client.get(
'/basic-verify', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.data, b'basic_verify_auth:susan')

def test_verify_auth_login_invalid(self):
creds = base64.b64encode(b'john:bye').decode('utf-8').strip('\r\n')
creds = base64.b64encode(b'john:bye').decode('utf-8')
response = self.client.get(
'/basic-verify', headers={'Authorization': 'Basic ' + creds})
self.assertEqual(response.status_code, 401)
Expand Down

0 comments on commit fc34cc5

Please sign in to comment.