summaryrefslogtreecommitdiffstats
path: root/acl/acl-impl/src/test
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-01-10 10:58:48 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-01-10 11:26:05 +0000
commita013f06756f8906355688baf67bf2b1af9da959a (patch)
tree4a7d58a9409c1d61e241a8358d3cd622411cc510 /acl/acl-impl/src/test
parent73c14a112bf24cc9ad5a73766058e0920d9aa7de (diff)
Fixing NPE in TCP/UDP L4 rules
Change-Id: Iae90f081c0add7ad9f6dd22229df683c6d395e78 Signed-off-by: Tomas Cechvala <tcechval@cisco.com> Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'acl/acl-impl/src/test')
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtoPreBindRuleProducerTest.java28
-rw-r--r--acl/acl-impl/src/test/resources/rules/tcp-rule-no-flags.json31
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