Search in sources :

Example 1 with PreInInterface

use of org.batfish.z3.state.PreInInterface 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))));
}
Also used : MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PostOutEdge(org.batfish.z3.state.PostOutEdge) PreInInterface(org.batfish.z3.state.PreInInterface) Edge(org.batfish.datamodel.Edge) PostOutEdge(org.batfish.z3.state.PostOutEdge) PreOutEdge(org.batfish.z3.state.PreOutEdge) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 2 with PreInInterface

use of org.batfish.z3.state.PreInInterface in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitPostInInterface.

@Test
public void testVisitPostInInterface() {
    SynthesizerInput input = MockSynthesizerInput.builder().setIncomingAcls(ImmutableMap.of(NODE1, ImmutableMap.of(INTERFACE1, ACL1, INTERFACE2, ACL2), NODE2, ImmutableMap.of(INTERFACE1, ACL1, INTERFACE2, ACL2))).setTopologyInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2, INTERFACE3), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2, INTERFACE3))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PostInInterface.State.INSTANCE)));
    // PassIncomingAcl
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclPermit(NODE1, ACL1), new PreInInterface(NODE1, INTERFACE1)), new PostInInterface(NODE1, INTERFACE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclPermit(NODE1, ACL2), new PreInInterface(NODE1, INTERFACE2)), new PostInInterface(NODE1, INTERFACE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PreInInterface(NODE1, INTERFACE3), new PostInInterface(NODE1, INTERFACE3))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclPermit(NODE2, ACL1), new PreInInterface(NODE2, INTERFACE1)), new PostInInterface(NODE2, INTERFACE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclPermit(NODE2, ACL2), new PreInInterface(NODE2, INTERFACE2)), new PostInInterface(NODE2, INTERFACE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(new PreInInterface(NODE2, INTERFACE3), new PostInInterface(NODE2, INTERFACE3))));
}
Also used : MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PostInInterface(org.batfish.z3.state.PostInInterface) AclPermit(org.batfish.z3.state.AclPermit) PreInInterface(org.batfish.z3.state.PreInInterface) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Example 3 with PreInInterface

use of org.batfish.z3.state.PreInInterface in project batfish by batfish.

the class DefaultTransitionGeneratorTest method testVisitNodeDropAclIn.

@Test
public void testVisitNodeDropAclIn() {
    SynthesizerInput input = MockSynthesizerInput.builder().setIncomingAcls(ImmutableMap.of(NODE1, ImmutableMap.of(INTERFACE1, ACL1, INTERFACE2, ACL2), NODE2, ImmutableMap.of(INTERFACE1, ACL1, INTERFACE2, ACL2))).setTopologyInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2))).build();
    Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeDropAclIn.State.INSTANCE)));
    // FailIncomingAcl
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclDeny(NODE1, ACL1), new PreInInterface(NODE1, INTERFACE1)), new NodeDropAclIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclDeny(NODE1, ACL2), new PreInInterface(NODE1, INTERFACE2)), new NodeDropAclIn(NODE1))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclDeny(NODE2, ACL1), new PreInInterface(NODE2, INTERFACE1)), new NodeDropAclIn(NODE2))));
    assertThat(rules, hasItem(new BasicRuleStatement(ImmutableSet.of(new AclDeny(NODE2, ACL2), new PreInInterface(NODE2, INTERFACE2)), new NodeDropAclIn(NODE2))));
}
Also used : AclDeny(org.batfish.z3.state.AclDeny) MockSynthesizerInput(org.batfish.z3.MockSynthesizerInput) SynthesizerInput(org.batfish.z3.SynthesizerInput) NodeDropAclIn(org.batfish.z3.state.NodeDropAclIn) TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) RuleStatement(org.batfish.z3.expr.RuleStatement) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) PreInInterface(org.batfish.z3.state.PreInInterface) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement) Test(org.junit.Test)

Aggregations

MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)3 SynthesizerInput (org.batfish.z3.SynthesizerInput)3 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)3 RuleStatement (org.batfish.z3.expr.RuleStatement)3 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)3 PreInInterface (org.batfish.z3.state.PreInInterface)3 Test (org.junit.Test)3 Edge (org.batfish.datamodel.Edge)1 AclDeny (org.batfish.z3.state.AclDeny)1 AclPermit (org.batfish.z3.state.AclPermit)1 NodeDropAclIn (org.batfish.z3.state.NodeDropAclIn)1 PostInInterface (org.batfish.z3.state.PostInInterface)1 PostOutEdge (org.batfish.z3.state.PostOutEdge)1 PreOutEdge (org.batfish.z3.state.PreOutEdge)1