summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorParth Verma <v.parth98@gmail.com>2023-11-23 20:46:17 -0800
committerGitHub <noreply@github.com>2023-11-24 05:46:17 +0100
commiteabfa2d0e38670365aa74117ad2f8710b81065c5 (patch)
tree9bc97757f38e4e6e5e9bb26dd1cf77c4df2cf8f2 /tests
parenta8adb6aa6cc6b9efd043acc980b5744bc211c760 (diff)
Fixed #34818 -- Prevented GenericIPAddressField from mutating error messages.
Co-authored-by: Parth Verma <parth.verma@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/validation/tests.py b/tests/validation/tests.py
index 43de77a44a..6bb04f6f14 100644
--- a/tests/validation/tests.py
+++ b/tests/validation/tests.py
@@ -206,3 +206,17 @@ class GenericIPAddressFieldTests(ValidationAssertions, TestCase):
self.assertIsNone(giptm.full_clean())
giptm = GenericIPAddressTestModel(generic_ip=None)
self.assertIsNone(giptm.full_clean())
+
+ def test_multiple_invalid_ip_raises_error(self):
+ giptm = GenericIPAddressTestModel(
+ v6_ip="1.2.3.4", v4_ip="::ffff:10.10.10.10", generic_ip="fsad"
+ )
+ self.assertFieldFailsValidationWithMessage(
+ giptm.full_clean, "v6_ip", ["Enter a valid IPv6 address."]
+ )
+ self.assertFieldFailsValidationWithMessage(
+ giptm.full_clean, "v4_ip", ["Enter a valid IPv4 address."]
+ )
+ self.assertFieldFailsValidationWithMessage(
+ giptm.full_clean, "generic_ip", ["Enter a valid IPv4 or IPv6 address."]
+ )