Ejemplo n.º 1
0
 def test_rejects_invalid_hostname(self):
     input = "%s abc-.foo" % factory.make_hostname()
     error = self.assertRaises(
         ValidationError, SubnetListFormField().clean, input)
     self.assertThat(error.message, Equals(
         "Invalid hostname: Label cannot start or end with "
         "hyphen: 'abc-'."))
Ejemplo n.º 2
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), SubnetListFormField().clean(input))
Ejemplo n.º 3
0
 def test_rejects_invalid_ipv6_subnet(self):
     input = "%s 100::/300" % factory.make_ipv6_network()
     error = self.assertRaises(ValidationError,
                               SubnetListFormField().clean, input)
     self.assertThat(error.message, Equals("Invalid network: 100::/300."))
Ejemplo n.º 4
0
 def test_rejects_invalid_ipv6_address(self):
     input = "%s fe80::abcde" % factory.make_hostname()
     error = self.assertRaises(ValidationError,
                               SubnetListFormField().clean, input)
     self.assertThat(error.message,
                     Equals("Invalid IP address: fe80::abcde."))
Ejemplo n.º 5
0
 def test_accepts_comma_separated_hostnames(self):
     hostnames = factory.make_hostname(), factory.make_hostname()
     input = ",".join(hostnames)
     self.assertEqual(" ".join(hostnames),
                      SubnetListFormField().clean(input))
Ejemplo n.º 6
0
 def test_accepts_hostname(self):
     hostname = factory.make_hostname()
     self.assertEqual(hostname, SubnetListFormField().clean(hostname))
Ejemplo n.º 7
0
 def test_accepts_comma_separated_subnets(self):
     subnets = [str(factory.make_ipv4_network()) for _ in range(5)]
     input = ",".join(subnets)
     self.assertEqual(" ".join(subnets), SubnetListFormField().clean(input))
Ejemplo n.º 8
0
 def test_accepts_single_subnet(self):
     subnet = str(factory.make_ipv4_network())
     self.assertEqual(subnet, SubnetListFormField().clean(subnet))
Ejemplo n.º 9
0
 def test_accepts_comma_separated_ips(self):
     ips = [factory.make_ip_address() for _ in range(5)]
     input = ",".join(ips)
     self.assertEqual(" ".join(ips), SubnetListFormField().clean(input))
Ejemplo n.º 10
0
 def test_accepts_single_ip(self):
     ip = factory.make_ip_address()
     self.assertEqual(ip, SubnetListFormField().clean(ip))
Ejemplo n.º 11
0
 def test_accepts_none(self):
     self.assertIsNone(SubnetListFormField().clean(None))
Ejemplo n.º 12
0
 def test_accepts_space_separated_hostnames(self):
     hostnames = factory.make_hostname(), factory.make_hostname()
     input = ' '.join(hostnames)
     self.assertEqual(input, SubnetListFormField().clean(input))
Ejemplo n.º 13
0
 def test_accepts_space_separated_subnets(self):
     subnets = [str(factory.make_ipv6_network()) for _ in range(5)]
     input = ' '.join(subnets)
     self.assertEqual(input, SubnetListFormField().clean(input))