From eabfa2d0e38670365aa74117ad2f8710b81065c5 Mon Sep 17 00:00:00 2001 From: Parth Verma Date: Thu, 23 Nov 2023 20:46:17 -0800 Subject: Fixed #34818 -- Prevented GenericIPAddressField from mutating error messages. Co-authored-by: Parth Verma --- tests/validation/tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/validation') 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."] + ) -- cgit v1.3