public void testFilter() throws Exception { filt.setAllowedFilters(new StringBuffer("172.16.25.*;10.0.4.1")); filt.setNotAllowedFilters(new StringBuffer("172.16.25.128/25")); assertNotAllowed(new StringBuffer("10.0.4.13")); assertAllowed(new StringBuffer("10.0.4.1")); assertAllowed(new StringBuffer("172.16.25.1")); assertNotAllowed(new StringBuffer("172.16.25.131")); }
public void checkFilter(StringBuffer s, int shouldBeAllowed) throws IpFilter.MalformedException { // IpFilter.Addr ip = new IpFilter.Addr(s); // boolean match = filt.isIpAllowed(ip); int match = filt.isIpAllowed(s, true, IpFilter.FLAG); if (match != shouldBeAllowed) { fail("isIpAllowed(" + s + ") was " + match + ", should have been " + shouldBeAllowed); } }