summaryrefslogtreecommitdiffstats
path: root/acl/acl-impl/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'acl/acl-impl/src/test')
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java19
-rw-r--r--acl/acl-impl/src/test/resources/acl/standard/standard-acl-tcp-src-only.json37
2 files changed, 55 insertions, 1 deletions
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java
index bfdd17682..b4b4ef9ba 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java
@@ -168,7 +168,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void updateCurrentAttributesTcp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp.json")
- AccessLists standardAcls) throws Exception {
+ AccessLists standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -178,6 +178,23 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
verifyTcpRequest(aclIndex);
}
+ @Test
+ public void updateCurrentAttributesTcpSrcOnly(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp-src-only.json")
+ AccessLists standardAcls) throws Exception {
+ final int aclIndex = 4;
+ when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
+ final Acl data = standardAcls.getAcl().get(0);
+ aclCustomizer.updateCurrentAttributes(validId, data, data, writeContext);
+
+ verify(aclApi, times(1)).aclAddReplace(aclAddReplaceRequestCaptor.capture());
+ final AclAddReplace request = aclAddReplaceRequestCaptor.getValue();
+ final AclRule tcpRule = request.r[0];
+ assertTrue(Arrays.equals(new byte[]{-64, -88, 2, 2}, tcpRule.srcIpAddr));
+ assertEquals(32, tcpRule.srcIpPrefixLen);
+ assertTrue(Arrays.equals(new byte[]{0, 0, 0, 0}, tcpRule.dstIpAddr));
+ assertEquals(0, tcpRule.dstIpPrefixLen);
+ }
+
@Test
public void writeCurrentAttributesUdp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
diff --git a/acl/acl-impl/src/test/resources/acl/standard/standard-acl-tcp-src-only.json b/acl/acl-impl/src/test/resources/acl/standard/standard-acl-tcp-src-only.json
new file mode 100644
index 000000000..48e6f8807
--- /dev/null
+++ b/acl/acl-impl/src/test/resources/acl/standard/standard-acl-tcp-src-only.json
@@ -0,0 +1,37 @@
+{
+ "access-lists": {
+ "acl": [
+ {
+ "acl-name": "standard-acl",
+ "acl-type": "vpp-acl:vpp-acl",
+ "access-list-entries": {
+ "ace": [
+ {
+ "rule-name": "tcp-rule",
+ "matches": {
+ "vpp-ace-nodes": {
+ "source-ipv4-network": "192.168.2.2/32",
+ "tcp-nodes": {
+ "source-port-range": {
+ "lower-port": "1",
+ "upper-port": "5487"
+ },
+ "destination-port-range": {
+ "lower-port": "87",
+ "upper-port": "6745"
+ },
+ "tcp-flags-mask": "1",
+ "tcp-flags-value": "7"
+ }
+ }
+ },
+ "actions": {
+ "permit": {}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file