SharedLocationSecurityGroupCustomizer extends BasicJcloudsLocationCustomizer { @Override public void customize(JcloudsLocation location, ComputeService computeService, Template template) { if(!enabled) return; super.customize(location, computeService, template); inboundPorts = template.getOptions().getInboundPorts(); final JcloudsLocationSecurityGroupCustomizer instance = getInstance(getSharedGroupId(location)); if (cidr != null) instance.setSshCidrSupplier(Suppliers.ofInstance(new Cidr(cidr))); instance.customize(location, computeService, template); }  void setLocationName(String locationName); void setTcpPortRanges(List<String> tcpPortRanges); void setUdpPortRanges(List<String> udpPortRanges); void setOpenIcmp(Boolean openIcmp); void setCidr(String cidr); void setEnabled(boolean enabled); @Override void customize(JcloudsLocation location, ComputeService computeService, Template template); @Override void customize(JcloudsLocation location, ComputeService computeService, JcloudsMachineLocation machine); Collection<SecurityGroup> applySecurityGroupCustomizations(JcloudsLocation location, ComputeService computeService, JcloudsMachineLocation machine);  }
@Test public void testCidrNotSetIfNotavailable() { customizer.customize(jcloudsLocation, computeService, mockTemplate); verify(sgCustomizer, never()).setSshCidrSupplier(any(Supplier.class)); }
@Test public void testInboundPortsAddedToPermissions() { when(mockOptions.getInboundPorts()).thenReturn(new int[]{5}); when(sgCustomizer.getBrooklynCidrBlock()).thenReturn("10.10.10.10/24"); customizer.customize(jcloudsLocation, computeService, mockTemplate); customizer.customize(jcloudsLocation, computeService, mock(JcloudsMachineLocation.class)); assertPermissionsAdded(5, 5, IpProtocol.TCP); }