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?
It depends on the nature of the test if your tests are making any HTTP requests then no, but otherwise this is not a problem.
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.
My intention is actually to ensure my HTTP requests fall back correctly without internet access.
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.
Another option worht investigating, updating the
/etc/hosts file for the length of your test with the domains you want to disable.