@Test public void testComputeUnassociatedPrivateIpFilter_noPrivateIps() { IpAccessList unassociatedIpFilter = computeUnassociatedPrivateIpFilter(ImmutableList.of()); assertThat( unassociatedIpFilter, equalTo( IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build())); }
@VisibleForTesting static IpAccessList computeUnassociatedPrivateIpFilter(Collection<Ip> validPrivateIps) { ImmutableList.Builder<AclLine> aclLines = ImmutableList.builder(); if (!validPrivateIps.isEmpty()) { IpSpace validPrivateIpSpace = IpWildcardSetIpSpace.builder() .including( validPrivateIps.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); aclLines.add( ExprAclLine.builder() .setTraceElement(ALLOWED_ASSOCIATED_PRIVATE_IP_TRACE_ELEMENT) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(validPrivateIpSpace).build())) .setAction(LineAction.PERMIT) .build()); } aclLines.add( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()); return IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines(aclLines.build()) .build(); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static IpAccessList computeUnassociatedPrivateIpFilter(Collection<Ip> validPrivateIps) { ImmutableList.Builder<AclLine> aclLines = ImmutableList.builder(); if (!validPrivateIps.isEmpty()) { IpSpace validPrivateIpSpace = IpWildcardSetIpSpace.builder() .including( validPrivateIps.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); aclLines.add( ExprAclLine.builder() .setTraceElement(ALLOWED_ASSOCIATED_PRIVATE_IP_TRACE_ELEMENT) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(validPrivateIpSpace).build())) .setAction(LineAction.PERMIT) .build()); } aclLines.add( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()); return IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines(aclLines.build()) .build(); } }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static IpAccessList computeUnassociatedPrivateIpFilter(Collection<Ip> validPrivateIps) { ImmutableList.Builder<AclLine> aclLines = ImmutableList.builder(); if (!validPrivateIps.isEmpty()) { IpSpace validPrivateIpSpace = IpWildcardSetIpSpace.builder() .including( validPrivateIps.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); aclLines.add( ExprAclLine.builder() .setTraceElement(ALLOWED_ASSOCIATED_PRIVATE_IP_TRACE_ELEMENT) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(validPrivateIpSpace).build())) .setAction(LineAction.PERMIT) .build()); } aclLines.add( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()); return IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines(aclLines.build()) .build(); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static IpAccessList computeUnassociatedPrivateIpFilter(Collection<Ip> validPrivateIps) { ImmutableList.Builder<AclLine> aclLines = ImmutableList.builder(); if (!validPrivateIps.isEmpty()) { IpSpace validPrivateIpSpace = IpWildcardSetIpSpace.builder() .including( validPrivateIps.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); aclLines.add( ExprAclLine.builder() .setTraceElement(ALLOWED_ASSOCIATED_PRIVATE_IP_TRACE_ELEMENT) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(validPrivateIpSpace).build())) .setAction(LineAction.PERMIT) .build()); } aclLines.add( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()); return IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines(aclLines.build()) .build(); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); @Override String getId(); @Nonnull List<String> getAttachmentVpcIds(); @Override boolean equals(Object o); @Override int hashCode(); }
InternetGateway implements AwsVpcEntity, Serializable { @VisibleForTesting static IpAccessList computeUnassociatedPrivateIpFilter(Collection<Ip> validPrivateIps) { ImmutableList.Builder<AclLine> aclLines = ImmutableList.builder(); if (!validPrivateIps.isEmpty()) { IpSpace validPrivateIpSpace = IpWildcardSetIpSpace.builder() .including( validPrivateIps.stream().map(IpWildcard::create).collect(Collectors.toList())) .build(); aclLines.add( ExprAclLine.builder() .setTraceElement(ALLOWED_ASSOCIATED_PRIVATE_IP_TRACE_ELEMENT) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(validPrivateIpSpace).build())) .setAction(LineAction.PERMIT) .build()); } aclLines.add( ExprAclLine.builder() .setTraceElement(DENIED_UNASSOCIATED_PRIVATE_IP_TRACE) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()); return IpAccessList.builder() .setName(UNASSOCIATED_PRIVATE_IP_FILTER_NAME) .setLines(aclLines.build()) .build(); } InternetGateway(
      String internetGatewayId, List<String> attachmentVpcIds, Map<String, String> tags); @Override String getId(); @Nonnull List<String> getAttachmentVpcIds(); @Override boolean equals(Object o); @Override int hashCode();  }