@Test public void testComputeServicePrefixFilter() { Ip serviceIp = Ip.parse("1.1.1.1"); Ip nonServiceIp = Ip.parse("6.6.6.6"); IpAccessList servicePrefixFilter = computeServicePrefixFilter(serviceIp.toIpSpace()); assertThat( servicePrefixFilter .filter( Flow.builder().setDstIp(serviceIp).setIngressNode("aa").build(), null, ImmutableMap.of(), ImmutableMap.of()) .getAction(), equalTo(LineAction.PERMIT)); assertThat( servicePrefixFilter .filter( Flow.builder().setDstIp(nonServiceIp).setIngressNode("aa").build(), null, ImmutableMap.of(), ImmutableMap.of()) .getAction(), equalTo(LineAction.DENY)); }
@VisibleForTesting static IpAccessList computeServicePrefixFilter(IpSpace servicePrefixSpace) { return IpAccessList.builder() .setName(SERVICE_PREFIX_FILTER) .setLines( ExprAclLine.builder() .setTraceElement(PERMIT_SERVICE_IPS) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setDstIps(servicePrefixSpace).build())) .setAction(LineAction.PERMIT) .build(), ExprAclLine.builder() .setTraceElement(DENY_NON_SERVICE_IPS) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build(); }
VpcEndpointGateway extends VpcEndpoint { @VisibleForTesting static IpAccessList computeServicePrefixFilter(IpSpace servicePrefixSpace) { return IpAccessList.builder() .setName(SERVICE_PREFIX_FILTER) .setLines( ExprAclLine.builder() .setTraceElement(PERMIT_SERVICE_IPS) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setDstIps(servicePrefixSpace).build())) .setAction(LineAction.PERMIT) .build(), ExprAclLine.builder() .setTraceElement(DENY_NON_SERVICE_IPS) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build(); } }
VpcEndpointGateway extends VpcEndpoint { @VisibleForTesting static IpAccessList computeServicePrefixFilter(IpSpace servicePrefixSpace) { return IpAccessList.builder() .setName(SERVICE_PREFIX_FILTER) .setLines( ExprAclLine.builder() .setTraceElement(PERMIT_SERVICE_IPS) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setDstIps(servicePrefixSpace).build())) .setAction(LineAction.PERMIT) .build(), ExprAclLine.builder() .setTraceElement(DENY_NON_SERVICE_IPS) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build(); } VpcEndpointGateway(String id, String serviceName, String vpcId, Map<String, String> tags); }
VpcEndpointGateway extends VpcEndpoint { @VisibleForTesting static IpAccessList computeServicePrefixFilter(IpSpace servicePrefixSpace) { return IpAccessList.builder() .setName(SERVICE_PREFIX_FILTER) .setLines( ExprAclLine.builder() .setTraceElement(PERMIT_SERVICE_IPS) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setDstIps(servicePrefixSpace).build())) .setAction(LineAction.PERMIT) .build(), ExprAclLine.builder() .setTraceElement(DENY_NON_SERVICE_IPS) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build(); } VpcEndpointGateway(String id, String serviceName, String vpcId, Map<String, String> tags); @Override boolean equals(@Nullable Object o); @Override int hashCode(); }
VpcEndpointGateway extends VpcEndpoint { @VisibleForTesting static IpAccessList computeServicePrefixFilter(IpSpace servicePrefixSpace) { return IpAccessList.builder() .setName(SERVICE_PREFIX_FILTER) .setLines( ExprAclLine.builder() .setTraceElement(PERMIT_SERVICE_IPS) .setMatchCondition( new MatchHeaderSpace( HeaderSpace.builder().setDstIps(servicePrefixSpace).build())) .setAction(LineAction.PERMIT) .build(), ExprAclLine.builder() .setTraceElement(DENY_NON_SERVICE_IPS) .setMatchCondition(TrueExpr.INSTANCE) .setAction(LineAction.DENY) .build()) .build(); } VpcEndpointGateway(String id, String serviceName, String vpcId, Map<String, String> tags); @Override boolean equals(@Nullable Object o); @Override int hashCode();  }