use of org.batfish.representation.host.HostInterface in project batfish by batfish.
the class HostInterfaceTest method testShared.
@Test
public void testShared() throws IOException {
Ip sharedIp = new Ip("1.0.0.1");
InterfaceAddress sharedAddress = new InterfaceAddress(sharedIp, 24);
Prefix nonShared1Prefix = Prefix.parse("2.0.0.2/24");
Prefix nonShared2Prefix = Prefix.parse("3.0.0.2/24");
String ifaceSharedText = "{\"name\":\"shared_interface\", \"prefix\":\"" + sharedAddress + "\", \"shared\":true}";
String ifaceNonShared1Text = "{\"name\":\"non_shared1_interface\", \"prefix\":\"" + nonShared1Prefix + "\", \"shared\":false}";
String ifaceNonShared2Text = "{\"name\":\"non_shared2_interface\", \"prefix\":\"" + nonShared2Prefix + "\"}";
HostInterface sharedHostInterface = BatfishObjectMapper.mapper().readValue(ifaceSharedText, HostInterface.class);
HostInterface nonShared1HostInterface = BatfishObjectMapper.mapper().readValue(ifaceNonShared1Text, HostInterface.class);
HostInterface nonShared2HostInterface = BatfishObjectMapper.mapper().readValue(ifaceNonShared2Text, HostInterface.class);
Interface sharedInterface = sharedHostInterface.toInterface(_c, _w);
Interface nonShared1Interface = nonShared1HostInterface.toInterface(_c, _w);
Interface nonShared2Interface = nonShared2HostInterface.toInterface(_c, _w);
/*
* Check that shared status from text is propagated into instances with correct defaults.
*/
assertThat(sharedHostInterface, isShared());
assertThat(nonShared1HostInterface, not(isShared()));
assertThat(nonShared2HostInterface, not(isShared()));
/*
* The shared interface should contain source NAT info as indicated, while the other interfaces
* should not contain any source NAT information.
*/
assertThat(sharedInterface, hasSourceNats(hasItem(allOf(hasPoolIpFirst(sharedIp), hasPoolIpLast(sharedIp)))));
assertThat(nonShared1Interface, hasSourceNats(empty()));
assertThat(nonShared2Interface, hasSourceNats(empty()));
}
use of org.batfish.representation.host.HostInterface in project batfish by batfish.
the class HostInterfaceTest method testToInterface.
@Test
public void testToInterface() {
String name = "eth0";
HostInterface hi = new HostInterface(name);
hi.setCanonicalName(name);
Interface i = hi.toInterface(_c, new Warnings());
/* Check defaults */
assertThat(i, isProxyArp(equalTo(false)));
}
Aggregations