예제 #1
0
 def test_ok(self):
     self.assertEqual(get_ip_by_domain("1.1.1.1"), "1.1.1.1")
     self.assertEqual(get_ip_by_domain("1.1.1.1:8123"), "1.1.1.1")
     self.assertEqual(get_ip_by_domain("http://1.1.1.1"), "1.1.1.1")
     with mock.patch("scan.peers.socket.gethostbyname", return_value="2.3.4.5"):
         self.assertEqual(get_ip_by_domain("devtrue.net"), "2.3.4.5")
         self.assertEqual(get_ip_by_domain("http://devtrue.net"), "2.3.4.5")
예제 #2
0
 def test_ok(self):
     self.assertEqual(get_ip_by_domain('1.1.1.1'), '1.1.1.1')
     self.assertEqual(get_ip_by_domain('1.1.1.1:8123'), '1.1.1.1')
     self.assertEqual(get_ip_by_domain('http://1.1.1.1'), '1.1.1.1')
     with mock.patch('scan.peers.socket.gethostbyname', return_value='2.3.4.5'):
         self.assertEqual(get_ip_by_domain('devtrue.net'), '2.3.4.5')
         self.assertEqual(get_ip_by_domain('http://devtrue.net'), '2.3.4.5')
예제 #3
0
 def test_ipv6(self):
     self.assertEqual(
         get_ip_by_domain("[2a02:c207:2016:1984:0:0:0:1]"),
         "2a02:c207:2016:1984:0:0:0:1",
     )
     self.assertEqual(
         get_ip_by_domain("[2a02:c207:2016:1984:0:0:0:1]:8123"),
         "2a02:c207:2016:1984:0:0:0:1",
     )
     self.assertEqual(
         get_ip_by_domain("http://[2a02:c207:2016:1984:0:0:0:1]"),
         "2a02:c207:2016:1984:0:0:0:1",
     )
예제 #4
0
 def test_short(self):
     self.assertEqual(get_ip_by_domain("1.0.0"), "1.0.0.0")
예제 #5
0
 def test_wrong(self):
     self.assertEqual(get_ip_by_domain(""), None)
     self.assertEqual(get_ip_by_domain("https://"), None)
     self.assertEqual(get_ip_by_domain("2a02:c207:2016:1984:0:0:0:1"), None)
     self.assertEqual(get_ip_by_domain("http://2a02:c207:2016:1984:0:0:0:1"), None)
예제 #6
0
 def test_short(self):
     self.assertEqual(get_ip_by_domain('1.0.0'), '1.0.0.0')
예제 #7
0
 def test_wrong(self):
     self.assertEqual(get_ip_by_domain(''), None)
     self.assertEqual(get_ip_by_domain('https://'), None)
     self.assertEqual(get_ip_by_domain('2a02:c207:2016:1984:0:0:0:1'), None)
     self.assertEqual(get_ip_by_domain('http://2a02:c207:2016:1984:0:0:0:1'), None)
예제 #8
0
 def test_ipv6(self):
     self.assertEqual(get_ip_by_domain('[2a02:c207:2016:1984:0:0:0:1]'), '2a02:c207:2016:1984:0:0:0:1')
     self.assertEqual(get_ip_by_domain('[2a02:c207:2016:1984:0:0:0:1]:8123'), '2a02:c207:2016:1984:0:0:0:1')
     self.assertEqual(get_ip_by_domain('http://[2a02:c207:2016:1984:0:0:0:1]'), '2a02:c207:2016:1984:0:0:0:1')