use of org.batfish.datamodel.SubRange in project batfish by batfish.
the class SecurityGroupsTest method testSinglePort.
@Test
public void testSinglePort() throws JSONException {
SecurityGroup sg = new SecurityGroup(_securityGroups.getJSONObject(0), null);
List<IpAccessListLine> inboundRules = new LinkedList<>();
List<IpAccessListLine> outboundRules = new LinkedList<>();
sg.addInOutAccessLines(inboundRules, outboundRules, _region);
assertThat(inboundRules, equalTo(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"))).setDstPorts(Sets.newHashSet(new SubRange(22, 22))).build(), _rejectSynOnly, _allowAllReverseOutboundRule)));
}
use of org.batfish.datamodel.SubRange in project batfish by batfish.
the class SecurityGroupsTest method testStatefulTcpRules.
@Test
public void testStatefulTcpRules() throws JSONException {
SecurityGroup sg = new SecurityGroup(_securityGroups.getJSONObject(8), null);
List<IpAccessListLine> inboundRules = new LinkedList<>();
List<IpAccessListLine> outboundRules = new LinkedList<>();
sg.addInOutAccessLines(inboundRules, outboundRules, _region);
assertThat(inboundRules, equalTo(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"))).setDstPorts(Sets.newHashSet(new SubRange(22, 22))).build(), _rejectSynOnly, // reverse of outbound rule
IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("5.6.7.8/32"))).setSrcPorts(Sets.newHashSet(new SubRange(80, 80))).build())));
assertThat(outboundRules, equalTo(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setDstIps(Sets.newHashSet(new IpWildcard("5.6.7.8/32"))).setDstPorts(Sets.newHashSet(new SubRange(80, 80))).build(), _rejectSynOnly, // reverse of inbound rule
IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setDstIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"))).setSrcPorts(Sets.newHashSet(new SubRange(22, 22))).build())));
}
use of org.batfish.datamodel.SubRange in project batfish by batfish.
the class SecurityGroupsTest method testBeginningHalfOpenInterval.
@Test
public void testBeginningHalfOpenInterval() throws JSONException {
SecurityGroup sg = new SecurityGroup(_securityGroups.getJSONObject(1), null);
List<IpAccessListLine> inboundRules = new LinkedList<>();
List<IpAccessListLine> outboundRules = new LinkedList<>();
sg.addInOutAccessLines(inboundRules, outboundRules, _region);
assertThat(inboundRules, equalTo(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"))).setDstPorts(Sets.newHashSet(new SubRange(0, 22))).build(), _rejectSynOnly, _allowAllReverseOutboundRule)));
}
use of org.batfish.datamodel.SubRange in project batfish by batfish.
the class SecurityGroupsTest method testInvalidEndInterval.
@Test
public void testInvalidEndInterval() throws JSONException {
SecurityGroup sg = new SecurityGroup(_securityGroups.getJSONObject(7), null);
List<IpAccessListLine> inboundRules = new LinkedList<>();
List<IpAccessListLine> outboundRules = new LinkedList<>();
sg.addInOutAccessLines(inboundRules, outboundRules, _region);
assertThat(inboundRules, equalTo(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"))).setDstPorts(Sets.newHashSet(new SubRange(30, 65535))).build(), _rejectSynOnly, _allowAllReverseOutboundRule)));
}
Aggregations