MCPcopy
hub / github.com/benoitc/gunicorn / test_forbidden_ip

Method test_forbidden_ip

tests/test_uwsgi.py:256–265  ·  view source on GitHub ↗

Test error when source IP not in allow list.

(self)

Source from the content-addressed store, hash-verified

254 assert 'truncated' in str(exc_info.value)
255
256 def test_forbidden_ip(self):
257 """Test error when source IP not in allow list."""
258 packet = make_uwsgi_packet({'REQUEST_METHOD': 'GET', 'PATH_INFO': '/'})
259 unreader = IterUnreader([packet])
260 cfg = MockConfig(uwsgi_allow_ips=['192.168.1.1'])
261
262 with pytest.raises(ForbiddenUWSGIRequest) as exc_info:
263 UWSGIRequest(cfg, unreader, ('10.0.0.1', 12345))
264 assert exc_info.value.code == 403
265 assert '10.0.0.1' in str(exc_info.value)
266
267 def test_allowed_ip_wildcard(self):
268 """Test that wildcard allows any IP."""

Callers

nothing calls this directly

Calls 4

IterUnreaderClass · 0.90
UWSGIRequestClass · 0.90
make_uwsgi_packetFunction · 0.85
MockConfigClass · 0.70

Tested by

no test coverage detected