kiwicom / pytest-recording

A pytest plugin that allows recording network interactions via VCR.py
MIT License
425 stars 34 forks source link

List of allowed hosts for `block_network` #7

Closed Stranger6667 closed 4 years ago

Stranger6667 commented 5 years ago

Could be like this:

@pytest.mark.block_network(allowed_hosts=["example\.com", "google\..*"])
def test_something():
    ...

List of regular expressions as the input

ghost commented 4 years ago

Hello :wave: First of all thanks for a wonderful little package, it greatly simplifies testing network interactions for our team.

I'd like to ask, are there any plans to work on the feature described in this issue?

I have a use-case for it in which I'd like to allow connections to 127.0.0.1 (localhost) but keep everything else blocked. The rationale is that blocking localhost breaks our API test client / integration test suite, which relies on HTTP loopback to work. I already figured out how to prevent recording those interactions by setting ignore_localhost=True, and now I'd like to block all outbound network traffic (but NOT the test client HTTP requests to localhost).

Thank you :upside_down_face:

Stranger6667 commented 4 years ago

Thank you Miloš :) I think we can work on it next sprint :)

Stranger6667 commented 4 years ago

Released in 0.4.0 - https://pypi.org/project/pytest-recording/0.4.0/