Running tests without internet access


#1

This may sound like a strange request, but I was wondering if it was possible to run tests without them having access to the internet?


#2

It depends on the nature of the test :slight_smile: if your tests are making any HTTP requests then no, but otherwise this is not a problem.


#3

You could possible try running the tests in a Docker container. If you set the “–net none” flag, all network access to/from the container is disabled.


#4

My intention is actually to ensure my HTTP requests fall back correctly without internet access.


#5

That makes sense. I think @luhn’s suggestion would be great, you could also try to send the request to an unresolvable address.

I think you could also disable the network interface ifdown but this may have some other implications so I think messing with the container’s networking is not the best idea.


#6

Another option worht investigating, updating the /etc/hosts file for the length of your test with the domains you want to disable.


#7