Skip to content

Commit 41ff5b0

Browse files
[3.12] gh-75743: Restore test_timeout.testConnectTimeout() (GH-109087) (#109103)
gh-75743: Restore test_timeout.testConnectTimeout() (GH-109087) This un-skips this test now that pythontest.net implements appropriate firewall rules for it. (cherry picked from commit 1829a3c) Co-authored-by: Ee Durbin <[email protected]>
1 parent b27ca96 commit 41ff5b0

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

Lib/test/test_timeout.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,12 @@ def setUp(self):
148148
def tearDown(self):
149149
self.sock.close()
150150

151-
@unittest.skipIf(True, 'need to replace these hosts; see bpo-35518')
152151
def testConnectTimeout(self):
153152
# Testing connect timeout is tricky: we need to have IP connectivity
154153
# to a host that silently drops our packets. We can't simulate this
155154
# from Python because it's a function of the underlying TCP/IP stack.
156-
# So, the following Snakebite host has been defined:
157-
blackhole = resolve_address('blackhole.snakebite.net', 56666)
155+
# So, the following port on the pythontest.net host has been defined:
156+
blackhole = resolve_address('pythontest.net', 56666)
158157

159158
# Blackhole has been configured to silently drop any incoming packets.
160159
# No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back
@@ -166,7 +165,7 @@ def testConnectTimeout(self):
166165
# to firewalling or general network configuration. In order to improve
167166
# our confidence in testing the blackhole, a corresponding 'whitehole'
168167
# has also been set up using one port higher:
169-
whitehole = resolve_address('whitehole.snakebite.net', 56667)
168+
whitehole = resolve_address('pythontest.net', 56667)
170169

171170
# This address has been configured to immediately drop any incoming
172171
# packets as well, but it does it respectfully with regards to the
@@ -180,20 +179,15 @@ def testConnectTimeout(self):
180179
# timeframe).
181180

182181
# For the records, the whitehole/blackhole configuration has been set
183-
# up using the 'pf' firewall (available on BSDs), using the following:
182+
# up using the 'iptables' firewall, using the following rules:
184183
#
185-
# ext_if="bge0"
186-
#
187-
# blackhole_ip="35.8.247.6"
188-
# whitehole_ip="35.8.247.6"
189-
# blackhole_port="56666"
190-
# whitehole_port="56667"
191-
#
192-
# block return in log quick on $ext_if proto { tcp udp } \
193-
# from any to $whitehole_ip port $whitehole_port
194-
# block drop in log quick on $ext_if proto { tcp udp } \
195-
# from any to $blackhole_ip port $blackhole_port
184+
# -A INPUT -p tcp --destination-port 56666 -j DROP
185+
# -A INPUT -p udp --destination-port 56666 -j DROP
186+
# -A INPUT -p tcp --destination-port 56667 -j REJECT
187+
# -A INPUT -p udp --destination-port 56667 -j REJECT
196188
#
189+
# See https://github.com/python/psf-salt/blob/main/pillar/base/firewall/snakebite.sls
190+
# for the current configuration.
197191

198192
skip = True
199193
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

0 commit comments

Comments
 (0)