Ejemplo n.º 1
0
 def to_python(self, value):
     if value in validators.EMPTY_VALUES:
         return ''
     if value and ':' in value:
             return clean_ipv6_address(value,
                 self.unpack_ipv4, self.error_messages['invalid'])
     return value
Ejemplo n.º 2
0
 def get_prep_value(self, value):
     if value and ':' in value:
         try:
             return clean_ipv6_address(value, self.unpack_ipv4)
         except exceptions.ValidationError:
             pass
     return value
Ejemplo n.º 3
0
 def to_python(self, value):
     if value and ':' in value:
         return clean_ipv6_address(value,
             self.unpack_ipv4, self.error_messages['invalid'])
     return value
Ejemplo n.º 4
0
 def test_unpacks_ipv4(self):
     self.assertEqual(clean_ipv6_address('::ffff:0a0a:0a0a', unpack_ipv4=True), '10.10.10.10')
     self.assertEqual(clean_ipv6_address('::ffff:1234:1234', unpack_ipv4=True), '18.52.18.52')
     self.assertEqual(clean_ipv6_address('::ffff:18.52.18.52', unpack_ipv4=True), '18.52.18.52')
Ejemplo n.º 5
0
 def test_cleanes_with_v4_mapping(self):
     self.assertEqual(clean_ipv6_address('::ffff:0a0a:0a0a'), '::ffff:10.10.10.10')
     self.assertEqual(clean_ipv6_address('::ffff:1234:1234'), '::ffff:18.52.18.52')
     self.assertEqual(clean_ipv6_address('::ffff:18.52.18.52'), '::ffff:18.52.18.52')
Ejemplo n.º 6
0
 def test_cleanes_plain_address(self):
     self.assertEqual(clean_ipv6_address('DEAD::0:BEEF'), 'dead::beef')
     self.assertEqual(clean_ipv6_address('2001:000:a:0000:0:fe:fe:beef'), '2001:0:a::fe:fe:beef')
     self.assertEqual(clean_ipv6_address('2001::a:0000:0:fe:fe:beef'), '2001:0:a::fe:fe:beef')