use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class ElasticsearchDomainTest method testEsSubnetEdge.
@Test
public void testEsSubnetEdge() throws IOException {
Map<String, Configuration> configurations = loadAwsConfigurations();
Topology topology = CommonUtil.synthesizeTopology(configurations);
// check that ES instance is a neighbor of both subnets in which its interfaces are
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("es-domain", "es-domain-subnet-073b8061"))));
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("es-domain", "es-domain-subnet-1f315846"))));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class RdsInstanceTest method testRdsSubnetEdge.
@Test
public void testRdsSubnetEdge() throws IOException {
Map<String, Configuration> configurations = loadAwsConfigurations();
Topology topology = CommonUtil.synthesizeTopology(configurations);
// check that RDS instance is a neighbor of both subnets in which its interfaces are
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-073b8061", "subnet-073b8061"), new NodeInterfacePair("test-rds", "test-rds-subnet-073b8061"))));
assertThat(topology.getEdges(), hasItem(new Edge(new NodeInterfacePair("subnet-1f315846", "subnet-1f315846"), new NodeInterfacePair("test-rds", "test-rds-subnet-1f315846"))));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class RdsInstanceTest method testSecurityGroupsAcl.
@Test
public void testSecurityGroupsAcl() throws IOException {
Map<String, Configuration> configurations = loadAwsConfigurations();
assertThat(configurations, hasKey("test-rds"));
assertThat(configurations.get("test-rds").getInterfaces().entrySet(), hasSize(2));
IpAccessListLine rejectSynOnly = IpAccessListLine.builder().setTcpFlags(ImmutableSet.of(TcpFlags.SYN_ONLY)).setAction(LineAction.REJECT).build();
IpAccessList expectedIncomingFilter = new IpAccessList("~SECURITY_GROUP_INGRESS_ACL~", Lists.newArrayList(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setSrcIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"), new IpWildcard("10.193.16.105/32"))).setDstPorts(Sets.newHashSet(new SubRange(45, 50))).build(), rejectSynOnly, IpAccessListLine.builder().setAction(LineAction.ACCEPT).setSrcIps(Sets.newHashSet(new IpWildcard("0.0.0.0/0"))).build()));
IpAccessList expectedOutgoingFilter = new IpAccessList("~SECURITY_GROUP_EGRESS_ACL~", Lists.newArrayList(IpAccessListLine.builder().setAction(LineAction.ACCEPT).setDstIps(Sets.newHashSet(new IpWildcard("0.0.0.0/0"))).build(), rejectSynOnly, IpAccessListLine.builder().setAction(LineAction.ACCEPT).setIpProtocols(Sets.newHashSet(IpProtocol.TCP)).setDstIps(Sets.newHashSet(new IpWildcard("1.2.3.4/32"), new IpWildcard("10.193.16.105/32"))).setSrcPorts(Sets.newHashSet(new SubRange(45, 50))).build()));
for (Interface iface : configurations.get("test-rds").getInterfaces().values()) {
assertThat(iface.getIncomingFilter(), equalTo(expectedIncomingFilter));
assertThat(iface.getOutgoingFilter(), equalTo(expectedOutgoingFilter));
}
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class SynthesizerInputImplTest method testComputeNeighborUnreachable.
@Test
public void testComputeNeighborUnreachable() {
Configuration node = _cb.build();
Vrf vrf = _vb.setOwner(node).build();
Interface iface1 = _ib.setOwner(node).setVrf(vrf).build();
Interface iface2 = _ib.build();
IpSpace ipSpace1 = Ip.ZERO;
IpSpace ipSpace2 = Ip.MAX;
IpSpaceMatchExpr m1 = new IpSpaceMatchExpr(ipSpace1, false, true);
IpSpaceMatchExpr m2 = new IpSpaceMatchExpr(ipSpace2, false, true);
SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(node.getName(), node)).build();
SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().setNeighborUnreachable(ImmutableMap.of(node.getName(), ImmutableMap.of(vrf.getName(), ImmutableMap.of(iface1.getName(), ipSpace1, iface2.getName(), ipSpace2)))).build()).setTopology(new Topology(ImmutableSortedSet.of())).build();
assertThat(inputWithoutDataPlane, hasNeighborUnreachable(nullValue()));
assertThat(inputWithDataPlane, hasNeighborUnreachable(equalTo(ImmutableMap.of(node.getHostname(), ImmutableMap.of(vrf.getName(), ImmutableMap.of(iface1.getName(), m1, iface2.getName(), m2))))));
}
use of org.batfish.datamodel.Configuration in project batfish by batfish.
the class SynthesizerInputImplTest method testComputeIpsByHostname.
@Test
public void testComputeIpsByHostname() {
Configuration c = _cb.build();
Vrf v = _vb.setOwner(c).build();
// Enabled but not flow sink. Should not appear in enabledFlowSinks.
Ip ipEnabled1 = new Ip("1.1.1.1");
Ip ipEnabled2 = new Ip("2.2.2.2");
Ip ipDisabled = new Ip("3.3.3.3");
// enabledInterface1
_ib.setOwner(c).setVrf(v).setAddress(new InterfaceAddress(ipEnabled1, Prefix.MAX_PREFIX_LENGTH)).build();
// enabledInterface1
_ib.setAddress(new InterfaceAddress(ipEnabled2, Prefix.MAX_PREFIX_LENGTH)).build();
// disabledInterface
_ib.setAddress(new InterfaceAddress(ipDisabled, Prefix.MAX_PREFIX_LENGTH)).setActive(false).build();
SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(c.getName(), c)).build();
SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().build()).setTopology(new Topology(ImmutableSortedSet.of())).build();
assertThat(inputWithoutDataPlane, hasIpsByHostname(nullValue()));
assertThat(inputWithDataPlane, hasIpsByHostname(equalTo(ImmutableMap.of(c.getName(), ImmutableSet.of(ipEnabled1, ipEnabled2)))));
}
Aggregations