@Test public void testConvertExtendsGatewaySecurityGroupsWithDefaultGatewayCidrsWithoutCCM() { ReflectionTestUtils.setField(underTest, "defaultGatewayCidr", Set.of("0.0.0.0/0", "1.1.1.1/1")); ReflectionTestUtils.setField(underTest, "nginxPort", 9443); underTest.extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack, Tunnel.DIRECT); Set<InstanceGroup> gateways = stack.getInstanceGroups().stream().filter(ig -> InstanceGroupType.isGateway(ig.getInstanceGroupType())).collect(Collectors.toSet()); for (InstanceGroup ig : gateways) { assertEquals(2, ig.getSecurityGroup().getSecurityRules().stream() .filter(rule -> rule.getCidr().equals("0.0.0.0/0") || rule.getCidr().equals("1.1.1.1/1") && Arrays.stream(rule.getPorts()).anyMatch(port -> port.equals("9443"))).count()); } }
public void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel) { Set<InstanceGroup> gateways = filterForGateways(stack); Set<String> defaultGatewayCidrs = filterEmptyCidrs(); LOGGER.debug("Extending security group for gateways: [{}] DefaultGatewayCidrs: [{}] Tunnel: [{}]", gateways.stream().map(InstanceGroup::getGroupName).collect(Collectors.joining(", ")), defaultGatewayCidrs, tunnel); if (!defaultGatewayCidrs.isEmpty() && !tunnel.useCcm()) { extendGatewaysSecurityGroupsWithRules(stack, gateways, defaultGatewayCidrs); } }
GatewaySecurityGroupDecorator { public void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel) { Set<InstanceGroup> gateways = filterForGateways(stack); Set<String> defaultGatewayCidrs = filterEmptyCidrs(); LOGGER.debug("Extending security group for gateways: [{}] DefaultGatewayCidrs: [{}] Tunnel: [{}]", gateways.stream().map(InstanceGroup::getGroupName).collect(Collectors.joining(", ")), defaultGatewayCidrs, tunnel); if (!defaultGatewayCidrs.isEmpty() && !tunnel.useCcm()) { extendGatewaysSecurityGroupsWithRules(stack, gateways, defaultGatewayCidrs); } } }
GatewaySecurityGroupDecorator { public void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel) { Set<InstanceGroup> gateways = filterForGateways(stack); Set<String> defaultGatewayCidrs = filterEmptyCidrs(); LOGGER.debug("Extending security group for gateways: [{}] DefaultGatewayCidrs: [{}] Tunnel: [{}]", gateways.stream().map(InstanceGroup::getGroupName).collect(Collectors.joining(", ")), defaultGatewayCidrs, tunnel); if (!defaultGatewayCidrs.isEmpty() && !tunnel.useCcm()) { extendGatewaysSecurityGroupsWithRules(stack, gateways, defaultGatewayCidrs); } }  }
GatewaySecurityGroupDecorator { public void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel) { Set<InstanceGroup> gateways = filterForGateways(stack); Set<String> defaultGatewayCidrs = filterEmptyCidrs(); LOGGER.debug("Extending security group for gateways: [{}] DefaultGatewayCidrs: [{}] Tunnel: [{}]", gateways.stream().map(InstanceGroup::getGroupName).collect(Collectors.joining(", ")), defaultGatewayCidrs, tunnel); if (!defaultGatewayCidrs.isEmpty() && !tunnel.useCcm()) { extendGatewaysSecurityGroupsWithRules(stack, gateways, defaultGatewayCidrs); } }  void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel); }
GatewaySecurityGroupDecorator { public void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel) { Set<InstanceGroup> gateways = filterForGateways(stack); Set<String> defaultGatewayCidrs = filterEmptyCidrs(); LOGGER.debug("Extending security group for gateways: [{}] DefaultGatewayCidrs: [{}] Tunnel: [{}]", gateways.stream().map(InstanceGroup::getGroupName).collect(Collectors.joining(", ")), defaultGatewayCidrs, tunnel); if (!defaultGatewayCidrs.isEmpty() && !tunnel.useCcm()) { extendGatewaysSecurityGroupsWithRules(stack, gateways, defaultGatewayCidrs); } }  void extendGatewaySecurityGroupWithDefaultGatewayCidrs(Stack stack, Tunnel tunnel);  }