### Question:
FileBasedClusterNodeFirewall implements ClusterNodeFirewall { @Override public boolean isPermissible(final String hostOrIp) { try { if (subnetInfos.isEmpty()) { return true; } final String ip; try { ip = InetAddress.getByName(hostOrIp).getHostAddress(); } catch (final UnknownHostException uhe) { logger.warn("Blocking unknown host '{}'", hostOrIp, uhe); return false; } for (final SubnetUtils.SubnetInfo subnetInfo : subnetInfos) { if (subnetInfo.isInRange(ip)) { return true; } } logger.debug("Blocking host '{}' because it does not match our allowed list.", hostOrIp); return false; } catch (final IllegalArgumentException iae) { logger.debug("Blocking requested host, '{}', because it is malformed.", hostOrIp, iae); return false; } } FileBasedClusterNodeFirewall(final File config);  FileBasedClusterNodeFirewall(final File config, final File restoreDirectory); @Override boolean isPermissible(final String hostOrIp);  }### Answer:
@Test public void ensureBadDataWasIgnored() { assumeTrue(badHostsDoNotResolve); assertFalse("firewall treated our malformed data as a host. If " + "`host \"bad data should be skipped\"` works locally, this test should have been " + "skipped.", ipsFirewall.isPermissible("bad data should be skipped")); assertFalse("firewall treated our malformed data as a host. If " + "`host \"more bad data\"` works locally, this test should have been " + "skipped.", ipsFirewall.isPermissible("more bad data")); }
@Test public void testIsPermissibleWithExactMatch() { assertTrue(ipsFirewall.isPermissible("2.2.2.2")); }
@Test public void testIsPermissibleWithSubnetMatch() { assertTrue(ipsFirewall.isPermissible("3.3.3.255")); }
@Test public void testIsPermissibleWithNoMatch() { assertFalse(ipsFirewall.isPermissible("255.255.255.255")); }
@Test public void testIsPermissibleWithMalformedData() { assumeTrue(badHostsDoNotResolve); assertFalse("firewall allowed host '" + NONEXISTENT_HOSTNAME + "' rather than rejecting as malformed. If `host " + NONEXISTENT_HOSTNAME + "` " + "works locally, this test should have been skipped.", ipsFirewall.isPermissible(NONEXISTENT_HOSTNAME)); }
@Test public void testIsPermissibleWithEmptyConfig() { assertTrue(acceptAllFirewall.isPermissible("1.1.1.1")); }
@Test public void testIsPermissibleWithEmptyConfigWithMalformedData() { assumeTrue(badHostsDoNotResolve); assertTrue("firewall did not allow malformed host '" + NONEXISTENT_HOSTNAME + "' under permissive configs. If " + "`host " + NONEXISTENT_HOSTNAME + "` works locally, this test should have been skipped.", acceptAllFirewall.isPermissible(NONEXISTENT_HOSTNAME)); }