Skip to content

Commit ab5edf1

Browse files
committed
Add a test for protocol.checkIPv6Address() and IPv6 sample to test_check_local
1 parent fb0d602 commit ab5edf1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/tests/test_protocol.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ def test_checkIPv4Address(self):
2525
self.assertFalse( # 8.8.8.8
2626
protocol.checkIPv4Address(b'\x08\x08\x08\x08', token, True))
2727

28+
def test_checkIPv6Address(self):
29+
"""Check the results of protocol.checkIPv6Address()"""
30+
test_ip = '2001:db8::ff00:42:8329'
31+
self.assertEqual(
32+
'test', protocol.checkIPv6Address(
33+
protocol.encodeHost(test_ip), 'test'))
34+
self.assertFalse(
35+
protocol.checkIPv6Address(
36+
protocol.encodeHost(test_ip), 'test', True))
37+
2838
def test_check_local(self):
2939
"""Check the logic of TCPConnection.local"""
3040
self.assertTrue(
@@ -35,6 +45,8 @@ def test_check_local(self):
3545
protocol.checkIPAddress(protocol.encodeHost('10.42.43.1'), True))
3646
self.assertTrue(
3747
protocol.checkIPAddress(protocol.encodeHost('172.31.255.2'), True))
48+
self.assertFalse(protocol.checkIPAddress(
49+
protocol.encodeHost('2001:db8::ff00:42:8329'), True))
3850

3951
globalhost = protocol.encodeHost('8.8.8.8')
4052
self.assertFalse(protocol.checkIPAddress(globalhost, True))

0 commit comments

Comments
 (0)