forked from jazzband/django-silk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent path or view_name being longer than 190 characters
MySQL index restrictions prevent us from having path or view_name be longer than 190 characters (see jazzband#38), but there is no logic in the Request object to enforce this limit when saving, so long URLs cause a 500 error. Closes jazzband#179.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django.test import TestCase | ||
from mock import Mock | ||
from silk.model_factory import RequestModelFactory | ||
|
||
|
||
class TestLongRequestUrl(TestCase): | ||
|
||
def test_no_long_url(self): | ||
url = '1234567890' * 19 # 190-character URL | ||
mock_request = Mock() | ||
mock_request.META = {'CONTENT_TYPE': 'text/plain'} | ||
mock_request.GET = {} | ||
mock_request.path = url | ||
mock_request.method = 'get' | ||
request_model = RequestModelFactory(mock_request).construct_request_model() | ||
self.assertEqual(request_model.path, url) | ||
|
||
def test_long_url(self): | ||
url = '1234567890' * 200 # 2000-character URL | ||
mock_request = Mock() | ||
mock_request.META = {'CONTENT_TYPE': 'text/plain'} | ||
mock_request.GET = {} | ||
mock_request.method = 'get' | ||
mock_request.path = url | ||
request_model = RequestModelFactory(mock_request).construct_request_model() | ||
self.assertEqual(request_model.path, '%s...%s' % (url[:94], url[1907:])) | ||
self.assertEqual(len(request_model.path), 190) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters