ValidationController implements IPAddressProvider { @GetMapping({"/internal/ipinfo", "/protected/ipinfo"}) public IPInfo ipInfo(@RequestParam String ipAddress, @RequestParam(required = false) Integer networkPrefix) throws UnknownHostException { if (!validation(new Validation("ip", ipAddress))) { return new IPInfo(); } return getIpInfo(ipAddress, networkPrefix); } ValidationController(); @PostMapping({"/internal/validate", "/protected/validate"}) boolean validation(@Validated @RequestBody Validation validation); @GetMapping({"/internal/ipinfo", "/protected/ipinfo"}) IPInfo ipInfo(@RequestParam String ipAddress,
                         @RequestParam(required = false) Integer networkPrefix);  }
@Test public void ipInfo() throws Exception { assertIpInfo( subject.ipInfo("fe80:0:0:0:0:0:c0a8:11", 32), "fe80:0:ffff:ffff:ffff:ffff:ffff:ffff", "fe80:0:0:0:0:0:0:0", 7.922816251426434E28D, false); assertIpInfo( subject.ipInfo("192.168.6.56", 21), "192.168.7.255", "192.168.0.0", 2048D, true); }