diff options
Diffstat (limited to 'acl/acl-impl/src/test')
-rw-r--r-- | acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java | 28 | ||||
-rw-r--r-- | acl/acl-impl/src/test/resources/rules/tcp-rule-no-flags.json | 31 |
2 files changed, 59 insertions, 0 deletions
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java index 24de2c999..eb177f10b 100644 --- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java +++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java @@ -77,6 +77,34 @@ public class ProtoPreBindRuleProducerTest implements ProtoPreBindRuleProducer, A } @Test + public void testTcpRuleNoFlags(@InjectTestData(resourcePath = "/rules/tcp-rule-no-flags.json") AccessLists acls) { + final AclRule tcpRule = createPreBindRule(extractAce(acls)); + assertEquals(6, tcpRule.proto); + assertEquals(123, tcpRule.srcportOrIcmptypeFirst); + assertEquals(123, tcpRule.srcportOrIcmptypeLast); + assertEquals((short)65000, tcpRule.dstportOrIcmpcodeFirst); + assertEquals((short)65000, tcpRule.dstportOrIcmpcodeLast); + assertEquals(0, tcpRule.tcpFlagsMask); + assertEquals(0, tcpRule.tcpFlagsValue); + } + + @Test + public void testSourcePortRangeNotGiven() { + AclRule rule = new AclRule(); + ProtoPreBindRuleProducer.bindSourcePortRange(rule, null); + assertEquals(0, rule.srcportOrIcmptypeFirst); + assertEquals(MAX_PORT_NUMBER, rule.srcportOrIcmptypeLast); + } + + @Test + public void testDestinationPortRangeNotGiven() { + AclRule rule = new AclRule(); + ProtoPreBindRuleProducer.bindDestinationPortRange(rule, null); + assertEquals(0, rule.dstportOrIcmpcodeFirst); + assertEquals(MAX_PORT_NUMBER, rule.dstportOrIcmpcodeLast); + } + + @Test public void testUdpRule(@InjectTestData(resourcePath = "/rules/udp-rule.json") AccessLists acls) { final AclRule udpRule = createPreBindRule(extractAce(acls)); assertEquals(17, udpRule.proto); diff --git a/acl/acl-impl/src/test/resources/rules/tcp-rule-no-flags.json b/acl/acl-impl/src/test/resources/rules/tcp-rule-no-flags.json new file mode 100644 index 000000000..31cc854df --- /dev/null +++ b/acl/acl-impl/src/test/resources/rules/tcp-rule-no-flags.json @@ -0,0 +1,31 @@ +{ + "access-lists": { + "acl": [ + { + "acl-name": "standard-acl", + "acl-type": "vpp-acl:vpp-acl", + "access-list-entries": { + "ace": [ + { + "rule-name": "tcp-no-flags-rule", + "matches": { + "vpp-ace-nodes": { + "destination-ipv4-network": "192.168.2.1/32", + "source-ipv4-network": "192.168.2.2/32", + "tcp-nodes": { + "source-port-range": { + "lower-port": "123" + }, + "destination-port-range": { + "lower-port": "65000" + } + } + } + } + } + ] + } + } + ] + } +}
\ No newline at end of file |