#5575 [Engine] test_security.py: test_ipv6_loopback fails instead of skipping when ::1 connect is blocked
open · @libin771018-sketch · 0 评论 · 去 GitHub 看
Setup & installServer & APINVIDIA / CUDASecurityWindows
说明
### Area
[Engine] (speed, kernels, models, the server and API)
### Desktop app, Terminal or source?
Source (START-HERE.bat, setup.sh or a build)
### What happened
`ListenAddress.test_ipv6_loopback` (`serve/test_security.py:67-93` in v0.2.12) guards the socket `bind()` and the `serve()` call with `except OSError: self.skipTest(...)`, but the client connection that follows is unguarded:
```python
c = http.client.HTTPConnection("::1", httpd.server_address[1], timeout=10)
try:
c.request("GET", "/health")
...
```
On this machine both guarded steps succeed (binding `::1` and `2001:db8::7`, and `serve(host="::")`), and then `connect()` to `::1` is refused by Windows with `PermissionError: [WinError 10013]`. The test therefore fails the suite instead of skipping like its own two guards intend, and a `PermissionError` is an `OSError`, so the existing guard would have caught it if it covered the connect.
Expected: the test skips with a message such as "IPv6 loopback is not available" when the loopback connection cannot be made, exactly as it already does when the bind fails.
Suggested fix: wrap the `HTTPConnection(...)` / `c.request(...)` block in the same `try/except OSError: self.skipTest(...)`, or do a preflight `socket.create_connection(("::1", httpd.server_address[1]), timeout=10)` inside that guard. No assertion changes: when the connection works, the 200 check stays.
### Smallest steps or command that reproduce it
```
.venv\Scripts\python.exe -m pytest serve\test_security.py::ListenAddress::test_ipv6_loopback -q
```
Actual (Python 3.14.6, Windows 11 25H2):
```
FAILED serve/test_security.py::ListenAddress::test_ipv6_loopback - PermissionError: [WinError 10013] ...
C:\Users\...\Python314\Lib\socket.py:859: PermissionError
1 failed
```
The final line of the traceback is `sock.connect(sa)`; the bind probes above it did not raise, so no `skipTest` ran.
### Reproduction status
Reproduced locally
### Strata version
Strata 0.2.12 (tag v0.2.12, commit 123bad4a) · engine 0.1.58
### Graphics card, memory and system
RTX 4090 24 GB · 253 GB RAM · Intel Core Ultra 9 285K · Windows 11 25H2 (build 26200.8655)
### Logs
```
________________________________ TestListenAddress.test_ipv6_loopback ________________________________
File "...\serve\test_security.py", line 85, in test_ipv6_loopback
c.request("GET", "/health")
File "...\Python314\Lib\http\client.py", line 1333, in request
self._send_request(method, url, body, headers, encode_chunked)
...
File "...\Python314\Lib\socket.py", line 859, in create_connection
sock.connect(sa)
E PermissionError: [WinError 10013] ...
```
本站相关内容
相关页面的快捷入口。