Exemple #1
0
    def test_split_port(self):
        internal_port, external_port = split_port("127.0.0.1:1000:2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, ("127.0.0.1", "1000"))

        internal_port, external_port = split_port("127.0.0.1::2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, ("127.0.0.1",))

        internal_port, external_port = split_port("1000:2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, "1000")
Exemple #2
0
    def test_split_port(self):
        internal_port, external_port = split_port("127.0.0.1:1000:2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, ("127.0.0.1", "1000"))

        internal_port, external_port = split_port("127.0.0.1::2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, ("127.0.0.1", ))

        internal_port, external_port = split_port("1000:2000")
        self.assertEqual(internal_port, "2000")
        self.assertEqual(external_port, "1000")
Exemple #3
0
 def test_split_port_with_host_ip_no_port(self):
     internal_port, external_port = split_port("127.0.0.1::2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, ("127.0.0.1", None))
Exemple #4
0
 def test_split_port_with_protocol(self):
     internal_port, external_port = split_port("127.0.0.1:1000:2000/udp")
     self.assertEqual(internal_port, "2000/udp")
     self.assertEqual(external_port, ("127.0.0.1", "1000"))
Exemple #5
0
 def test_split_port_invalid(self):
     with self.assertRaises(ConfigError):
         split_port("0.0.0.0:1000:2000:tcp")
Exemple #6
0
 def test_split_port_no_host_port(self):
     internal_port, external_port = split_port("2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, None)
Exemple #7
0
 def test_split_port_with_host_port(self):
     internal_port, external_port = split_port("1000:2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, "1000")
Exemple #8
0
 def test_split_port_invalid(self):
     with self.assertRaises(ConfigError):
         split_port("0.0.0.0:1000:2000:tcp")
Exemple #9
0
 def test_split_port_no_host_port(self):
     internal_port, external_port = split_port("2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, None)
Exemple #10
0
 def test_split_port_with_host_port(self):
     internal_port, external_port = split_port("1000:2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, "1000")
Exemple #11
0
 def test_split_port_with_host_ip_no_port(self):
     internal_port, external_port = split_port("127.0.0.1::2000")
     self.assertEqual(internal_port, "2000")
     self.assertEqual(external_port, ("127.0.0.1", None))
Exemple #12
0
 def test_split_port_with_protocol(self):
     internal_port, external_port = split_port("127.0.0.1:1000:2000/udp")
     self.assertEqual(internal_port, "2000/udp")
     self.assertEqual(external_port, ("127.0.0.1", "1000"))