Search in sources :

Example 71 with Configuration

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"))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) Test(org.junit.Test)

Example 72 with Configuration

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"))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) Test(org.junit.Test)

Example 73 with Configuration

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));
    }
}
Also used : IpWildcard(org.batfish.datamodel.IpWildcard) Configuration(org.batfish.datamodel.Configuration) IpAccessListLine(org.batfish.datamodel.IpAccessListLine) IpAccessList(org.batfish.datamodel.IpAccessList) SubRange(org.batfish.datamodel.SubRange) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 74 with Configuration

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))))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) IpSpace(org.batfish.datamodel.IpSpace) IpSpaceMatchExpr(org.batfish.z3.expr.IpSpaceMatchExpr) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Example 75 with Configuration

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)))));
}
Also used : Configuration(org.batfish.datamodel.Configuration) InterfaceAddress(org.batfish.datamodel.InterfaceAddress) Ip(org.batfish.datamodel.Ip) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Test(org.junit.Test)

Aggregations

Configuration (org.batfish.datamodel.Configuration)170 Test (org.junit.Test)69 Interface (org.batfish.datamodel.Interface)55 Ip (org.batfish.datamodel.Ip)49 Vrf (org.batfish.datamodel.Vrf)45 HashMap (java.util.HashMap)44 Topology (org.batfish.datamodel.Topology)38 VendorConfiguration (org.batfish.vendor.VendorConfiguration)35 Prefix (org.batfish.datamodel.Prefix)33 Edge (org.batfish.datamodel.Edge)32 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)30 Map (java.util.Map)29 Set (java.util.Set)29 TreeMap (java.util.TreeMap)29 BatfishException (org.batfish.common.BatfishException)28 IpAccessList (org.batfish.datamodel.IpAccessList)26 ArrayList (java.util.ArrayList)25 HashSet (java.util.HashSet)25 List (java.util.List)25 SortedSet (java.util.SortedSet)24