0

So, I have a express API that checks a list of blocked IPs, if the request IP matches one IP on the IPs blocked list, I want to sent a message to the end-user.

Now I'm implementing tests, I have been using supertest to make calls to my API endpoints

Let's say I want to make two calls the endpoint "/user":

  1. one call with IP 127.0.0.1 (default)
  2. one call with IP 127.0.1.1 (API should block this IP)

I found some old stackoverflow issues, did everything as shown in the answers, but none answers changed the supertest IP, therefore my API didn't return a message saying the IP was blocked

So, is there a way to automatically test IP bans?

Vitor Gouveia
  • 53
  • 2
  • 9
  • Can you elaborate on why the answers on the question you linked don’t meet your requirements, or more specifically how “*they don’t seem to work anymore*”? Nothing in the Express documentation indicates to me that they shouldn’t function as described any longer. – esqew Jul 08 '21 at 00:01
  • I edited the question, so, I implemented the answers, one at a time, and them both together, but it didn't work, when logging the request IP in the express API, the IP was unchanged – Vitor Gouveia Jul 08 '21 at 00:25
  • You may want to look into firewall solutions rather than hack into the network stack from express. – Brady Dean Jul 08 '21 at 00:37

0 Answers0