summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorErik Romijn <eromijn@solidlinks.nl>2014-04-20 16:25:39 -0400
committerTim Graham <timograham@gmail.com>2014-04-21 18:29:39 -0400
commit34526c2f56b863c2103655a0893ac801667e86ea (patch)
tree0325faf6cd632874a79c74653eeb95a7c97135d4 /tests/model_fields
parent380545bf85cbf17fc698d136815b7691f8d023ca (diff)
[1.7.x] Fixed queries that may return unexpected results on MySQL due to typecasting.
This is a security fix. Disclosure will follow shortly. Backport of 75c0d4ea3ae48970f788c482ee0bd6b29a7f1307 from master
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/tests.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 754ad20e5d..48d3e6a41b 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -673,12 +673,20 @@ class PromiseTest(test.TestCase):
self.assertIsInstance(
CharField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ CharField().get_prep_value(lazy_func()),
+ six.text_type)
def test_CommaSeparatedIntegerField(self):
lazy_func = lazy(lambda: '1,2', six.text_type)
self.assertIsInstance(
CommaSeparatedIntegerField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ CommaSeparatedIntegerField().get_prep_value(lazy_func()),
+ six.text_type)
def test_DateField(self):
lazy_func = lazy(lambda: datetime.date.today(), datetime.date)
@@ -709,12 +717,20 @@ class PromiseTest(test.TestCase):
self.assertIsInstance(
FileField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ FileField().get_prep_value(lazy_func()),
+ six.text_type)
def test_FilePathField(self):
lazy_func = lazy(lambda: 'tests.py', six.text_type)
self.assertIsInstance(
FilePathField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ FilePathField().get_prep_value(lazy_func()),
+ six.text_type)
def test_FloatField(self):
lazy_func = lazy(lambda: 1.2, float)
@@ -735,9 +751,13 @@ class PromiseTest(test.TestCase):
int)
def test_IPAddressField(self):
- lazy_func = lazy(lambda: '127.0.0.1', six.text_type)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
+ lazy_func = lazy(lambda: '127.0.0.1', six.text_type)
+ self.assertIsInstance(
+ IPAddressField().get_prep_value(lazy_func()),
+ six.text_type)
+ lazy_func = lazy(lambda: 0, int)
self.assertIsInstance(
IPAddressField().get_prep_value(lazy_func()),
six.text_type)
@@ -747,6 +767,10 @@ class PromiseTest(test.TestCase):
self.assertIsInstance(
GenericIPAddressField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ GenericIPAddressField().get_prep_value(lazy_func()),
+ six.text_type)
def test_NullBooleanField(self):
lazy_func = lazy(lambda: True, bool)
@@ -771,6 +795,10 @@ class PromiseTest(test.TestCase):
self.assertIsInstance(
SlugField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ SlugField().get_prep_value(lazy_func()),
+ six.text_type)
def test_SmallIntegerField(self):
lazy_func = lazy(lambda: 1, int)
@@ -783,6 +811,10 @@ class PromiseTest(test.TestCase):
self.assertIsInstance(
TextField().get_prep_value(lazy_func()),
six.text_type)
+ lazy_func = lazy(lambda: 0, int)
+ self.assertIsInstance(
+ TextField().get_prep_value(lazy_func()),
+ six.text_type)
def test_TimeField(self):
lazy_func = lazy(lambda: datetime.datetime.now().time(), datetime.time)