Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albertyw committed Jan 13, 2023
1 parent 4c4a1c8 commit 8484e2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions project/tests/test_config_max_body_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_no_max_response(self):
mock_response.headers = {'content-type': 'text/plain'}
mock_response.content = b'a' * 1000 # 1000 bytes?
mock_response.status_code = 200
mock_response.get = mock_response.headers.get
response_model = ResponseModelFactory(mock_response).construct_response_model()
self.assertTrue(response_model.raw_body)

Expand All @@ -54,5 +55,6 @@ def test_max_response(self):
mock_response.headers = {'content-type': 'text/plain'}
mock_response.content = b'a' * 1024 * 100 # 100kb
mock_response.status_code = 200
mock_response.get = mock_response.headers.get
response_model = ResponseModelFactory(mock_response).construct_response_model()
self.assertFalse(response_model.raw_body)
6 changes: 3 additions & 3 deletions project/tests/test_sensitive_data_in_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ def test_password_in_batched_json(self):

def test_authorization_header(self):
mock_request = Mock()
mock_request.headers = {'HTTP_AUTHORIZATION': 'secret'}
mock_request.headers = {'authorization': 'secret'}
mock_request.body = ''
mock_request.get = mock_request.headers.get
factory = RequestModelFactory(mock_request)
headers = factory.encoded_headers()
json_headers = json.loads(headers)

self.assertIn('AUTHORIZATION', json_headers)
self.assertEqual(json_headers['AUTHORIZATION'], RequestModelFactory.CLEANSED_SUBSTITUTE)
self.assertIn('authorization', json_headers)
self.assertEqual(json_headers['authorization'], RequestModelFactory.CLEANSED_SUBSTITUTE)

0 comments on commit 8484e2e

Please sign in to comment.