Ejemplo n.º 1
0
 def test_rejects_invalid_hostname(self):
     input = "%s abc-.foo" % factory.make_hostname()
     error = self.assertRaises(
         ValidationError, HostListFormField().clean, input)
     self.assertThat(error.message, Equals(
         "Invalid hostname: Label cannot start or end with "
         "hyphen: 'abc-'."))
Ejemplo n.º 2
0
 def test_rejects_invalid_ipv6_address(self):
     input = "%s fe80::abcde" % factory.make_hostname()
     error = self.assertRaises(ValidationError,
                               HostListFormField().clean, input)
     self.assertThat(
         error.message,
         Equals("Failed to detect a valid IP address from 'fe80::abcde'."))
Ejemplo n.º 3
0
 def test_accepts_misc(self):
     servers = {
         "::1",
         "1::",
         "1::2",
         "1:2::3",
         "1::2:3",
         "1:2::3:4",
         "::127.0.0.1",
     }
     input = ",".join(servers)
     self.assertEqual(" ".join(servers), HostListFormField().clean(input))
Ejemplo n.º 4
0
 def test_accepts_comma_separated_hostnames(self):
     hostnames = factory.make_hostname(), factory.make_hostname()
     input = ",".join(hostnames)
     self.assertEqual(" ".join(hostnames), HostListFormField().clean(input))
Ejemplo n.º 5
0
 def test_accepts_hostname(self):
     hostname = factory.make_hostname()
     self.assertEqual(hostname, HostListFormField().clean(hostname))
Ejemplo n.º 6
0
 def test_accepts_comma_separated_ips(self):
     ips = [factory.make_ip_address() for _ in range(5)]
     input = ",".join(ips)
     self.assertEqual(" ".join(ips), HostListFormField().clean(input))
Ejemplo n.º 7
0
 def test_accepts_single_ip(self):
     ip = factory.make_ip_address()
     self.assertEqual(ip, HostListFormField().clean(ip))
Ejemplo n.º 8
0
 def test_accepts_none(self):
     self.assertIsNone(HostListFormField().clean(None))
Ejemplo n.º 9
0
 def test_accepts_space_separated_hostnames(self):
     hostnames = factory.make_hostname(), factory.make_hostname()
     input = ' '.join(hostnames)
     self.assertEqual(input, HostListFormField().clean(input))