http: Return bad request for invalid requests

This commit is contained in:
Martin Polden
2020-12-09 21:09:41 +01:00
parent a4808f1fa4
commit 86b68bdf55
2 changed files with 9 additions and 8 deletions

View File

@ -160,6 +160,7 @@ func TestJSONHandlers(t *testing.T) {
{s.URL + "/port/31337", "{\n \"ip\": \"127.0.0.1\",\n \"port\": 31337,\n \"reachable\": true\n}", 200},
{s.URL + "/port/80", "{\n \"ip\": \"127.0.0.1\",\n \"port\": 80,\n \"reachable\": true\n}", 200}, // checking that our test server is reachable on port 80
{s.URL + "/port/80?ip=1.3.3.7", "{\n \"ip\": \"127.0.0.1\",\n \"port\": 80,\n \"reachable\": true\n}", 200}, // ensuring that the "ip" parameter is not usable to check remote host ports
{s.URL + "/?ip=1.3.3.7/country", "{\n \"error\": \"could not parse IP: 1.3.3.7/country\"\n}", 400},
{s.URL + "/foo", "{\n \"error\": \"404 page not found\"\n}", 404},
{s.URL + "/health", `{"status":"OK"}`, 200},
}