@Test
public void testIsIntranet() {

    String ipPrefix = "192.168.1.";
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETMASK, "255.255.255.255");
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETWORK, "192.168.1.1");
    assertTrue(accessManager.isIntranet("192.168.1.1"));
    assertFalse(accessManager.isIntranet("192.168.1.2"));
    assertFalse(accessManager.isIntranet("192.168.1.0"));
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETMASK, "255.255.255.254");
    assertTrue(accessManager.isIntranet("192.168.1.0"));
    assertTrue(accessManager.isIntranet("192.168.1.1"));
    assertFalse(accessManager.isIntranet("192.168.1.2"));
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETMASK, "255.255.255.252");
    assertTrue(accessManager.isIntranet("192.168.1.0"));
    assertTrue(accessManager.isIntranet("192.168.1.1"));
    assertTrue(accessManager.isIntranet("192.168.1.2"));
    assertTrue(accessManager.isIntranet("192.168.1.3"));
    assertFalse(accessManager.isIntranet("192.168.1.4"));
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETMASK, "255.255.255.248");
    for (int i = 1; i < 8; i++) {
        String ipToTest = ipPrefix + i;
        assertTrue("IP " + ipToTest +" is in the intranet", accessManager.isIntranet(ipToTest));
    }
    assertFalse("IP " + "192.168.1.8" +" is not in the intranet", accessManager.isIntranet("192.168.1.8"));
    settingManager.setValue(Settings.SYSTEM_INTRANET_NETMASK, "255.255.255.0");
    for (int i = 1; i < 256; i++) {
        String ipToTest = ipPrefix + i;
        assertTrue("IP " + ipToTest +" is in the intranet", accessManager.isIntranet(ipToTest));
    }
    assertFalse("IP " + "192.168.2.1" +" is not in the intranet", accessManager.isIntranet("192.168.2.1"));
}