TrustedDestination { public abstract Range<IPAddress> hosts();  abstract Range<IPAddress> hosts(); abstract Optional<Range<Port>> ports(); boolean isATrustedHost(IPAddress candidate); boolean isATrustedPort(Port port);  }
@Test public void with_cidr_for_host() throws Exception { final ImmutableTrustedDestination destination = ImmutableTrustedDestination.builder().hosts(ImmutableCIDR.of("192.168.0.1/29")).build(); Assertions.assertThat(destination.hosts()).isEqualTo(ImmutableCIDR.of("192.168.0.1/29")); }
@Test public void with_single_ip_for_host() throws Exception { final ImmutableTrustedDestination destination = ImmutableTrustedDestination.builder().hosts(ImmutableIPAddress.of("192.168.0.1")).build(); Assertions.assertThat(destination.hosts()).isEqualTo(ImmutableIPAddress.of("192.168.0.1")); }
@Test public void with_ip_range_for_host() throws Exception { final ImmutableTrustedDestination destination = ImmutableTrustedDestination.builder() .hosts(ImmutableIPRange.builder() .from(ImmutableIPAddress.of("192.168.0.1")) .to(ImmutableIPAddress.of("192.168.0.7")) .build()) .build(); Assertions.assertThat(destination.hosts()).isEqualTo(ImmutableIPRange.builder() .from(ImmutableIPAddress.of("192.168.0.1")) .to(ImmutableIPAddress.of("192.168.0.7")) .build()); }