use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOutEdge.
@Test
public void testVisitPreOutEdge() {
SynthesizerInput input = MockSynthesizerInput.builder().setArpTrueEdge(ImmutableMap.of(NODE1, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(1), INTERFACE4, b(2)), NODE4, ImmutableMap.of(INTERFACE3, b(3))), INTERFACE2, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(4)))), VRF2, ImmutableMap.of(INTERFACE3, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(5))))), NODE2, ImmutableMap.of(VRF1, ImmutableMap.of(INTERFACE1, ImmutableMap.of(NODE3, ImmutableMap.of(INTERFACE3, b(6))))))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOutEdge.State.INSTANCE)));
// DestinationRouting
assertThat(rules, hasItem(new BasicRuleStatement(b(1), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(2), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE3, INTERFACE4))));
assertThat(rules, hasItem(new BasicRuleStatement(b(3), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE1, NODE4, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(4), ImmutableSet.of(new PostInVrf(NODE1, VRF1), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE2, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(5), ImmutableSet.of(new PostInVrf(NODE1, VRF2), new PreOut(NODE1)), new PreOutEdge(NODE1, INTERFACE3, NODE3, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(b(6), ImmutableSet.of(new PostInVrf(NODE2, VRF1), new PreOut(NODE2)), new PreOutEdge(NODE2, INTERFACE1, NODE3, INTERFACE3))));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitAclDeny.
@Test
public void testVisitAclDeny() {
SynthesizerInput input = MockSynthesizerInput.builder().setAclActions(aclActions()).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(AclDeny.State.INSTANCE)));
// MatchDenyLine
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL1, 1), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL1, 3), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL2, 0), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE1, ACL2, 2), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL1, 1), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL1, 3), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL2, 0), new AclDeny(NODE2, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineMatch(NODE2, ACL2, 2), new AclDeny(NODE2, ACL2))));
// MatchNoLines
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE1, ACL1, 3), new AclDeny(NODE1, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE1, ACL2, 3), new AclDeny(NODE1, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclDeny(NODE1, ACL3))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE2, ACL1, 3), new AclDeny(NODE2, ACL1))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclLineNoMatch(NODE2, ACL2, 3), new AclDeny(NODE2, ACL2))));
assertThat(rules, hasItem(new BasicRuleStatement(new AclDeny(NODE1, ACL3))));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPostIn.
@Test
public void testVisitPostIn() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setEnabledInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PostIn.State.INSTANCE)));
// CopyOriginate
assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE1), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE2), new PostIn(NODE2))));
// ProjectPostInInterface
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE1), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE2), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE1), new PostIn(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE2), new PostIn(NODE2))));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitDropAclOut.
@Test
public void testVisitDropAclOut() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(DropAclOut.State.INSTANCE)));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAclOut(NODE1), DropAclOut.INSTANCE)));
assertThat(rules, hasItem(new BasicRuleStatement(new NodeDropAclOut(NODE2), DropAclOut.INSTANCE)));
}
use of org.batfish.z3.expr.BasicRuleStatement in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreInInterface.
@Test
public void testVisitPreInInterface() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledEdges(ImmutableSet.of(new Edge(NODE1, INTERFACE1, NODE2, INTERFACE1), new Edge(NODE1, INTERFACE1, NODE2, INTERFACE2), new Edge(NODE1, INTERFACE1, NODE2, INTERFACE3), new Edge(NODE1, INTERFACE2, NODE2, INTERFACE1), new Edge(NODE1, INTERFACE2, NODE2, INTERFACE2), new Edge(NODE1, INTERFACE2, NODE2, INTERFACE3), new Edge(NODE1, INTERFACE3, NODE2, INTERFACE1), new Edge(NODE1, INTERFACE3, NODE2, INTERFACE2), new Edge(NODE1, INTERFACE3, NODE2, INTERFACE3), new Edge(NODE2, INTERFACE1, NODE1, INTERFACE1), new Edge(NODE2, INTERFACE1, NODE1, INTERFACE2), new Edge(NODE2, INTERFACE1, NODE1, INTERFACE3), new Edge(NODE2, INTERFACE2, NODE1, INTERFACE1), new Edge(NODE2, INTERFACE2, NODE1, INTERFACE2), new Edge(NODE2, INTERFACE2, NODE1, INTERFACE3), new Edge(NODE2, INTERFACE3, NODE1, INTERFACE1), new Edge(NODE2, INTERFACE3, NODE1, INTERFACE2), new Edge(NODE2, INTERFACE3, NODE1, INTERFACE3))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreInInterface.State.INSTANCE)));
// PostOutNeighbor
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE1, NODE2, INTERFACE1)), new PreInInterface(NODE2, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE1, NODE2, INTERFACE2)), new PreInInterface(NODE2, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE1, NODE2, INTERFACE3)), new PreInInterface(NODE2, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE2, NODE2, INTERFACE1)), new PreInInterface(NODE2, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE2, NODE2, INTERFACE2)), new PreInInterface(NODE2, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE2, NODE2, INTERFACE3)), new PreInInterface(NODE2, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE3, NODE2, INTERFACE1)), new PreInInterface(NODE2, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE3, NODE2, INTERFACE2)), new PreInInterface(NODE2, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE1, INTERFACE3, NODE2, INTERFACE3)), new PreInInterface(NODE2, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE1, NODE1, INTERFACE1)), new PreInInterface(NODE1, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE1, NODE1, INTERFACE2)), new PreInInterface(NODE1, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE1, NODE1, INTERFACE3)), new PreInInterface(NODE1, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE2, NODE1, INTERFACE1)), new PreInInterface(NODE1, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE2, NODE1, INTERFACE2)), new PreInInterface(NODE1, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE2, NODE1, INTERFACE3)), new PreInInterface(NODE1, INTERFACE3))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE3, NODE1, INTERFACE1)), new PreInInterface(NODE1, INTERFACE1))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE3, NODE1, INTERFACE2)), new PreInInterface(NODE1, INTERFACE2))));
assertThat(rules, hasItem(new BasicRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(new PostOutEdge(NODE2, INTERFACE3, NODE1, INTERFACE3)), new PreInInterface(NODE1, INTERFACE3))));
}
Aggregations