summaryrefslogtreecommitdiffstats
path: root/acl/acl-impl/src/test/java
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2018-11-19 14:59:14 +0100
committerMichal Cmarada <mcmarada@cisco.com>2018-11-19 14:59:14 +0100
commit718e9a3c7cac01860f3e3fe6174fcc1bd33fb4eb (patch)
tree34fae7680450e166e845f0c2db84ed8c3215930f /acl/acl-impl/src/test/java
parentf9acfac8b701f9903a28edc98db127c36d73384f (diff)
HC2VPP-291: ACL model bump
- bump ACL yang models - fix ACL module implementation and validation - fix ACL Unit tests - update postman collection Change-Id: Iaab64e6d92d17babc3ccef7921b41070c3716516 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'acl/acl-impl/src/test/java')
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/AclTestSchemaContext.java8
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java)109
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java52
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java)30
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java)32
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java183
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java150
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractorTest.java144
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/StandardAceDataExtractorTest.java327
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java20
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/macip/MacIpInterfaceAssignmentRequestTest.java24
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtocolParsingTest.java143
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/AclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclCustomizerTest.java)51
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/AclValidatorTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclValidatorTest.java)80
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java72
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclMacipCustomizerTest.java45
16 files changed, 783 insertions, 687 deletions
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/AclTestSchemaContext.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/AclTestSchemaContext.java
index 6eb6862bf..6e10be47a 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/AclTestSchemaContext.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/AclTestSchemaContext.java
@@ -33,13 +33,11 @@ public interface AclTestSchemaContext {
.getInstance(),
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.$YangModuleInfoImpl
.getInstance(),
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160708.$YangModuleInfoImpl
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.$YangModuleInfoImpl
.getInstance(),
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.$YangModuleInfoImpl
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.$YangModuleInfoImpl
.getInstance(),
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.$YangModuleInfoImpl
- .getInstance(),
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.$YangModuleInfoImpl
+ org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.acl.rev181022.$YangModuleInfoImpl
.getInstance()));
return context;
}
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java
index 074b25b29..beda3ccff 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.util.AclContextManager;
import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -35,29 +36,34 @@ import io.fd.vpp.jvpp.acl.dto.AclDetailsReplyDump;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetails;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetails;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetailsReplyDump;
import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
import java.util.ArrayList;
+import java.util.Collections;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceStateAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-public abstract class AbstractVppAclCustomizerTest
- extends InitializingListReaderCustomizerTest<VppAcls, VppAclsKey, VppAclsBuilder> {
+public abstract class AbstractAclCustomizerTest
+ extends InitializingListReaderCustomizerTest<AclSet, AclSetKey, AclSetBuilder> {
protected static final String IF_NAME = "eth1";
protected static final int IF_ID = 1;
+ protected static final int ACL_ID = 1;
+ protected static final int ACL_MAC_ID = 2;
+ private static final String ACL_NAME = "acl-name";
+ private static final String ACL_MAC_NAME = "acl-mac-name";
protected static final String IF_NAME_NO_ACL = "eth2";
protected static final int IF_ID_NO_ACL = 2;
@@ -73,32 +79,39 @@ public abstract class AbstractVppAclCustomizerTest
@Mock
protected AclContextManager standardAclContext;
- protected AbstractVppAclCustomizerTest(final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
- super(VppAcls.class, parentBuilderClass);
+ @Mock
+ protected AclContextManager macIpAclContext;
+
+ protected AbstractAclCustomizerTest(final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(AclSet.class, parentBuilderClass);
}
- protected static InstanceIdentifier<Acl> getAclId(final String ifName) {
- return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(ifName))
- .augmentation(VppAclInterfaceStateAugmentation.class).child(Acl.class);
+ protected static KeyedInstanceIdentifier<Interface, InterfaceKey> getAclId(final String ifName) {
+ return AclIIds.ACLS_AP.child(Interface.class, new InterfaceKey(ifName));
}
@Override
protected void setUp() throws Exception {
defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
+ when(macIpAclContext.getAclName(ACL_MAC_ID, mappingContext)).thenReturn(ACL_MAC_NAME);
+ when(standardAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
+ when(macIpAclContext.containsAcl(ACL_MAC_NAME, mappingContext)).thenReturn(true);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(0);
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
+ when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
}
@Test
public void testGetAllIdsNoAclConfigured() throws ReadFailedException {
- final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
- when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
}
@Test
public void testRead() throws ReadFailedException {
final String aclName = "acl-name";
- final Class<VppAcl> aclType = VppAcl.class;
defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME);
final AclDetailsReplyDump reply = new AclDetailsReplyDump();
@@ -108,19 +121,25 @@ public abstract class AbstractVppAclCustomizerTest
reply.aclDetails.add(detail);
when(aclApi.aclDump(any())).thenReturn(future(reply));
- final VppAclsBuilder builder = mock(VppAclsBuilder.class);
- getCustomizer().readCurrentAttributes(getIid(IF_NAME, new VppAclsKey(aclName, aclType)), builder, ctx);
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME, new AclSetKey(aclName)), builder, ctx);
verify(builder).setName(aclName);
- verify(builder).setType(aclType);
}
@Test
public void testReadAllTwoIfacesInOneTx() throws ReadFailedException {
final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 2, "acl1", "acl2", "acl3");
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(0);
+ final MacipAclInterfaceListDetailsReplyDump macReply2 = macAaclInterfaceDump(1);
+ final MacipAclInterfaceGetReply interfaceGet = macipAclInterfaceGetReply();
+
+
when(aclApi.aclInterfaceListDump(aclInterfaceRequest(IF_ID))).thenReturn(future(reply));
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(interfaceGet));
when(aclApi.aclInterfaceListDump(aclInterfaceRequest(IF_ID_NO_ACL)))
- .thenReturn(future(aclInterfaceDump((byte) 0)));
+ .thenReturn(future(aclInterfaceDump((byte) 0)));
// read all for interface with defined ACLs:
assertFalse(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
@@ -128,19 +147,28 @@ public abstract class AbstractVppAclCustomizerTest
assertEquals(0, getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).size());
}
+ protected MacipAclInterfaceGetReply macipAclInterfaceGetReply(final String... aclNames) {
+ final MacipAclInterfaceGetReply reply = new MacipAclInterfaceGetReply();
+ reply.acls = new int[aclNames.length];
+ for (int i = 0; i < aclNames.length; ++i) {
+ defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
+ reply.acls[i] = i;
+ }
+ reply.count = (byte) aclNames.length;
+ return reply;
+ }
+
@Test
public void testInit() {
final String aclName = "acl-name";
- final Class<VppAcl> aclType = VppAcl.class;
defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME);
- final VppAcls readValue = new VppAclsBuilder().build();
+ final AclSet readValue = new AclSetBuilder().build();
final Initialized<? extends DataObject> cfgValue =
- getCustomizer().init(getIid(IF_NAME, new VppAclsKey(aclName, aclType)), readValue, ctx);
+ getCustomizer().init(getIid(IF_NAME, new AclSetKey(aclName)), readValue, ctx);
assertEquals(readValue, cfgValue.getData());
- assertNotNull(cfgValue.getId().firstKeyOf(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class));
- assertEquals(cfgValue.getId().getTargetType(), VppAcls.class);
+ assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
+ assertEquals(cfgValue.getId().getTargetType(), AclSet.class);
}
protected AclInterfaceListDump aclInterfaceRequest(final int swIfIndex) {
@@ -157,12 +185,31 @@ public abstract class AbstractVppAclCustomizerTest
defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
details.acls[i] = i;
}
+ details.count = (byte) aclNames.length;
details.nInput = nInput;
reply.aclInterfaceListDetails.add(details);
return reply;
}
- protected abstract InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName);
+ protected MacipAclInterfaceListDetailsReplyDump macAaclInterfaceDump(int swIfIndex, final String... aclNames) {
+ final MacipAclInterfaceListDetailsReplyDump assignedAcls = new MacipAclInterfaceListDetailsReplyDump();
+
+ MacipAclInterfaceListDetails details = new MacipAclInterfaceListDetails();
+ details.swIfIndex = swIfIndex;
+ details.count = (byte) aclNames.length;
+ details.acls = new int[aclNames.length];
+ for (int i = 0; i < aclNames.length; ++i) {
+ defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
+ details.acls[i] = i;
+ }
+
+ assignedAcls.macipAclInterfaceListDetails.add(details);
+ assignedAcls.macipAclInterfaceListDetails = Collections.singletonList(details);
+
+ return assignedAcls;
+ }
+
+ protected abstract InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName);
- protected abstract InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key);
+ protected abstract InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key);
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
index 1b4403b2d..7501815a6 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
@@ -35,18 +35,15 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessListsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.Ace;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.Deny;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppMacipAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAce;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.VppAceNodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Other;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Acls;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.AclsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Drop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.L4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.Icmp;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -58,7 +55,7 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
private static final String MACIP_ACL_NAME = "vpp-macip-acl";
private static final String MACIP_ACE_NAME = "vpp-macip-ace";
private static final int MACIP_ACL_INDEX = 456;
- private static final short PROTOCOL = 2;
+ private static final short PROTOCOL = 1;
@Mock
private FutureJVppAclFacade aclApi;
@Mock
@@ -66,13 +63,12 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
@Mock
private AclContextManager macipAclContext;
private KeyedInstanceIdentifier<Acl, AclKey> ACL_IID =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(
- ACL_NAME, VppAcl.class));
+ InstanceIdentifier.create(Acls.class).child(Acl.class, new AclKey(ACL_NAME));
private KeyedInstanceIdentifier<Acl, AclKey> MACIP_ACL_IID =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(MACIP_ACL_NAME, VppMacipAcl.class));
+ InstanceIdentifier.create(Acls.class).child(Acl.class, new AclKey(MACIP_ACL_NAME));
public AclCustomizerTest() {
- super(Acl.class, AccessListsBuilder.class);
+ super(Acl.class, AclsBuilder.class);
}
@Override
@@ -103,15 +99,18 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
when(standardAclContext.getAclName(ACL_INDEX, mappingContext)).thenReturn(ACL_NAME);
when(standardAclContext.getAclIndex(ACL_NAME, mappingContext)).thenReturn(ACL_INDEX);
when(standardAclContext.getAceName(ACL_NAME, 0, mappingContext)).thenReturn(ACE_NAME);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
when(macipAclContext.getAclName(MACIP_ACL_INDEX, mappingContext)).thenReturn(MACIP_ACL_NAME);
when(macipAclContext.getAclIndex(MACIP_ACL_NAME, mappingContext)).thenReturn(MACIP_ACL_INDEX);
when(macipAclContext.getAceName(MACIP_ACL_NAME, 0, mappingContext)).thenReturn(MACIP_ACE_NAME);
+ when(macipAclContext.containsAcl(MACIP_ACL_NAME, mappingContext)).thenReturn(true);
}
@Test
public void testGetAllIds() throws ReadFailedException {
- final List<AclKey> allIds = getCustomizer().getAllIds(InstanceIdentifier.create(AccessLists.class).child(Acl.class), ctx);
+ final List<AclKey> allIds =
+ getCustomizer().getAllIds(InstanceIdentifier.create(Acls.class).child(Acl.class), ctx);
assertEquals(2, allIds.size());
assertEquals(ACL_IID.getKey(), allIds.get(0));
assertEquals(MACIP_ACL_IID.getKey(), allIds.get(1));
@@ -122,14 +121,13 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
final AclBuilder builder = new AclBuilder();
getCustomizer().readCurrentAttributes(ACL_IID, builder, ctx);
assertEquals(ACL_IID.getKey(), builder.key());
- final List<Ace> aces = builder.getAccessListEntries().getAce();
+ final List<Ace> aces = builder.getAces().getAce();
assertEquals(1, aces.size());
final Ace ace = aces.get(0);
- assertEquals(ACE_NAME, ace.key().getRuleName());
- assertTrue(ace.getActions().getPacketHandling() instanceof Deny);
- final VppAceNodes nodes = ((VppAce) (ace.getMatches().getAceType())).getVppAceNodes();
- assertEquals(PROTOCOL, ((Other) nodes.getIpProtocol()).getOtherNodes().getProtocol().shortValue());
-
+ assertEquals(ACE_NAME, ace.key().getName());
+ assertTrue(ace.getActions().getForwarding().equals(Drop.class));
+ final L4 l4 = ((ace.getMatches())).getL4();
+ assertEquals(Icmp.class, l4.getImplementedInterface());
}
@Test
@@ -137,10 +135,10 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
final AclBuilder builder = new AclBuilder();
getCustomizer().readCurrentAttributes(MACIP_ACL_IID, builder, ctx);
assertEquals(MACIP_ACL_IID.getKey(), builder.key());
- final List<Ace> aces = builder.getAccessListEntries().getAce();
+ final List<Ace> aces = builder.getAces().getAce();
assertEquals(1, aces.size());
final Ace ace = aces.get(0);
- assertEquals(MACIP_ACE_NAME, ace.key().getRuleName());
- assertTrue(ace.getActions().getPacketHandling() instanceof Deny);
+ assertEquals(MACIP_ACE_NAME, ace.key().getName());
+ assertTrue(ace.getActions().getForwarding().equals(Drop.class));
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java
index 967b8200a..18f1978ef 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java
@@ -25,21 +25,23 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import javax.annotation.Nonnull;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Egress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.EgressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Egress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-public class EgressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
+public class EgressAclCustomizerTest extends AbstractAclCustomizerTest {
- public EgressVppAclCustomizerTest() {
- super(EgressBuilder.class);
+ public EgressAclCustomizerTest() {
+ super(AclSetsBuilder.class);
}
@Override
- protected EgressVppAclCustomizer initCustomizer() {
- return new EgressVppAclCustomizer(aclApi, interfaceContext, standardAclContext);
+ protected EgressAclCustomizer initCustomizer() {
+ return new EgressAclCustomizer(aclApi, interfaceContext, standardAclContext);
}
@Test
@@ -57,12 +59,12 @@ public class EgressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
}
@Override
- protected InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Egress.class).child(VppAcls.class);
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Egress.class).child(AclSets.class).child(AclSet.class);
}
- @Override
- protected InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key) {
- return getAclId(ifName).child(Egress.class).child(VppAcls.class, key);
+ protected KeyedInstanceIdentifier<AclSet, AclSetKey> getIid(@Nonnull final String ifName,
+ @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Egress.class).child(AclSets.class).child(AclSet.class, key);
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java
index 42a798e88..666f6d8c9 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java
@@ -16,31 +16,33 @@
package io.fd.hc2vpp.acl.read;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static io.fd.vpp.jvpp.Assertions.assertEquals;
+import static junit.framework.TestCase.assertTrue;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import javax.annotation.Nonnull;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Ingress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class IngressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
+public class IngressAclCustomizerTest extends AbstractAclCustomizerTest {
- public IngressVppAclCustomizerTest() {
- super(IngressBuilder.class);
+ public IngressAclCustomizerTest() {
+ super(AclSetsBuilder.class);
}
@Override
- protected IngressVppAclCustomizer initCustomizer() {
- return new IngressVppAclCustomizer(aclApi, interfaceContext, standardAclContext);
+ protected IngressAclCustomizer initCustomizer() {
+ return new IngressAclCustomizer(aclApi, interfaceContext, standardAclContext, macIpAclContext);
}
+
@Test
public void testGetAllIdsNoInputAclConfigured() throws ReadFailedException {
final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0, "acl1");
@@ -57,12 +59,12 @@ public class IngressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
}
@Override
- protected InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Ingress.class).child(VppAcls.class);
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class);
}
@Override
- protected InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key) {
- return getAclId(ifName).child(Ingress.class).child(VppAcls.class, key);
+ protected InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class, key);
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java
new file mode 100644
index 000000000..6678ab53a
--- /dev/null
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.acl.read;
+
+import static io.fd.hc2vpp.acl.read.IngressAclCustomizer.ACL_NOT_ASSIGNED;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.Initialized;
+import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDetails;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
+import javax.annotation.Nonnull;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Ingress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MacIpAclCustomizerTest extends AbstractAclCustomizerTest {
+
+ protected static final String IF_NAME_NO_ACL = "eth2";
+ protected static final int IF_ID_NO_ACL = 1;
+ protected static final String IFC_CTX_NAME = "interface-context";
+ private static final String IF_NAME = "eth1";
+ private static final int IF_ID = 1;
+ private static final String ACL_NAME = "acl-name";
+ private static final int ACL_ID = 1;
+ @Mock
+ protected FutureJVppAclFacade aclApi;
+ protected NamingContext interfaceContext = new NamingContext("iface", IFC_CTX_NAME);
+
+ public MacIpAclCustomizerTest() {
+ super(AclSetsBuilder.class);
+ }
+
+ @Override
+ protected IngressAclCustomizer initCustomizer() {
+ return new IngressAclCustomizer(aclApi, interfaceContext, standardAclContext, macIpAclContext);
+ }
+
+ @Override
+ protected void setUp() {
+ defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
+ when(macIpAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
+ when(macIpAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(false);
+ final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
+ when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1, "acl-name");
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ }
+
+
+ @Test
+ public void testRead() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ assignedAcls.count = 2;
+ assignedAcls.acls = new int[]{ACL_NOT_ASSIGNED, ACL_ID};
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+
+ final MacipAclDump request = new MacipAclDump();
+ request.aclIndex = ACL_ID;
+ final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
+ final MacipAclDetails details = new MacipAclDetails();
+ details.aclIndex = ACL_ID;
+ reply.macipAclDetails.add(details);
+ when(aclApi.macipAclDump(request)).thenReturn(future(reply));
+
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verify(builder).setName(ACL_NAME);
+ }
+
+ @Test
+ public void testReadNotAssigned() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ // pretending we have 3 interfaces, IF_NAME does not have MacipAcl assigned
+ assignedAcls.count = 3;
+ assignedAcls.acls = new int[]{ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED};
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+
+ final MacipAclDump request = new MacipAclDump();
+ request.aclIndex = ACL_ID;
+ final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
+ final MacipAclDetails details = new MacipAclDetails();
+ details.aclIndex = ACL_ID;
+ reply.macipAclDetails.add(details);
+ when(aclApi.macipAclDump(request)).thenReturn(future(reply));
+
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verifyZeroInteractions(builder);
+ }
+
+ @Test
+ public void testReadNoAcls() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ assignedAcls.count = 0;
+ assignedAcls.acls = new int[0];
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verifyZeroInteractions(builder);
+ }
+
+ @Test
+ public void testGetAllIdsNoAclConfigured() throws ReadFailedException {
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1);
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).isEmpty());
+ }
+
+ @Test
+ public void testReadAllTwoIfacesInOneTx() throws ReadFailedException {
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1);
+ final MacipAclInterfaceGetReply interfaceGet = macipAclInterfaceGetReply();
+ // read all for interface with defined ACLs:
+ assertFalse(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
+ // read all for interface without ACLs defined:
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(interfaceGet));
+ Assert.assertEquals(0, getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).size());
+ }
+
+ @Test
+ public void testInit() {
+ final AclSet readValue = new AclSetBuilder().build();
+ final Initialized<? extends DataObject>
+ cfgValue = getCustomizer().init(getWildcardedIid(IF_NAME), readValue, ctx);
+ assertEquals(cfgValue.getData(), readValue);
+ assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
+ assertEquals(cfgValue.getId().getTargetType(), AclSet.class);
+
+ }
+
+ @Override
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class);
+ }
+
+ @Override
+ protected InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class, key);
+ }
+} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java
deleted file mode 100644
index 23ce85640..000000000
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.acl.read;
-
-import static io.fd.hc2vpp.acl.read.VppMacIpAclCustomizer.ACL_NOT_ASSIGNED;
-import static io.fd.hc2vpp.acl.read.AbstractVppAclCustomizerTest.getAclId;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-import io.fd.hc2vpp.acl.util.AclContextManager;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.spi.read.Initialized;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDetails;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDetailsReplyDump;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDump;
-import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
-import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
-import javax.annotation.Nonnull;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AclBase;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAclBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class VppMacIpAclCustomizerTest extends InitializingReaderCustomizerTest<VppMacipAcl, VppMacipAclBuilder> {
-
- protected static final String IF_NAME_NO_ACL = "eth2";
- protected static final int IF_ID_NO_ACL = 2;
- protected static final String IFC_CTX_NAME = "interface-context";
- private static final String IF_NAME = "eth1";
- private static final int IF_ID = 1;
- private static final String ACL_NAME = "acl-name";
- private static final int ACL_ID = 1;
- private static final Class<? extends AclBase> ACL_TYPE =
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppMacipAcl.class;
- @Mock
- protected FutureJVppAclFacade aclApi;
- protected NamingContext interfaceContext = new NamingContext("iface", IFC_CTX_NAME);
- @Mock
- protected AclContextManager macIpAclContext;
-
- public VppMacIpAclCustomizerTest() {
- super(VppMacipAcl.class, IngressBuilder.class);
- }
-
- @Override
- protected VppMacIpAclCustomizer initCustomizer() {
- return new VppMacIpAclCustomizer(aclApi, interfaceContext, macIpAclContext);
- }
-
- @Override
- protected void setUp() {
- defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
- defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
- when(macIpAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
- }
-
- @Test
- public void testRead() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
-
- final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
- assignedAcls.count = 2;
- assignedAcls.acls = new int[] {ACL_NOT_ASSIGNED, ACL_ID};
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
-
- final MacipAclDump request = new MacipAclDump();
- request.aclIndex = ACL_ID;
- final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
- final MacipAclDetails details = new MacipAclDetails();
- details.aclIndex = ACL_ID;
- reply.macipAclDetails.add(details);
- when(aclApi.macipAclDump(request)).thenReturn(future(reply));
-
- getCustomizer().readCurrentAttributes(getIid(IF_NAME), builder, ctx);
- verify(builder).setName(ACL_NAME);
- verify(builder).setType(ACL_TYPE);
- }
-
- @Test
- public void testReadNotAssigned() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
-
- final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
- // pretending we have 3 interfaces, IF_NAME does not have MacipAcl assigned
- assignedAcls.count = 3;
- assignedAcls.acls = new int[] {ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED, ACL_ID};
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
-
- final MacipAclDump request = new MacipAclDump();
- request.aclIndex = ACL_ID;
- final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
- final MacipAclDetails details = new MacipAclDetails();
- details.aclIndex = ACL_ID;
- reply.macipAclDetails.add(details);
- when(aclApi.macipAclDump(request)).thenReturn(future(reply));
-
- getCustomizer().readCurrentAttributes(getIid(IF_NAME), builder, ctx);
- verifyZeroInteractions(builder);
- }
-
- @Test
- public void testReadNoAcls() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(new MacipAclInterfaceGetReply()));
- getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL), builder, ctx);
- verifyZeroInteractions(builder);
- }
-
- @Test
- public void testInit() {
- final VppMacipAcl readValue = new VppMacipAclBuilder().build();
- final Initialized<? extends DataObject> cfgValue = getCustomizer().init(getIid(IF_NAME), readValue, ctx);
- assertEquals(cfgValue.getData(), readValue);
- assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
- assertEquals(cfgValue.getId().getTargetType(), VppMacipAcl.class);
-
- }
-
- protected InstanceIdentifier<VppMacipAcl> getIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Ingress.class).child(VppMacipAcl.class);
- }
-
-} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractorTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractorTest.java
index ea01cedb6..5375ee429 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractorTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/MacIpAceDataExtractorTest.java
@@ -17,7 +17,6 @@
package io.fd.hc2vpp.acl.util.ace.extractor;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -25,114 +24,56 @@ import io.fd.hc2vpp.common.test.util.CommonTests;
import io.fd.vpp.jvpp.acl.types.MacipAclRule;
import java.util.Arrays;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.AceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.ActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.DenyBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.PermitBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppMacipAce;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppMacipAceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.VppMacipAceNodesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.vpp.macip.ace.nodes.AceIpVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.vpp.macip.ace.nodes.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.vpp.macip.ace.nodes.ace.ip.version.AceIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.vpp.macip.ace.nodes.ace.ip.version.AceIpv6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.macip.ace.vpp.macip.ace.nodes.ace.ip.version.AceIpv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Accept;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Drop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.AceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.ActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.L3;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.source.network.SourceIpv4Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.source.network.SourceIpv4NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.source.network.SourceIpv6Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.source.network.SourceIpv6NetworkBuilder;
public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implements MacIpAceDataExtractor, CommonTests {
@Test
- public void testFromMacIpAce() {
- verifyExceptionalCase(() -> fromMacIpAce(new AceBuilder().build()), IllegalArgumentException.class);
- verifyExceptionalCase(() -> fromMacIpAce(new AceBuilder().setMatches(new MatchesBuilder().build()).build()),
- IllegalArgumentException.class);
-
- final VppMacipAce macipAce = new VppMacipAceBuilder().build();
- assertEquals(macipAce, fromMacIpAce(new AceBuilder().setMatches(new MatchesBuilder()
- .setAceType(macipAce).build()).build()));
- }
-
- @Test
- public void testMacIpIsIpv6() {
- assertFalse(macIpIsIpv6(new VppMacipAceBuilder().build()));
- assertFalse(macIpIsIpv6(
- new VppMacipAceBuilder().setVppMacipAceNodes(new VppMacipAceNodesBuilder().build()).build()));
- assertFalse(macIpIsIpv6(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build()));
- assertTrue(macIpIsIpv6(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build()));
- }
-
- @Test
public void testSourceMacAsBytes() {
- assertTrue(Arrays.equals(DEFAULT_MAC_ADDRESS_BYTES, sourceMacAsBytes(new VppMacipAceBuilder().build())));
- assertTrue(
- Arrays.equals(DEFAULT_MAC_ADDRESS_BYTES, sourceMacAsBytes(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(MAC_ADDRESS_BYTES,
- sourceMacAsBytes(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setSourceMacAddress(MAC_ADDRESS).build())
- .build())));
+ assertTrue(Arrays.equals(MAC_ADDRESS_BYTES, sourceMacAsBytes(MAC_ADDRESS)));
}
@Test
public void sourceMacMaskAsBytes() {
- assertTrue(Arrays.equals(DEFAULT_MAC_ADDRESS_BYTES, sourceMacMaskAsBytes(new VppMacipAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_MAC_ADDRESS_BYTES,
- sourceMacMaskAsBytes(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(MAC_ADDRESS_BYTES,
- sourceMacMaskAsBytes(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setSourceMacAddressMask(MAC_ADDRESS).build())
- .build())));
+ assertTrue(Arrays.equals(MAC_ADDRESS_BYTES, sourceMacMaskAsBytes(MAC_ADDRESS)));
}
@Test
public void testIpv4Address() {
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4Address(new VppMacipAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4Address(
- new VppMacipAceBuilder().setVppMacipAceNodes(new VppMacipAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4Address(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV4_PREFIX_BYTES, ipv4Address(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setSourceIpv4Network(IPV4_PREFIX).build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4Address(new SourceIpv4NetworkBuilder().build())));
+ assertTrue(Arrays.equals(IPV4_PREFIX_BYTES,
+ ipv4Address(new SourceIpv4NetworkBuilder().setSourceIpv4Network(IPV4_PREFIX).build())));
}
@Test
public void testIpv4AddressPrefix() {
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4AddressPrefix(new VppMacipAceBuilder().build()));
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4AddressPrefix(
- new VppMacipAceBuilder().setVppMacipAceNodes(new VppMacipAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4AddressPrefix(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build()));
- assertEquals(IPV4_PREFIX_VALUE, ipv4AddressPrefix(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setSourceIpv4Network(IPV4_PREFIX).build()).build()).build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4AddressPrefix(new SourceIpv4NetworkBuilder().build()));
+ assertEquals(IPV4_PREFIX_VALUE,
+ ipv4AddressPrefix(new SourceIpv4NetworkBuilder().setSourceIpv4Network(IPV4_PREFIX).build()));
}
@Test
public void testIpv6Address() {
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6Address(new VppMacipAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6Address(
- new VppMacipAceBuilder().setVppMacipAceNodes(new VppMacipAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6Address(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV6_PREFIX_BYTES, ipv6Address(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setSourceIpv6Network(IPV6_PREFIX).build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6Address(new SourceIpv6NetworkBuilder().build())));
+ assertTrue(Arrays.equals(IPV6_PREFIX_BYTES,
+ ipv6Address(new SourceIpv6NetworkBuilder().setSourceIpv6Network(IPV6_PREFIX).build())));
}
@Test
public void testIpv6AddressPrefix() {
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6AddressPrefix(new VppMacipAceBuilder().build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6AddressPrefix(
- new VppMacipAceBuilder().setVppMacipAceNodes(new VppMacipAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6AddressPrefix(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build()));
- assertEquals(IPV6_PREFIX_VALUE, ipv6AddressPrefix(new VppMacipAceBuilder().setVppMacipAceNodes(
- new VppMacipAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setSourceIpv6Network(IPV6_PREFIX).build()).build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6AddressPrefix(new SourceIpv6NetworkBuilder().build()));
+ assertEquals(IPV6_PREFIX_VALUE,
+ ipv6AddressPrefix(new SourceIpv6NetworkBuilder().setSourceIpv6Network(IPV6_PREFIX).build()));
}
@Test
@@ -141,11 +82,10 @@ public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implemen
verifyExceptionalCase(() -> macIpAction(new AceBuilder().setActions(new ActionsBuilder().build()).build()),
IllegalArgumentException.class);
// this one must pass even if deny is not fully set, because of default value definition
- assertEquals((byte) 0, macIpAction(new AceBuilder().setActions(new ActionsBuilder().setPacketHandling(
- new DenyBuilder().build()).build()).build()));
-
- assertEquals((byte) 1, macIpAction(new AceBuilder().setActions(new ActionsBuilder().setPacketHandling(
- new PermitBuilder().setPermit(true).build()).build()).build()));
+ assertEquals((byte) 0, macIpAction(
+ new AceBuilder().setActions(new ActionsBuilder().setForwarding(Drop.class).build()).build()));
+ assertEquals((byte) 1, macIpAction(
+ new AceBuilder().setActions(new ActionsBuilder().setForwarding(Accept.class).build()).build()));
}
@Test
@@ -156,9 +96,10 @@ public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implemen
rule.srcIpAddr = IPV4_PREFIX_BYTES;
rule.srcIpPrefixLen = IPV4_PREFIX_VALUE;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv4);
- assertEquals(IPV4_PREFIX, AceIpv4.class.cast(result).getSourceIpv4Network());
+ final L3 result = parseMacIpAceL3(rule);
+ assertEquals(Ipv4.class, result.getImplementedInterface());
+ assertEquals(IPV4_PREFIX,
+ ((SourceIpv4Network) ((Ipv4) result).getIpv4().getSourceNetwork()).getSourceIpv4Network());
}
@Test
@@ -167,9 +108,9 @@ public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implemen
rule.isIpv6 = 0;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv4);
- assertNull(AceIpv4.class.cast(result).getSourceIpv4Network());
+ final L3 result = parseMacIpAceL3(rule);
+ assertEquals(Ipv4.class, result.getImplementedInterface());
+ assertNull(((Ipv4) result).getIpv4());
}
@Test
@@ -180,9 +121,10 @@ public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implemen
rule.srcIpAddr = IPV6_PREFIX_BYTES;
rule.srcIpPrefixLen = IPV6_PREFIX_VALUE;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv6);
- assertEquals(IPV6_PREFIX, AceIpv6.class.cast(result).getSourceIpv6Network());
+ final L3 result = parseMacIpAceL3(rule);
+ assertEquals(Ipv6.class, result.getImplementedInterface());
+ assertEquals(IPV6_PREFIX, ((SourceIpv6Network) ((Ipv6) result).getIpv6().getSourceNetwork())
+ .getSourceIpv6Network());
}
@Test
@@ -191,9 +133,9 @@ public class MacIpAceDataExtractorTest extends AceDataExtractorTestCase implemen
rule.isIpv6 = 1;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv6);
- assertNull(AceIpv6.class.cast(result).getSourceIpv6Network());
+ final L3 result = parseMacIpAceL3(rule);
+ assertEquals(Ipv6.class, result.getImplementedInterface());
+ assertNull(((Ipv6) result).getIpv6());
}
@Test
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/StandardAceDataExtractorTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/StandardAceDataExtractorTest.java
index f22d6600a..627dba6b0 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/StandardAceDataExtractorTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/ace/extractor/StandardAceDataExtractorTest.java
@@ -25,159 +25,212 @@ import io.fd.hc2vpp.common.test.util.CommonTests;
import io.fd.vpp.jvpp.acl.types.AclRule;
import java.util.Arrays;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.AceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.ActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.MatchesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.Deny;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.DenyBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.Permit;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.actions.packet.handling.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.actions.packet.handling.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAce;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.VppAceNodesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.vpp.ace.nodes.AceIpVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.vpp.ace.nodes.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.vpp.ace.nodes.ace.ip.version.AceIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.vpp.ace.nodes.ace.ip.version.AceIpv6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.vpp.ace.nodes.ace.ip.version.AceIpv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.IcmpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.IcmpV6Builder;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.acl.rev181022.AcceptAndReflect;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Accept;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Drop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.AceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.ActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.MatchesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.L3;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.destination.network.DestinationIpv4Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.destination.network.DestinationIpv4NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.source.network.SourceIpv4Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv4.header.fields.source.network.SourceIpv4NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.destination.network.DestinationIpv6Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.destination.network.DestinationIpv6NetworkBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.source.network.SourceIpv6Network;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.acl.ipv6.header.fields.source.network.SourceIpv6NetworkBuilder;
public class StandardAceDataExtractorTest extends AceDataExtractorTestCase implements StandardAceDataExtractor,
CommonTests {
@Test
- public void testFromStandardAce() {
- verifyExceptionalCase(() -> fromStandardAce(new AceBuilder().build()), IllegalArgumentException.class);
- verifyExceptionalCase(() -> fromStandardAce(new AceBuilder().setMatches(new MatchesBuilder().build()).build()),
- IllegalArgumentException.class);
-
- final VppAce ace = new VppAceBuilder().build();
- assertEquals(ace, fromStandardAce(new AceBuilder().setMatches(new MatchesBuilder()
- .setAceType(ace).build()).build()));
- }
-
- @Test
public void testStandardIsIpv6WithoutMatch() {
- assertFalse(standardIsIpv6(new VppAceBuilder().build(), null));
- assertFalse(standardIsIpv6(new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build(), null));
- assertFalse(standardIsIpv6(new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder()
- .setIpProtocol(new IcmpBuilder().build()).build()).build(), null));
- assertTrue(standardIsIpv6(new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder()
- .setIpProtocol(new IcmpV6Builder().build()).build()).build(), null));
- }
-
- @Test
- public void testStandardIsIpv6WithMatch() {
- final VppAce ipv6Ace = new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder()
- .setIpProtocol(new IcmpV6Builder().build()).build()).build();
-
- assertTrue(standardIsIpv6(ipv6Ace, new MatchesBuilder().build()));
- assertTrue(standardIsIpv6(ipv6Ace, new MatchesBuilder().setAceType(new VppAceBuilder().build()).build()));
- assertTrue(standardIsIpv6(ipv6Ace, new MatchesBuilder().setAceType(new VppAceBuilder()
- .setVppAceNodes(new VppAceNodesBuilder().build())
- .build()).build()));
- assertFalse(standardIsIpv6(ipv6Ace, new MatchesBuilder().setAceType(new VppAceBuilder()
- .setVppAceNodes(new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build())
- .build()).build()));
+ assertFalse(standardIsIpv6(null));
+ assertFalse(standardIsIpv6(new MatchesBuilder().build()));
+ assertFalse(standardIsIpv6(new MatchesBuilder().setL3(new Ipv6Builder().build()).build()));
+ assertTrue(standardIsIpv6(new MatchesBuilder().setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .build()).build()).build()));
}
@Test
public void testIpv4SourceAddress() {
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(new VppAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV4_PREFIX_BYTES, ipv4SourceAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setSourceIpv4Network(IPV4_PREFIX).build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(new MatchesBuilder().build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES,
+ ipv4SourceAddress(new MatchesBuilder().setL3(new Ipv4Builder().build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4SourceAddress(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setSourceNetwork(new SourceIpv4NetworkBuilder().build()).build()).build()).build())));
+ assertTrue(Arrays.equals(IPV4_PREFIX_BYTES, ipv4SourceAddress(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setSourceNetwork(
+ new SourceIpv4NetworkBuilder().setSourceIpv4Network(IPV4_PREFIX).build())
+ .build()).build()).build())));
}
@Test
public void testIpv4SourceAddressPrefix() {
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new VppAceBuilder().build()));
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build()));
- assertEquals(IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setSourceIpv4Network(IPV4_PREFIX).build()).build()).build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new MatchesBuilder().build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE,
+ ipv4SourceAddressPrefix(new MatchesBuilder().setL3(new Ipv4Builder().build()).build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .build()).build()).build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setSourceNetwork(new SourceIpv4NetworkBuilder().build()).build()).build()).build()));
+ assertEquals(IPV4_PREFIX_VALUE, ipv4SourceAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setSourceNetwork(
+ new SourceIpv4NetworkBuilder().setSourceIpv4Network(IPV4_PREFIX).build())
+ .build()).build()).build()));
}
@Test
public void testIpv4DestinationAddress() {
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(new VppAceBuilder().build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(new MatchesBuilder().build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(
+ new MatchesBuilder().setL3(new Ipv4Builder().build()).build())));
assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV4_PREFIX_BYTES, ipv4DestinationAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setDestinationIpv4Network(IPV4_PREFIX).build()).build()).build())));
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV4_ADDRESS_BYTES, ipv4DestinationAddress(
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setDestinationNetwork(new DestinationIpv4NetworkBuilder()
+ .build()).build()).build()).build())));
+ assertTrue(Arrays.equals(IPV4_PREFIX_BYTES, ipv4DestinationAddress(
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setDestinationNetwork(
+ new DestinationIpv4NetworkBuilder().setDestinationIpv4Network(IPV4_PREFIX)
+ .build()).build()).build()).build())));
}
@Test
public void testIpv4DestinationAddressPrefix() {
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(new VppAceBuilder().build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(new MatchesBuilder().build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(
+ new MatchesBuilder().setL3(new Ipv4Builder().build()).build()));
assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder().build()).build()).build()));
- assertEquals(IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv4Builder()
- .setDestinationIpv4Network(IPV4_PREFIX).build()).build()).build()));
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .build()).build()).build()));
+ assertEquals(DEFAULT_IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setDestinationNetwork(new DestinationIpv4NetworkBuilder()
+ .build()).build()).build()).build()));
+ assertEquals(IPV4_PREFIX_VALUE, ipv4DestinationAddressPrefix(
+ new MatchesBuilder().setL3(new Ipv4Builder().setIpv4(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv4.Ipv4Builder()
+ .setDestinationNetwork(
+ new DestinationIpv4NetworkBuilder().setDestinationIpv4Network(IPV4_PREFIX)
+ .build()).build()).build()).build()));
}
@Test
public void testIpv6SourceAddress() {
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(new VppAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV6_PREFIX_BYTES, ipv6SourceAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setSourceIpv6Network(IPV6_PREFIX).build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(new MatchesBuilder().build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES,
+ ipv6SourceAddress(new MatchesBuilder().setL3(new Ipv6Builder().build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6SourceAddress(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setSourceNetwork(new SourceIpv6NetworkBuilder().build()).build()).build()).build())));
+ assertTrue(Arrays.equals(IPV6_PREFIX_BYTES, ipv6SourceAddress(new MatchesBuilder().setL3(new Ipv6Builder()
+ .setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setSourceNetwork(
+ new SourceIpv6NetworkBuilder().setSourceIpv6Network(IPV6_PREFIX).build())
+ .build()).build()).build())));
}
@Test
public void ipv6SourceAddressPrefix() {
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new VppAceBuilder().build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build()));
- assertEquals(IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setSourceIpv6Network(IPV6_PREFIX).build()).build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new MatchesBuilder().build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE,
+ ipv6SourceAddressPrefix(new MatchesBuilder().setL3(new Ipv6Builder().build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .build()).build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setSourceNetwork(new SourceIpv6NetworkBuilder().build()).build()).build()).build()));
+ assertEquals(IPV6_PREFIX_VALUE, ipv6SourceAddressPrefix(new MatchesBuilder().setL3(new Ipv6Builder()
+ .setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setSourceNetwork(
+ new SourceIpv6NetworkBuilder().setSourceIpv6Network(IPV6_PREFIX).build())
+ .build()).build()).build()));
}
@Test
public void ipv6DestinationAddress() {
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(new VppAceBuilder().build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build())));
- assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build())));
- assertTrue(Arrays.equals(IPV6_PREFIX_BYTES, ipv6DestinationAddress(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setDestinationIpv6Network(IPV6_PREFIX).build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(new MatchesBuilder().build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES,
+ ipv6DestinationAddress(new MatchesBuilder().setL3(new Ipv6Builder().build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .build()).build()).build())));
+ assertTrue(Arrays.equals(DEFAULT_IPV6_ADDRESS_BYTES, ipv6DestinationAddress(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setDestinationNetwork(new DestinationIpv6NetworkBuilder().build()).build()).build())
+ .build())));
+ assertTrue(Arrays.equals(IPV6_PREFIX_BYTES, ipv6DestinationAddress(new MatchesBuilder().setL3(new Ipv6Builder()
+ .setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setDestinationNetwork(
+ new DestinationIpv6NetworkBuilder().setDestinationIpv6Network(IPV6_PREFIX)
+ .build())
+ .build()).build()).build())));
}
@Test
public void ipv6DestinationAddressPrefix() {
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new VppAceBuilder().build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(
- new VppAceBuilder().setVppAceNodes(new VppAceNodesBuilder().build()).build()));
- assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder().build()).build()).build()));
- assertEquals(IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new VppAceBuilder().setVppAceNodes(
- new VppAceNodesBuilder().setAceIpVersion(new AceIpv6Builder()
- .setDestinationIpv6Network(IPV6_PREFIX).build()).build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new MatchesBuilder().build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE,
+ ipv6DestinationAddressPrefix(new MatchesBuilder().setL3(new Ipv6Builder().build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .build()).build()).build()));
+ assertEquals(DEFAULT_IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new MatchesBuilder()
+ .setL3(new Ipv6Builder().setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setDestinationNetwork(new DestinationIpv6NetworkBuilder().build()).build()).build())
+ .build()));
+ assertEquals(IPV6_PREFIX_VALUE, ipv6DestinationAddressPrefix(new MatchesBuilder().setL3(new Ipv6Builder()
+ .setIpv6(
+ new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l3.ipv6.Ipv6Builder()
+ .setDestinationNetwork(
+ new DestinationIpv6NetworkBuilder().setDestinationIpv6Network(IPV6_PREFIX)
+ .build())
+ .build()).build()).build()));
}
@Test
@@ -188,12 +241,10 @@ public class StandardAceDataExtractorTest extends AceDataExtractorTestCase imple
// this one should pass because of default value
assertEquals(0, standardAction(
- new AceBuilder().setActions(new ActionsBuilder().setPacketHandling(new DenyBuilder().build()).build())
- .build()));
+ new AceBuilder().setActions(new ActionsBuilder().setForwarding(Drop.class).build()).build()));
assertEquals(2, standardAction(new AceBuilder().setActions(
- new ActionsBuilder().setPacketHandling(new StatefulBuilder().setPermitAndReflect(true).build()).build())
- .build()));
+ new ActionsBuilder().setForwarding(AcceptAndReflect.class).build()).build()));
}
@Test
@@ -206,10 +257,13 @@ public class StandardAceDataExtractorTest extends AceDataExtractorTestCase imple
rule.dstIpAddr = IPV4_2_PREFIX_BYTES;
rule.dstIpPrefixLen = IPV4_2_PREFIX_VALUE;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv4);
- assertEquals(IPV4_PREFIX, AceIpv4.class.cast(result).getSourceIpv4Network());
- assertEquals(IPV4_2_PREFIX, AceIpv4.class.cast(result).getDestinationIpv4Network());
+ final L3 result = parseStandardAceL3(rule);
+ assertEquals(result.getImplementedInterface(), Ipv4.class);
+ assertEquals(IPV4_PREFIX,
+ ((SourceIpv4Network) ((Ipv4) result).getIpv4().getSourceNetwork()).getSourceIpv4Network());
+ assertEquals(IPV4_2_PREFIX,
+ ((DestinationIpv4Network) ((Ipv4) result).getIpv4().getDestinationNetwork())
+ .getDestinationIpv4Network());
}
@Test
@@ -218,10 +272,10 @@ public class StandardAceDataExtractorTest extends AceDataExtractorTestCase imple
rule.isIpv6 = 0;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv4);
- assertNull(AceIpv4.class.cast(result).getSourceIpv4Network());
- assertNull(AceIpv4.class.cast(result).getDestinationIpv4Network());
+ final L3 result = parseStandardAceL3(rule);
+ assertEquals(result.getImplementedInterface(), Ipv4.class);
+ assertNull(((Ipv4) result).getIpv4().getSourceNetwork());
+ assertNull(((Ipv4) result).getIpv4().getDestinationNetwork());
}
@Test
@@ -234,10 +288,13 @@ public class StandardAceDataExtractorTest extends AceDataExtractorTestCase imple
rule.dstIpAddr = IPV6_2_PREFIX_BYTES;
rule.dstIpPrefixLen = IPV6_2_PREFIX_VALUE;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv6);
- assertEquals(IPV6_PREFIX, AceIpv6.class.cast(result).getSourceIpv6Network());
- assertEquals(IPV6_2_PREFIX, AceIpv6.class.cast(result).getDestinationIpv6Network());
+ final L3 result = parseStandardAceL3(rule);
+ assertEquals(result.getImplementedInterface(), Ipv6.class);
+ assertEquals(IPV6_PREFIX,
+ ((SourceIpv6Network) ((Ipv6) result).getIpv6().getSourceNetwork()).getSourceIpv6Network());
+ assertEquals(IPV6_2_PREFIX,
+ ((DestinationIpv6Network) ((Ipv6) result).getIpv6().getDestinationNetwork())
+ .getDestinationIpv6Network());
}
@Test
@@ -246,19 +303,17 @@ public class StandardAceDataExtractorTest extends AceDataExtractorTestCase imple
rule.isIpv6 = 1;
- final AceIpVersion result = ipVersion(rule);
- assertTrue(result instanceof AceIpv6);
- assertNull(AceIpv6.class.cast(result).getSourceIpv6Network());
- assertNull(AceIpv6.class.cast(result).getDestinationIpv6Network());
+ final L3 result = parseStandardAceL3(rule);
+ assertEquals(result.getImplementedInterface(), Ipv6.class);
+ assertNull((((Ipv6) result).getIpv6().getSourceNetwork()));
+ assertNull((((Ipv6) result).getIpv6().getDestinationNetwork()));
}
@Test
public void testActions() {
verifyExceptionalCase(() -> actions((byte) -1), IllegalArgumentException.class);
- assertTrue(actions((byte) 0).getPacketHandling() instanceof Deny);
- assertTrue(actions((byte) 1).getPacketHandling() instanceof Permit);
- assertTrue(actions((byte) 2).getPacketHandling() instanceof Stateful);
+ assertTrue(actions((byte) 0).getForwarding().equals(Drop.class));
+ assertTrue(actions((byte) 1).getForwarding().equals(Accept.class));
}
-
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java
index fb5d61458..1b7cf8c32 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/acl/AclInterfaceAssignmentRequestTest.java
@@ -16,19 +16,20 @@
package io.fd.hc2vpp.acl.util.iface.acl;
-import static io.fd.hc2vpp.acl.util.iface.acl.AclInterfaceAssignmentRequest.create;
+import static io.fd.hc2vpp.acl.write.request.AclInterfaceAssignmentRequest.create;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.collect.ImmutableList;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.util.AclContextManager;
+import io.fd.hc2vpp.acl.write.request.AclInterfaceAssignmentRequest;
import io.fd.hc2vpp.common.test.util.FutureProducer;
import io.fd.hc2vpp.common.test.util.NamingContextHelper;
import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -43,11 +44,8 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class AclInterfaceAssignmentRequestTest implements NamingContextHelper, FutureProducer {
@@ -76,7 +74,7 @@ public class AclInterfaceAssignmentRequestTest implements NamingContextHelper, F
@Mock
private MappingContext mappingContext;
- private InstanceIdentifier<Acl> validIdentifier;
+ private InstanceIdentifier<Interface> validIdentifier;
private NamingContext interfaceContext;
@Mock
@@ -86,10 +84,8 @@ public class AclInterfaceAssignmentRequestTest implements NamingContextHelper, F
public void setUp() {
initMocks(this);
- validIdentifier = InstanceIdentifier.create(Interfaces.class).
- child(Interface.class, new InterfaceKey(INTERFACE_NAME))
- .augmentation(VppAclInterfaceAugmentation.class)
- .child(Acl.class);
+ validIdentifier = AclIIds.ACLS_AP
+ .child(Interface.class, new InterfaceKey(INTERFACE_NAME));
interfaceContext = new NamingContext("iface", "interface-context");
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/macip/MacIpInterfaceAssignmentRequestTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/macip/MacIpInterfaceAssignmentRequestTest.java
index a7049b77f..145eec38e 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/macip/MacIpInterfaceAssignmentRequestTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/iface/macip/MacIpInterfaceAssignmentRequestTest.java
@@ -16,8 +16,8 @@
package io.fd.hc2vpp.acl.util.iface.macip;
-import static io.fd.hc2vpp.acl.util.iface.macip.MacIpInterfaceAssignmentRequest.addNew;
-import static io.fd.hc2vpp.acl.util.iface.macip.MacIpInterfaceAssignmentRequest.deleteExisting;
+import static io.fd.hc2vpp.acl.write.request.MacIpInterfaceAssignmentRequest.addNew;
+import static io.fd.hc2vpp.acl.write.request.MacIpInterfaceAssignmentRequest.deleteExisting;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
@@ -27,7 +27,9 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.util.AclContextManager;
+import io.fd.hc2vpp.acl.write.request.MacIpInterfaceAssignmentRequest;
import io.fd.hc2vpp.common.test.util.FutureProducer;
import io.fd.hc2vpp.common.test.util.NamingContextHelper;
import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -41,13 +43,8 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MacIpInterfaceAssignmentRequestTest implements NamingContextHelper,FutureProducer {
@@ -66,7 +63,7 @@ public class MacIpInterfaceAssignmentRequestTest implements NamingContextHelper,
@Mock
private MappingContext mappingContext;
- private InstanceIdentifier<VppMacipAcl> validIdentifier;
+ private InstanceIdentifier<Interface> validIdentifier;
private NamingContext interfaceContext;
@Mock
private AclContextManager macIpAclContext;
@@ -75,12 +72,7 @@ public class MacIpInterfaceAssignmentRequestTest implements NamingContextHelper,
public void setUp() throws Exception {
initMocks(this);
- validIdentifier = InstanceIdentifier.create(Interfaces.class).
- child(Interface.class, new InterfaceKey(INTERFACE_NAME))
- .augmentation(VppAclInterfaceAugmentation.class)
- .child(Acl.class)
- .child(Ingress.class)
- .child(VppMacipAcl.class);
+ validIdentifier = AclIIds.ACLS_AP.child(Interface.class, new InterfaceKey(INTERFACE_NAME));
interfaceContext = new NamingContext("iface", "interface-context");
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtocolParsingTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtocolParsingTest.java
index 08fe6f38b..170080b66 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtocolParsingTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/util/protocol/ProtocolParsingTest.java
@@ -24,41 +24,44 @@ import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.vpp.jvpp.acl.types.AclRule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAce;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Icmp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.IcmpV6;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Other;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Tcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Udp;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.acl.rev181022.VppIcmpAceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Acls;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.Icmp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.Tcp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.Udp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.tcp.tcp.source.port.source.port.RangeOrOperator;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev181001.port.range.or.operator.port.range.or.operator.Range;
@RunWith(HoneycombTestRunner.class)
public class ProtocolParsingTest implements ProtoPreBindRuleProducer, IpProtocolReader, AclTestSchemaContext {
private static final byte IGNORE_PROTOCOL = 0;
- //TODO - remove after resolving how to address identity from different model in textual yang instance identifier
- private VppAce extractAce(AccessLists accessLists) {
- return VppAce.class
- .cast(accessLists.getAcl().get(0).getAccessListEntries().getAce().get(0).getMatches().getAceType());
+ private Ace extractAce(Acls acls) {
+ return acls.getAcl().get(0).getAces().getAce().get(0);
}
@Test
- public void testIcmpRule(@InjectTestData(resourcePath = "/rules/icmp-rule.json") AccessLists acls) {
+ public void testIcmpRule(@InjectTestData(resourcePath = "/rules/icmp-rule.json") Acls acls) {
final AclRule icmpRule = createPreBindRule(extractAce(acls));
assertEquals(1, icmpRule.proto);
assertEquals(0, icmpRule.tcpFlagsMask);
assertEquals(0, icmpRule.tcpFlagsValue);
- final Icmp protocol = (Icmp)parseProtocol(icmpRule);
- assertEquals(5, protocol.getIcmpNodes().getIcmpTypeRange().getFirst().shortValue());
- assertEquals(8, protocol.getIcmpNodes().getIcmpTypeRange().getLast().shortValue());
- assertEquals(1, protocol.getIcmpNodes().getIcmpCodeRange().getFirst().shortValue());
- assertEquals(3, protocol.getIcmpNodes().getIcmpCodeRange().getLast().shortValue());
+ final Icmp protocol = (Icmp) parseProtocol(icmpRule);
+ assertEquals(5, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpTypeRange()
+ .getFirst().shortValue());
+ assertEquals(8, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpTypeRange()
+ .getLast().shortValue());
+ assertEquals(1, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpCodeRange()
+ .getFirst().shortValue());
+ assertEquals(3, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpCodeRange()
+ .getLast().shortValue());
}
@Test
- public void testIcmpv6Rule(@InjectTestData(resourcePath = "/rules/icmp-v6-rule.json") AccessLists acls) {
+ public void testIcmpv6Rule(@InjectTestData(resourcePath = "/rules/icmp-v6-rule.json") Acls acls) {
final AclRule icmpv6Rule = createPreBindRule(extractAce(acls));
assertEquals(58, icmpv6Rule.proto);
@@ -69,43 +72,67 @@ public class ProtocolParsingTest implements ProtoPreBindRuleProducer, IpProtocol
assertEquals(0, icmpv6Rule.tcpFlagsMask);
assertEquals(0, icmpv6Rule.tcpFlagsValue);
- final IcmpV6 protocol = (IcmpV6)parseProtocol(icmpv6Rule);
- assertEquals(5, protocol.getIcmpV6Nodes().getIcmpTypeRange().getFirst().shortValue());
- assertEquals(8, protocol.getIcmpV6Nodes().getIcmpTypeRange().getLast().shortValue());
- assertEquals(1, protocol.getIcmpV6Nodes().getIcmpCodeRange().getFirst().shortValue());
- assertEquals(3, protocol.getIcmpV6Nodes().getIcmpCodeRange().getLast().shortValue());
+ final Icmp protocol = (Icmp) parseProtocol(icmpv6Rule);
+ assertEquals(5, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpTypeRange()
+ .getFirst().shortValue());
+ assertEquals(8, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpTypeRange()
+ .getLast().shortValue());
+ assertEquals(1, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpCodeRange()
+ .getFirst().shortValue());
+ assertEquals(3, protocol.getIcmp().augmentation(VppIcmpAceAugmentation.class).getVppIcmpAce().getIcmpCodeRange()
+ .getLast().shortValue());
}
@Test
- public void testTcpRule(@InjectTestData(resourcePath = "/rules/tcp-rule.json") AccessLists acls) {
+ public void testTcpRule(@InjectTestData(resourcePath = "/rules/tcp-rule.json") Acls acls) {
final AclRule tcpRule = createPreBindRule(extractAce(acls));
assertEquals(6, tcpRule.proto);
assertEquals(1, tcpRule.tcpFlagsMask);
assertEquals(7, tcpRule.tcpFlagsValue);
- final Tcp protocol = (Tcp)parseProtocol(tcpRule);
- assertEquals(1, protocol.getTcpNodes().getSourcePortRange().getLowerPort().getValue().intValue());
- assertEquals(5487, protocol.getTcpNodes().getSourcePortRange().getUpperPort().getValue().intValue());
- assertEquals(87, protocol.getTcpNodes().getDestinationPortRange().getLowerPort().getValue().intValue());
- assertEquals(6745, protocol.getTcpNodes().getDestinationPortRange().getUpperPort().getValue().intValue());
+ final Tcp protocol = (Tcp) parseProtocol(tcpRule);
+ assertEquals(1,
+ ((Range) ((RangeOrOperator) protocol.getTcp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getLowerPort().getValue().intValue());
+ assertEquals(5487,
+ ((Range) ((RangeOrOperator) protocol.getTcp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getUpperPort().getValue().intValue());
+ assertEquals(87,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.tcp.tcp.destination.port.destination.port.RangeOrOperator) protocol
+ .getTcp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getLowerPort().getValue().intValue());
+ assertEquals(6745,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.tcp.tcp.destination.port.destination.port.RangeOrOperator) protocol
+ .getTcp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getUpperPort().getValue().intValue());
}
@Test
- public void testTcpRuleNoFlags(@InjectTestData(resourcePath = "/rules/tcp-rule-no-flags.json") AccessLists acls) {
+ public void testTcpRuleNoFlags(@InjectTestData(resourcePath = "/rules/tcp-rule-no-flags.json") Acls 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((short) 65000, tcpRule.dstportOrIcmpcodeFirst);
+ assertEquals((short) 65000, tcpRule.dstportOrIcmpcodeLast);
assertEquals(0, tcpRule.tcpFlagsMask);
assertEquals(0, tcpRule.tcpFlagsValue);
- final Tcp protocol = (Tcp)parseProtocol(tcpRule);
- assertEquals(123, protocol.getTcpNodes().getSourcePortRange().getLowerPort().getValue().intValue());
- assertEquals(123, protocol.getTcpNodes().getSourcePortRange().getUpperPort().getValue().intValue());
- assertEquals(65000, protocol.getTcpNodes().getDestinationPortRange().getLowerPort().getValue().intValue());
- assertEquals(65000, protocol.getTcpNodes().getDestinationPortRange().getUpperPort().getValue().intValue());
+ final Tcp protocol = (Tcp) parseProtocol(tcpRule);
+ assertEquals(123,
+ ((Range) ((RangeOrOperator) protocol.getTcp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getLowerPort().getValue().intValue());
+ assertEquals(123,
+ ((Range) ((RangeOrOperator) protocol.getTcp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getUpperPort().getValue().intValue());
+ assertEquals(65000,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.tcp.tcp.destination.port.destination.port.RangeOrOperator) protocol
+ .getTcp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getLowerPort().getValue().intValue());
+ assertEquals(65000,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.tcp.tcp.destination.port.destination.port.RangeOrOperator) protocol
+ .getTcp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getUpperPort().getValue().intValue());
}
@Test
@@ -125,40 +152,36 @@ public class ProtocolParsingTest implements ProtoPreBindRuleProducer, IpProtocol
}
@Test
- public void testUdpRule(@InjectTestData(resourcePath = "/rules/udp-rule.json") AccessLists acls) {
+ public void testUdpRule(@InjectTestData(resourcePath = "/rules/udp-rule.json") Acls acls) {
final AclRule udpRule = createPreBindRule(extractAce(acls));
assertEquals(17, udpRule.proto);
assertEquals(0, udpRule.tcpFlagsMask);
assertEquals(0, udpRule.tcpFlagsValue);
- final Udp protocol = (Udp)parseProtocol(udpRule);
- assertEquals(1, protocol.getUdpNodes().getSourcePortRange().getLowerPort().getValue().intValue());
- assertEquals(5487, protocol.getUdpNodes().getSourcePortRange().getUpperPort().getValue().intValue());
- assertEquals(87, protocol.getUdpNodes().getDestinationPortRange().getLowerPort().getValue().intValue());
- assertEquals(6745, protocol.getUdpNodes().getDestinationPortRange().getUpperPort().getValue().intValue());
+ final Udp protocol = (Udp) parseProtocol(udpRule);
+ assertEquals(1,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.udp.udp.source.port.source.port.RangeOrOperator) protocol
+ .getUdp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getLowerPort().getValue().intValue());
+ assertEquals(5487,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.udp.udp.source.port.source.port.RangeOrOperator) protocol
+ .getUdp().getSourcePort().getSourcePort()).getPortRangeOrOperator())
+ .getUpperPort().getValue().intValue());
+ assertEquals(87,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.udp.udp.destination.port.destination.port.RangeOrOperator) protocol
+ .getUdp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getLowerPort().getValue().intValue());
+ assertEquals(6745,
+ ((Range) ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.udp.udp.destination.port.destination.port.RangeOrOperator) protocol
+ .getUdp().getDestinationPort().getDestinationPort())
+ .getPortRangeOrOperator()).getUpperPort().getValue().intValue());
}
- @Test
- public void testOtherRule(@InjectTestData(resourcePath = "/rules/other-rule.json") AccessLists acls) {
- final AclRule rule = createPreBindRule(extractAce(acls));
- final int protocolNumber = 64;
- assertEquals(protocolNumber, rule.proto);
- assertEquals(0, rule.srcportOrIcmptypeFirst);
- assertEquals((short) 65535, rule.srcportOrIcmptypeLast);
- assertEquals(0, rule.dstportOrIcmpcodeFirst);
- assertEquals((short) 65535, rule.dstportOrIcmpcodeLast);
- assertEquals(0, rule.tcpFlagsMask);
- assertEquals(0, rule.tcpFlagsValue);
-
- final Other protocol = (Other)parseProtocol(rule);
- assertEquals(protocolNumber, protocol.getOtherNodes().getProtocol().shortValue());
- }
@Test
- public void tesProtocolNotSpecified(@InjectTestData(resourcePath = "/rules/no-protocol-rule.json") AccessLists acls) {
+ public void tesProtocolNotSpecified(@InjectTestData(resourcePath = "/rules/no-protocol-rule.json") Acls acls) {
final AclRule noProtocolRule = createPreBindRule(extractAce(acls));
assertEquals(IGNORE_PROTOCOL, noProtocolRule.proto);
}
-
} \ No newline at end of file
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/AclCustomizerTest.java
index a3fa6db0e..ae7023059 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/AclCustomizerTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.AclTestSchemaContext;
import io.fd.hc2vpp.acl.util.AclContextManager;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
@@ -46,15 +47,14 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Acls;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@RunWith(HoneycombTestRunner.class)
-public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTestSchemaContext {
+public class AclCustomizerTest extends WriterCustomizerTest implements AclTestSchemaContext {
@Mock
private FutureJVppAclFacade aclApi;
@@ -70,7 +70,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
private InstanceIdentifier<Acl> validId;
private InstanceIdentifier<Acl> validMacipId;
- private VppAclCustomizer aclCustomizer;
+ private AclCustomizer aclCustomizer;
@Mock
private AclContextManager standardAclContext;
@@ -80,11 +80,9 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Override
protected void setUpTest() throws Exception {
- validId =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey("standard-acl", VppAcl.class));
- validMacipId =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey("macip-acl", VppAcl.class));
- aclCustomizer = new VppAclCustomizer(aclApi, standardAclContext, macIpAclContext);
+ validId = AclIIds.ACLS.child(Acl.class, new AclKey("standard-acl"));
+ validMacipId = AclIIds.ACLS.child(Acl.class, new AclKey("macip-acl"));
+ aclCustomizer = new AclCustomizer(aclApi, standardAclContext, macIpAclContext);
when(aclApi.aclAddReplace(any())).thenReturn(future(new AclAddReplaceReply()));
when(aclApi.aclDel(any())).thenReturn(future(new AclDelReply()));
@@ -93,7 +91,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void writeCurrentAttributesMacip(@InjectTestData(resourcePath = "/acl/macip/macip-acl.json")
- AccessLists macipAcl) throws WriteFailedException {
+ Acls macipAcl) throws WriteFailedException {
aclCustomizer.writeCurrentAttributes(validMacipId, macipAcl.getAcl().get(0), writeContext);
@@ -116,7 +114,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void writeCurrentAttributesIcmpIpv4(@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
aclCustomizer.writeCurrentAttributes(validId, standardAcls.getAcl().get(0), writeContext);
verify(aclApi, times(1)).aclAddReplace(aclAddReplaceRequestCaptor.capture());
@@ -125,7 +123,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void updateCurrentAttributesIcmpIpv4(@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -139,7 +137,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void writeCurrentAttributesIcmpIpv6(@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp-v6.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
aclCustomizer.writeCurrentAttributes(validId, standardAcls.getAcl().get(0), writeContext);
verify(aclApi, times(1)).aclAddReplace(aclAddReplaceRequestCaptor.capture());
@@ -149,7 +147,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void updateCurrentAttributesIcmpIpv6(
@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp-v6.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -162,7 +160,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void writeCurrentAttributesTcp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
aclCustomizer.writeCurrentAttributes(validId, standardAcls.getAcl().get(0), writeContext);
verify(aclApi, times(1)).aclAddReplace(aclAddReplaceRequestCaptor.capture());
@@ -171,7 +169,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void updateCurrentAttributesTcp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -182,8 +180,9 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
}
@Test
- public void updateCurrentAttributesTcpSrcOnly(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp-src-only.json")
- AccessLists standardAcls) throws Exception {
+ public void updateCurrentAttributesTcpSrcOnly(
+ @InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp-src-only.json")
+ Acls standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -201,7 +200,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void writeCurrentAttributesUdp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
aclCustomizer.writeCurrentAttributes(validId, standardAcls.getAcl().get(0), writeContext);
verify(aclApi, times(1)).aclAddReplace(aclAddReplaceRequestCaptor.capture());
@@ -211,7 +210,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void updateCurrentAttributesUdp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
final Acl data = standardAcls.getAcl().get(0);
@@ -224,7 +223,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void deleteCurrentAttributesIcmpIpv4(@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(Optional.absent());
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
@@ -237,7 +236,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void deleteCurrentAttributesIcmpIpv6(
@InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp-v6.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(Optional.absent());
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
@@ -249,7 +248,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void deleteCurrentAttributesTcp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-tcp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(Optional.absent());
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
@@ -261,7 +260,7 @@ public class VppAclCustomizerTest extends WriterCustomizerTest implements AclTes
@Test
public void deleteCurrentAttributesUdp(@InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
- AccessLists standardAcls) throws Exception {
+ Acls standardAcls) throws Exception {
when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(Optional.absent());
final int aclIndex = 4;
when(standardAclContext.getAclIndex("standard-acl", mappingContext)).thenReturn(aclIndex);
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclValidatorTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/AclValidatorTest.java
index 287e53f80..6f4d8556f 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/VppAclValidatorTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/AclValidatorTest.java
@@ -16,8 +16,7 @@
package io.fd.hc2vpp.acl.write;
-import static io.fd.hc2vpp.acl.write.VppAclValidator.checkAclReferenced;
-import static java.util.stream.Collectors.toSet;
+import static io.fd.hc2vpp.acl.write.AclValidator.checkAclReferenced;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
@@ -25,51 +24,52 @@ import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.AclTestSchemaContext;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.DataValidationFailedException;
import io.fd.honeycomb.translate.write.WriteContext;
+import java.util.HashSet;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppMacipAcl;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.acl.rev181022.VppAcl;
+import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.acl.rev181022.VppMacipAcl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Acls;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AttachmentPoints;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AttachmentPointsBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@RunWith(HoneycombTestRunner.class)
-public class VppAclValidatorTest implements AclTestSchemaContext {
+public class AclValidatorTest implements AclTestSchemaContext {
- private static final InstanceIdentifier<Acl> ID = InstanceIdentifier.create(AccessLists.class)
- .child(Acl.class, new AclKey("standard-acl", VppAcl.class));
+ private static final InstanceIdentifier<Acl> ID = AclIIds.ACLS
+ .child(Acl.class, new AclKey("standard-acl"));
- @InjectTestData(id = "/ietf-interfaces:interfaces", resourcePath = "/interface-acl/acl-references.json")
- private Interfaces interfaces;
+ @InjectTestData(id = "/ietf-access-control-list:acls/ietf-access-control-list:attachment-points", resourcePath = "/interface-acl/acl-references.json")
+ private AttachmentPoints attachmentPoints;
@Mock
private WriteContext writeContext;
- private VppAclValidator validator;
+ private AclValidator validator;
@Before
public void init(){
initMocks(this);
- when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(Optional.of(interfaces));
- validator = new VppAclValidator();
+ when(writeContext.readAfter(AclIIds.ACLS_AP)).thenReturn(Optional.of(attachmentPoints));
+ validator = new AclValidator();
}
@Test
public void testValidateWrite(
- @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") AccessLists acls)
+ @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") Acls acls)
throws DataValidationFailedException.CreateValidationFailedException {
validator.validateWrite(ID, acls.getAcl().get(0), writeContext);
}
@@ -82,7 +82,7 @@ public class VppAclValidatorTest implements AclTestSchemaContext {
@Test
public void testValidateUpdate(
- @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") AccessLists acls)
+ @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") Acls acls)
throws DataValidationFailedException.UpdateValidationFailedException {
final Acl data = acls.getAcl().get(0);
validator.validateUpdate(ID, data, data, writeContext);
@@ -90,7 +90,7 @@ public class VppAclValidatorTest implements AclTestSchemaContext {
@Test(expected = DataValidationFailedException.UpdateValidationFailedException.class)
public void testValidateUpdateUnsupportedType(
- @InjectTestData(resourcePath = "/acl/ipv4/ipv4-acl.json") AccessLists acls)
+ @InjectTestData(resourcePath = "/acl/ipv4/ipv4-acl.json") Acls acls)
throws DataValidationFailedException.UpdateValidationFailedException {
final Acl data = acls.getAcl().get(0);
validator.validateUpdate(ID, data, data, writeContext);
@@ -98,46 +98,44 @@ public class VppAclValidatorTest implements AclTestSchemaContext {
@Test
public void testValidateDelete(
- @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") AccessLists acls)
+ @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") Acls acls)
throws DataValidationFailedException.DeleteValidationFailedException {
validator.validateDelete(ID, acls.getAcl().get(0), writeContext);
}
@Test(expected = DataValidationFailedException.DeleteValidationFailedException.class)
public void testValidateDeleteReferenced(
- @InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
- AccessLists standardAcls,
- @InjectTestData(resourcePath = "/acl/standard/interface-ref-acl-udp.json")
- Interfaces references) throws Exception {
- when(writeContext.readAfter(InstanceIdentifier.create(Interfaces.class))).thenReturn(
- Optional.of(new InterfacesBuilder().setInterface(references.getInterface()).build()));
+ @InjectTestData(resourcePath = "/acl/standard/standard-acl-udp.json")
+ Acls standardAcls,
+ @InjectTestData(id = "/ietf-access-control-list:acls/ietf-access-control-list:attachment-points",
+ resourcePath = "/acl/standard/interface-ref-acl-udp.json")
+ AttachmentPoints references) throws Exception {
+ when(writeContext.readAfter(AclIIds.ACLS_AP)).thenReturn(
+ Optional.of(new AttachmentPointsBuilder().setInterface(references.getInterface()).build()));
validator.validateDelete(ID, standardAcls.getAcl().get(0), writeContext);
}
@Test
public void testReferencedVppAclFirst() {
- final List<Interface> referenced = checkAclReferenced(writeContext, new AclBuilder()
- .setAclName("acl1").setAclType(VppAcl.class).build());
+ final List<String> referenced = checkAclReferenced(writeContext, new AclBuilder()
+ .setName("acl1").setType(VppAcl.class).build());
assertThat(referenced, hasSize(3));
- assertThat(referenced.stream().map(Interface::getName).collect(toSet()),
- containsInAnyOrder("eth0", "eth1", "eth2"));
+ assertThat(new HashSet<>(referenced), containsInAnyOrder("eth0", "eth1", "eth2"));
}
@Test
public void testReferencedVppAclSecond() {
- final List<Interface> referenced = checkAclReferenced(writeContext, new AclBuilder()
- .setAclName("acl2").setAclType(VppAcl.class).build());
+ final List<String> referenced = checkAclReferenced(writeContext, new AclBuilder()
+ .setName("acl2").setType(VppAcl.class).build());
assertThat(referenced, hasSize(1));
- assertThat(referenced.stream().map(Interface::getName).collect(toSet()),
- containsInAnyOrder("eth1"));
+ assertThat(new HashSet<>(referenced), containsInAnyOrder("eth1"));
}
@Test
public void testReferencedMacipAcl() {
- final List<Interface> referenced = checkAclReferenced(writeContext, new AclBuilder()
- .setAclName("acl4").setAclType(VppMacipAcl.class).build());
+ final List<String> referenced = checkAclReferenced(writeContext, new AclBuilder()
+ .setName("acl4").setType(VppMacipAcl.class).build());
assertThat(referenced, hasSize(1));
- assertThat(referenced.stream().map(Interface::getName).collect(toSet()),
- containsInAnyOrder("eth2"));
+ assertThat(new HashSet<>(referenced), containsInAnyOrder("eth2"));
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java
index 5dc139acc..b6c26ceeb 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclCustomizerTest.java
@@ -17,10 +17,10 @@
package io.fd.hc2vpp.acl.write;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.AclTestSchemaContext;
import io.fd.hc2vpp.acl.util.AclContextManager;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
@@ -31,15 +31,12 @@ import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
import java.util.Collections;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.AclBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.IngressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class InterfaceAclCustomizerTest extends WriterCustomizerTest implements AclTestSchemaContext {
@@ -47,61 +44,70 @@ public class InterfaceAclCustomizerTest extends WriterCustomizerTest implements
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "eth0";
private static final int IFACE_ID = 123;
+ private static final int ACL_ID = 111;
@Mock
private FutureJVppAclFacade aclApi;
@Mock
private AclContextManager standardAclContext;
+ @Mock
+ private AclContextManager macipAclContext;
private InterfaceAclCustomizer customizer;
- private NamingContext interfaceContext;
- private InstanceIdentifier<Acl> ACL_ID = InstanceIdentifier.create(Interfaces.class)
- .child(Interface.class, new InterfaceKey(IFACE_NAME)).augmentation(VppAclInterfaceAugmentation.class).child(Acl.class);
+ private InstanceIdentifier<Interface> IFC_IID =
+ AclIIds.ACLS_AP.child(Interface.class, new InterfaceKey(IFACE_NAME));
+ private Interface ifcAcl;
+ private static final String ACL_NAME = "standard_acl";
+
@Override
- protected void setUpTest() throws Exception {
+ protected void setUpTest() {
defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
- interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- customizer = new InterfaceAclCustomizer(aclApi, interfaceContext, standardAclContext);
+ final NamingContext interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
+ customizer = new InterfaceAclCustomizer(aclApi, interfaceContext, standardAclContext, macipAclContext);
+ ifcAcl = new InterfaceBuilder()
+ .setIngress(new IngressBuilder()
+ .setAclSets(new AclSetsBuilder()
+ .setAclSet(Collections.singletonList(new AclSetBuilder()
+ .setName(ACL_NAME)
+ .build()))
+ .build())
+ .build())
+ .build();
+ when(standardAclContext.getAclIndex(ACL_NAME, mappingContext)).thenReturn(ACL_ID);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
when(aclApi.aclInterfaceSetAclList(any())).thenReturn(future(new AclInterfaceSetAclListReply()));
}
@Test
public void testWrite() throws Exception {
- final Acl acl = new AclBuilder().build();
- customizer.writeCurrentAttributes(ACL_ID, acl, writeContext);
+ customizer.writeCurrentAttributes(IFC_IID, ifcAcl, writeContext);
final AclInterfaceSetAclList list = new AclInterfaceSetAclList();
list.swIfIndex = IFACE_ID;
- list.acls = new int[]{};
+ list.acls = new int[]{ACL_ID};
+ list.count = 1;
+ list.nInput = 1;
verify(aclApi).aclInterfaceSetAclList(list);
}
@Test
public void testUpdate() throws Exception {
- final Acl acl = new AclBuilder().build();
- customizer.updateCurrentAttributes(ACL_ID, acl, acl, writeContext);
+ final Interface updIfcAcl = new InterfaceBuilder().build();
+ customizer.updateCurrentAttributes(IFC_IID, updIfcAcl, ifcAcl, writeContext);
final AclInterfaceSetAclList list = new AclInterfaceSetAclList();
list.swIfIndex = IFACE_ID;
- list.acls = new int[]{};
+ list.acls = new int[]{ACL_ID};
+ list.count = 1;
+ list.nInput = 1;
verify(aclApi).aclInterfaceSetAclList(list);
}
@Test
public void testDelete() throws Exception {
- final VppAcls
- element = mock(VppAcls.class);
- final Acl acl = new AclBuilder()
- .setIngress(new IngressBuilder()
- .setVppAcls(Collections.singletonList(new VppAclsBuilder()
- .setName("asd")
- .build()))
- .build())
- .build();
- customizer.deleteCurrentAttributes(ACL_ID, acl, writeContext);
+ customizer.deleteCurrentAttributes(IFC_IID, ifcAcl, writeContext);
final AclInterfaceSetAclList list = new AclInterfaceSetAclList();
list.swIfIndex = IFACE_ID;
list.acls = new int[]{};
verify(aclApi).aclInterfaceSetAclList(list);
}
-
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclMacipCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclMacipCustomizerTest.java
index b5fa649ca..af3deaca2 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclMacipCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/write/InterfaceAclMacipCustomizerTest.java
@@ -20,23 +20,24 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.AclTestSchemaContext;
import io.fd.hc2vpp.acl.util.AclContextManager;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.vpp.jvpp.acl.dto.AclInterfaceSetAclListReply;
import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceAddDel;
import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceAddDelReply;
import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
+import java.util.Collections;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.IngressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class InterfaceAclMacipCustomizerTest extends WriterCustomizerTest implements AclTestSchemaContext {
@@ -51,27 +52,31 @@ public class InterfaceAclMacipCustomizerTest extends WriterCustomizerTest implem
private FutureJVppAclFacade aclApi;
@Mock
private AclContextManager macipAclContext;
+ @Mock
+ private AclContextManager standardAclContext;
- private InterfaceAclMacIpCustomizer customizer;
+ private InterfaceAclCustomizer customizer;
private NamingContext interfaceContext;
- private InstanceIdentifier<VppMacipAcl> ACL_IID = InstanceIdentifier.create(Interfaces.class)
- .child(Interface.class, new InterfaceKey(IFACE_NAME)).augmentation(VppAclInterfaceAugmentation.class)
- .child(Acl.class).child(Ingress.class).child(VppMacipAcl.class);
- private VppMacipAcl acl;
+ private InstanceIdentifier<Interface> IFC_IID =
+ AclIIds.ACLS_AP.child(Interface.class, new InterfaceKey(IFACE_NAME));
+ private Interface ifcAcl;
@Override
protected void setUpTest() throws Exception {
defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
- customizer = new InterfaceAclMacIpCustomizer(aclApi, macipAclContext, interfaceContext);
- acl = new VppMacipAclBuilder().setName(ACL_NAME).build();
+ customizer = new InterfaceAclCustomizer(aclApi, interfaceContext, standardAclContext, macipAclContext);
+ ifcAcl = new InterfaceBuilder().setIngress(new IngressBuilder().setAclSets(new AclSetsBuilder().setAclSet(
+ Collections.singletonList(new AclSetBuilder().setName(ACL_NAME).build())).build()).build()).build();
when(macipAclContext.getAclIndex(ACL_NAME, mappingContext)).thenReturn(ACL_ID);
+ when(macipAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
when(aclApi.macipAclInterfaceAddDel(any())).thenReturn(future(new MacipAclInterfaceAddDelReply()));
+ when(aclApi.aclInterfaceSetAclList(any())).thenReturn(future(new AclInterfaceSetAclListReply()));
}
@Test
public void testWrite() throws Exception {
- customizer.writeCurrentAttributes(ACL_IID, acl, writeContext);
+ customizer.writeCurrentAttributes(IFC_IID, ifcAcl, writeContext);
final MacipAclInterfaceAddDel request = new MacipAclInterfaceAddDel();
request.swIfIndex = IFACE_ID;
request.isAdd = 1;
@@ -79,19 +84,19 @@ public class InterfaceAclMacipCustomizerTest extends WriterCustomizerTest implem
verify(aclApi).macipAclInterfaceAddDel(request);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testUpdate() throws Exception {
- customizer.updateCurrentAttributes(ACL_IID, acl, acl, writeContext);
+ customizer.updateCurrentAttributes(IFC_IID, ifcAcl, ifcAcl, writeContext);
+ verify(aclApi).aclInterfaceSetAclList(any());
}
@Test
public void testDelete() throws Exception {
- customizer.deleteCurrentAttributes(ACL_IID, acl, writeContext);
+ customizer.deleteCurrentAttributes(IFC_IID, ifcAcl, writeContext);
final MacipAclInterfaceAddDel request = new MacipAclInterfaceAddDel();
request.swIfIndex = IFACE_ID;
request.isAdd = 0;
request.aclIndex = ACL_ID;
verify(aclApi).macipAclInterfaceAddDel(request);
}
-
} \ No newline at end of file