@Test public void userIdGroupsToAclLineExprs() { IpPermissions ipPermissions = new IpPermissions( "tcp", 22, 22, ImmutableList.of(), ImmutableList.of(), ImmutableList.of(new UserIdGroupPair(SG_ID, SG_DESC))); ExprAclLine line = ipPermissions.toIpAccessListLine(true, testRegion(), "acl line", new Warnings()); OrMatchExpr matchIpSpaces = new OrMatchExpr( ImmutableList.of( new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(Ip.parse("1.1.1.1").toIpSpace()).build(), traceElementEniPrivateIp(INSTANCE_1)), new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(Ip.parse("2.2.2.2").toIpSpace()).build(), traceElementEniPrivateIp(INSTANCE_2))), traceElementForAddress("source", SG_NAME, AddressType.SECURITY_GROUP)); assertThat( line, hasMatchCondition( new AndMatchExpr( ImmutableList.of(matchTcp, matchSSH, matchIpSpaces), getTraceElementForRule(SG_DESC)))); }
private List<AclLineMatchExpr> userIdGroupsToAclLineExprs( Region region, List<AclLineMatchExpr> protocolAndPortExprs, boolean ingress) { return _userIdGroupPairs.stream() .map( uIdGr -> Optional.ofNullable(region.getSecurityGroups().get(uIdGr.getGroupId())) .map( sg -> createAclLineExprForSg( protocolAndPortExprs, toMatchExpr(sg, ingress), uIdGr.getDescription()))) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableList.toImmutableList()); }
IpPermissions implements Serializable { private List<AclLineMatchExpr> userIdGroupsToAclLineExprs( Region region, List<AclLineMatchExpr> protocolAndPortExprs, boolean ingress) { return _userIdGroupPairs.stream() .map( uIdGr -> Optional.ofNullable(region.getSecurityGroups().get(uIdGr.getGroupId())) .map( sg -> createAclLineExprForSg( protocolAndPortExprs, toMatchExpr(sg, ingress), uIdGr.getDescription()))) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableList.toImmutableList()); } }
IpPermissions implements Serializable { private List<AclLineMatchExpr> userIdGroupsToAclLineExprs( Region region, List<AclLineMatchExpr> protocolAndPortExprs, boolean ingress) { return _userIdGroupPairs.stream() .map( uIdGr -> Optional.ofNullable(region.getSecurityGroups().get(uIdGr.getGroupId())) .map( sg -> createAclLineExprForSg( protocolAndPortExprs, toMatchExpr(sg, ingress), uIdGr.getDescription()))) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableList.toImmutableList()); } IpPermissions(
      String ipProtocol,
      @Nullable Integer fromPort,
      @Nullable Integer toPort,
      List<IpRange> ipRanges,
      List<String> prefixList,
      List<UserIdGroupPair> userIdGroupPairs); }
IpPermissions implements Serializable { private List<AclLineMatchExpr> userIdGroupsToAclLineExprs( Region region, List<AclLineMatchExpr> protocolAndPortExprs, boolean ingress) { return _userIdGroupPairs.stream() .map( uIdGr -> Optional.ofNullable(region.getSecurityGroups().get(uIdGr.getGroupId())) .map( sg -> createAclLineExprForSg( protocolAndPortExprs, toMatchExpr(sg, ingress), uIdGr.getDescription()))) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableList.toImmutableList()); } IpPermissions(
      String ipProtocol,
      @Nullable Integer fromPort,
      @Nullable Integer toPort,
      List<IpRange> ipRanges,
      List<String> prefixList,
      List<UserIdGroupPair> userIdGroupPairs); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Nullable Integer getFromPort(); @Nonnull String getIpProtocol(); @Nonnull List<IpRange> getIpRanges(); @Nonnull List<String> getPrefixList(); @Nonnull List<UserIdGroupPair> getUserIdGroupPairs(); @Nullable Integer getToPort(); }
IpPermissions implements Serializable { private List<AclLineMatchExpr> userIdGroupsToAclLineExprs( Region region, List<AclLineMatchExpr> protocolAndPortExprs, boolean ingress) { return _userIdGroupPairs.stream() .map( uIdGr -> Optional.ofNullable(region.getSecurityGroups().get(uIdGr.getGroupId())) .map( sg -> createAclLineExprForSg( protocolAndPortExprs, toMatchExpr(sg, ingress), uIdGr.getDescription()))) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableList.toImmutableList()); } IpPermissions(
      String ipProtocol,
      @Nullable Integer fromPort,
      @Nullable Integer toPort,
      List<IpRange> ipRanges,
      List<String> prefixList,
      List<UserIdGroupPair> userIdGroupPairs); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Nullable Integer getFromPort(); @Nonnull String getIpProtocol(); @Nonnull List<IpRange> getIpRanges(); @Nonnull List<String> getPrefixList(); @Nonnull List<UserIdGroupPair> getUserIdGroupPairs(); @Nullable Integer getToPort();  }